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

Purpose : PNG to SVG vector transformation #14

Closed
mastef opened this issue Jun 9, 2019 · 7 comments
Closed

Purpose : PNG to SVG vector transformation #14

mastef opened this issue Jun 9, 2019 · 7 comments

Comments

@mastef
Copy link

mastef commented Jun 9, 2019

I've been looking into how to reduce the filesize of files like this :

b

The .png is 66kb big, but as a svg file should be much much smaller. This could be a great use-case for frontend web images optimization.

Provided issues like #13 #7 and #6 would be implemented, the result could be very close?

Also possibly merging neighbouring same-color shapes. Maybe applying gradient on the final frame.

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 9, 2019

Do you mean for the original pngs to load eventually or to completely replace them? If the former, then this has a mode that uses primitive and might suit your use case: https://github.com/axe312ger/sqip

@mastef
Copy link
Author

mastef commented Jun 10, 2019

To completely replace them - redraw an illustration from a source .jpg / .png to .svg

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 10, 2019

For an image that uses a limited colour palette like your example image, a flood-filling approach that makes SVG polygons by tracing each contiguous block of colour would work much better than hillclimbing.

The hillclimbing approach used in Geometrize produces shapes that won't be "optimally" placed, which changes the style of the output image.

Also, obviously when using fewer shapes you often lose details, like the steam on the coffee cup in your example.

So I don't think the approach here is ideal for completely replacing raster images with SVG, if the aim is to reduce file size.

@mastef
Copy link
Author

mastef commented Jun 12, 2019

@Tw1ddle Any ideas of projects that would be better suited for this?

I was basically thinking of creating an image with 10k shapes and then merging ( and simplifying ) same color neighbour shapes.

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 12, 2019

This has some examples of tools applied to continuous tone images. They all blow up the file size: https://en.wikipedia.org/wiki/Image_tracing#Usage_domains - but given just a few blocks of colour like in your example, they will do much better.

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 17, 2019

Hope that answered your question! 😄

@cancerberoSgx
Copy link
Collaborator

cancerberoSgx commented Jun 21, 2019

@mastef

Hello, I'm experimenting with image tracing technologies with the purpose of converting bitmap images to vector graphics.

Right know I have relatively well results and working on a tool that provide JavaScript API for Node.js and browsers and CLI: https://www.npmjs.com/package/svg-png-converter

The tracing libraries used are potrace and bitmap2vector

Right now I'm trying to build a geometrize JavaScript API from geometrize-haxe sources Tw1ddle/geometrize-haxe-web#3 and #15 since I think it can be a a very good technology for this (and also because I think it would be awesome to have a official JavaScript API of this project). Checkout Tw1ddle/geometrize-haxe-web#3 (comment)

Help welcome and also if you know another image tracing technology that might be useful for this....

Thanks

This issue was closed.
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

3 participants