Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Names of images in markdown #49

Open
JonathanCrossland opened this issue Sep 9, 2019 · 14 comments
Open

Names of images in markdown #49

JonathanCrossland opened this issue Sep 9, 2019 · 14 comments

Comments

@JonathanCrossland
Copy link

Hi. thanks for working on this :)

When you export to HTML from google docs, they name the files image1.jpg, image2.jpg etc.
We get a nice folder of images.

If you output ![images/image1.jpg] - etc instead of title + index + jpg, it would make life a lot easier when mapping image files.

we could simply copy the folder into the relative path and it should work.

if you then suppress all the error warning, it would help us make this process a bit cleaner..
what do you think?

@evbacher
Copy link
Owner

evbacher commented Sep 10, 2019

Yes, that's a good suggestion. I can change the way the image link is output.

It is possible to save the image files, but that requires excessive permissions.

@JonathanCrossland
Copy link
Author

excessive permissions would be bad, I agree and thanks for considering the change.

@SergiosKar
Copy link

+1 on changing the name. it will indeed make the mapping much much easier

@evbacher
Copy link
Owner

evbacher commented May 7, 2020

I can easily change the name. However, the order of the images in the zip file is not the same as the order in the Google Doc. So there may be some manual rejiggering required, unless there's some obvious but as-yet undiscovered scheme for ordering the images in the zip file.

@hllorens
Copy link

Hi, this seems a great addon, but for me to be useful I need the original images (the path can just be the original one pointing to google server)

@evbacher
Copy link
Owner

As of today's update (1.0β25), the image path is now in the form images/image1.png, images/image2.jpg, etc. However, beware that the exported zip file from Google Docs does not always have the images in the same order, so you'll still need to check that the images are referenced in the correct place in your converted doc. There does not seem to be any rhyme nor reason about the order in the exported zip file that you get from Download > Web Page.

@SergiosKar
Copy link

fyi I'm 90% sure that the order of the exported images is the same with the order that they been added to the docs.. not sure if there is something you can do about though

@evbacher
Copy link
Owner

evbacher commented Jun 3, 2020

I wish this were so, but I just tested it again: I added 4 images, and they came out in the zip file as image1, image2, image4, image3. I've only done a few experiments, but each time I've seen them come out in a different order than they appear in the doc (and in this case, I made sure to add them in that order, top to bottom of the doc). So, it looks like you'll still need to proofread the doc to make sure you get the images in the right spots.

@SergiosKar
Copy link

oooh. it just looks so weird that google has enforced no order in that.. anyway thanks for spending time on it

@sjovanovic
Copy link

This issue should be open.
It basically downgrades the entire add-on to a toy.

@evbacher
Copy link
Owner

If you find out the scheme that Google uses to name the images (it's not the order in the Doc), let me know and we can fix that. Otherwise, I don't know of any way to guarantee that the image names correspond to the correct images as Google exports them into the zip file.

@evbacher
Copy link
Owner

Reopening in hopes that Google will (someday) export the images in a reproducible order.

@evbacher evbacher reopened this Dec 11, 2021
@sjovanovic
Copy link

sjovanovic commented Dec 13, 2021

Thanks for reopening.

I don't think Google cares about this. Random order is probably side effect of some optimization.
Better bet in my opinion is to create a zip from within the script. Something like this...

In your gdc.handleImage function add inline image blobs inside of a global array i.e.:

imgBlob.setName('image' + gdc.imageCounter + fileType)
if(!Array.isArray(gdc.imageBlobList)) gdc.imageBlobList = []
gdc.imageBlobList.push(imgBlob)

Then after everything is done, create a ZIP file and save to Drive i.e.:

let zip = Utilities.zip(gdc.imageBlobList);
let newFile = DriveApp.createFile(zip, "inline_images.zip");

Also, I wonder if just setting imgBlob.setName('image' + gdc.imageCounter + fileType) would affect google's export to name the files accordingly.

@evbacher
Copy link
Owner

evbacher commented Dec 13, 2021

The original version of this did export images to a zip file stored in Drive, but it requires very intrusive permssions (read all Drive files, write to Drive) that most people do not want to grant to an add-on. So I'm not planning to do that. It would be possible to do in a separate add-on, but it would still require lots of permissions.

I will check out your suggestion that imgBlob.setName might affect Google's export to name the files in the correct order (though I doubt it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants