Problem with image base64 encoding: images are 'quite never' displayed in the created html
I build an html doc by encoding images with base64.
Then, I upload the html on google docs, but images are 'quite never' displayed. The encoding is right: for example, I use this to do the image encoding and then I use it in theimg
tag for the src
attribute, changing properly the data type
<img src='data:image/gif;base64,<IMG_ENCODING>' />
or
<img src='data:image/jpeg;base64,<IMG_ENCODING>' />
or
<img src='data:image/png;base64,<IMG_ENCODING>' />
EDIT
I think the problem is tied to compression. I tried to use
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(image, 0.0f)];
And some of the images (that before aren't displayed) are displayed. But other images aren't. I don't know if there is a limit to the length on the base64 string开发者_运维问答 on gdocs.
Is there a way to compress the base64 string before sending it to the server? or?Any hint is greatly welcomed.
None of your images are displayed or only some ? And if only some, then only the small ones are displayed ? Because if you answer yes to all then the problem is that your files are to large to be used as base64 encoded sources for the image tags. The browser reads that as a url and there is a limit to the length of a url (about 7-8kb max)
精彩评论