png support in from_html plugin #291

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@woolfg
woolfg commented Jun 27, 2014

support of png images used in img tags

@diegocr
Collaborator
diegocr commented Jun 27, 2014

How about if we modify addImage() to detect the format from the raw data? (it does already for data-uris)

I think it'd be matter of checking if the first four bytes matches with 0x89504e47

@diegocr
Collaborator
diegocr commented Jun 27, 2014

Check 0f3c2d0 - it's untested but i think it should work :)

@woolfg
woolfg commented Jun 27, 2014

hey, that's possible, but I just tried 0f3c2d0 which is not working as createDataURIFromElement (line 498) needs the format to convert the image to a data uri (i think)

@diegocr
Collaborator
diegocr commented Jun 27, 2014

Oops, wrongly recall fromHTML's images[] contains raw data while they are indeed IMG nodes :$

Well, i'm still thinking that should be added to the addImage plugin, so feel free to modify createDataURIFromElement by reusing the 'element.nodeName === 'IMG' block.

Btw, relying on the file extension isn't accurate as you can guess, but if we have to check that i'd rather use /\.png(?:[?#].*)?$/i.test(src)

@diegocr
Collaborator
diegocr commented Jun 28, 2014

8247a27 should do it.

@woolfg
woolfg commented Jun 29, 2014

yup, works great, just tested. thanks

@woolfg woolfg closed this Jun 29, 2014
@woolfg woolfg deleted the woolfg:png branch Jun 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment