pycairo icon indicating copy to clipboard operation
pycairo copied to clipboard

Support for write_to_jpg

Open skybber opened this issue 3 years ago • 2 comments

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.

skybber avatar Sep 26 '22 07:09 skybber

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?

lazka avatar Oct 01 '22 11:10 lazka

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.

skybber avatar Oct 01 '22 13:10 skybber

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.

lazka avatar Oct 16 '22 15:10 lazka

This is now live here: https://pycairo.readthedocs.io/en/latest/integration.html#pillow-pil-cairo

lazka avatar Oct 16 '22 16:10 lazka

Thanks for help! It is working for me.

skybber avatar Oct 16 '22 17:10 skybber