pycairo
pycairo copied to clipboard
Support for write_to_jpg
This PR implements write_to_jpg method, I'm not sure if it is suitable for pycairo, since it is not part of cairo interface, but it helps a lot in my project for which the performance of output to image format is cruicial - PNG is too slow.
As you have guessed this is out of scope for pycairo. Adding another dependency makes things more complicated and having a different api than cairo is confusing.
We can look into other ways to improve your use case maybe.
What are your requirements? Lots of images? small, large? in memory, saving to disk? auto-generating on client request?
Interactive charts, PNG is 10x slower:
https://www.czsky.cz/chart?ra=0.1452909172145668&dec=0.08127808535581996&fsz=100&splitview=true
it's running on pycairo+JPG (80-90% quality) now.
Please have a look at https://github.com/pygobject/pycairo/pull/281
In theory it should solve your problem without adding any new APIs, assuming you can use pillow in your project.
Feedback welcome.
This is now live here: https://pycairo.readthedocs.io/en/latest/integration.html#pillow-pil-cairo
Thanks for help! It is working for me.