Skip to content

handy function for converting high-res whiteboard sketches to crisp, transparent PNGs

License

Notifications You must be signed in to change notification settings

GMakarenko/transparent-png

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

transparent-png

handy function for converting high-res whiteboard sketches to crisp, transparent background PNGs. Thanks for the wicked-awesome Marciana drawing, Monica ;)

Getting running

Super easy:

  • clone this repo
  • cd transparent-png
  • pip install -r requirements.txt
  • To test: python converter.py

You should go from this...

Imgur

to this:

Imgur

You can point the converter at any file and manually specify the output file: python converter.py --in_file /tmp/myjpeg.jpg --out_file mypng.png

Tuning the conversion

I use a sigmoid function the looks at how dark a pixel is and, based on that, assigns it an alpha transparency. The sigmoid function is nice because it renders a smooth gradient against a transparent background, avoiding the awkward discontinuities that a simple threshold would create. The defaults I picked worked pretty well, but if you'd like to play with them this is the function you'll be adjusting:

Imgur

--offset shifts the curve right and left, and --steepness controls the steepness of the transparency gradient. The larger this number, the closer your approximation to a strict threshold for transparency will be.

About

handy function for converting high-res whiteboard sketches to crisp, transparent PNGs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%