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

png support in from_html plugin #291

Closed
wants to merge 1 commit into from
Closed

Conversation

woolfg
Copy link
Contributor

@woolfg woolfg commented Jun 27, 2014

support of png images used in img tags

@diegocr
Copy link
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
Copy link
Collaborator

diegocr commented Jun 27, 2014

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

@woolfg
Copy link
Contributor Author

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
Copy link
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
Copy link
Collaborator

diegocr commented Jun 28, 2014

8247a27 should do it.

@woolfg
Copy link
Contributor Author

woolfg commented Jun 29, 2014

yup, works great, just tested. thanks

@woolfg woolfg closed this Jun 29, 2014
@woolfg woolfg deleted the png branch June 29, 2014 16:22
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

Successfully merging this pull request may close these issues.

None yet

2 participants