Skip to content
Advertisement

Tag: python-imaging-library

PIL’s colour space conversion YCbCr -> RGB

The algorithm used by PIL v1.1.7 gives ‘washed out’ looking results. When converting the same source data using ffmpeg it looks correct. Using mplayer gives identical results to ffmpeg (perhaps they use the same library underneath). This leads me to believe PIL may be stuffing up the colour space conversions. The conversion seems to be sourced in libImaging/ConvertYCbCr.c: This is

Python: The _imagingft C module is not installed

I’ve tried lots of solution that posted on the net, they don’t work. So the system can find the _imaging but still can’t use truetype font Raises this error: Answer Your installed PIL was compiled without libfreetype. You can get precompiled installer of PIL (compiled with libfreetype) here (and many other precompiled Python C Modules): http://www.lfd.uci.edu/~gohlke/pythonlibs/

Center-/middle-align text with PIL?

How would I center-align (and middle-vertical-align) text when using PIL? Answer Deprecation Warning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead. Code using textbbox instead of textsize. Result Use Draw.textsize method to calculate text size and re-calculate position accordingly. Here is an example: and the result: If your fontsize is different, include

How to use PIL to make all white pixels transparent?

I’m trying to make all white pixels transparent using the Python Image Library. (I’m a C hacker trying to learn python so be gentle) I’ve got the conversion working (at least the pixel values look correct) but I can’t figure out how to convert the list into a buffer to re-create the image. Here’s the code Answer You need to

Advertisement