https://github.com/enjeck/jpg2svg
Convert JPG images to SVG
https://github.com/enjeck/jpg2svg
converter image-converter image-manipulation image-to-image image-to-image-translation jpeg jpg svg
Last synced: 7 months ago
JSON representation
Convert JPG images to SVG
- Host: GitHub
- URL: https://github.com/enjeck/jpg2svg
- Owner: enjeck
- Created: 2021-09-14T17:34:06.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-11T04:18:46.000Z (almost 4 years ago)
- Last Synced: 2025-02-28T19:30:06.548Z (7 months ago)
- Topics: converter, image-converter, image-manipulation, image-to-image, image-to-image-translation, jpeg, jpg, svg
- Language: Python
- Homepage:
- Size: 887 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jpg2svg
An attempt at converting colored JPG images to colored SVG. It automatically traces the image in layers and applies dominant colors selected from the image to each layer.
Some results (JPG and converted SVG side by side)
Images with higher contrast, and with white backgrounds produce better results:
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
### Technical details
The actual image conversion code is held at [svg.py](svg.py). Below is a summary of the steps it follows:
- Resizes the image to reduce processing time
- Quantitizes the image to reduce the number of colors to work with
- Calculates the luminance/brightness of dominant colors
- Converts the JPG image to bitmap (since Potrace, used for tracing, only supports the Bitmap format)
- Uses luminance values as thresholds for tracing the image into multiple layers
- Converts the tracing to XML
- Applies dominant colors to each of the layers
- Groups the various layers into one SVG element