How to install PIL with JPEG support on raspberry pi?

I tried installing PIL on my raspberry pi and read the jpeg files. However, this does not work out of the box.

When I run the following:

sudo pip install pil 

I get the following error while trying to open an image:

 ""decoder jpeg not available"" 

When I tried to install all the necessary JPEG libraries, I encountered some errors, for example:

 sudo apt-get install libjpeg E: Unable to locate package libjpeg 
+6
source share
1 answer

You need to reinstall PIL, as well as install the necessary libraries, as well as link them manually. This answer is based on this blog post for regularly installing Pub Ubuntu and this askubuntu question , which explains how to compile jpeg encoding:

 ### uninstall PIL sudo pip uninstall pil ### download and compile the JPEG library wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz tar xvfz jpegsrc.v8c.tar.gz cd jpeg-8c ./configure --enable-shared --prefix=$CONFIGURE_PREFIX make sudo make install ### link the libraries correctly - RASPBERRY PI ONLY sudo ln -s /usr/lib/arm-linux-gnueabi/libjpeg.so /usr/lib sudo ln -s /usr/lib/arm-linux-gnueabi/libfreetype.so /usr/lib sudo ln -s /usr/lib/arm-linux-gnueabi/libz.so /usr/lib ### install rest of the libraries, as well as freetrype and zlib sudo apt-get install libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev ### re-install PIL sudo pip install pil 

Hope this helps someone!

+13
source

Source: https://habr.com/ru/post/958728/


All Articles