JPEG decoder not available in PIL

Discussion in 'Python' started by Peter, Dec 6, 2005.

  1. Peter

    Peter Guest

    I have a problem which seems to come up from time to time but I can't
    find anything relevant in the archives. I have used PIL v1.1.5 with no
    problem on Windows for some time but now wish to put it on Linux (Suse
    Linux v10.0). I obtained and built the JPEG libraries (jpeg-6b) without
    any problem. The tests for the installation work fine. I built Python
    2.4.2 from the sources but with no special options, just 'out of the
    box'. This works fine. PIL built as it should but the selftest.py fails
    with the ‘'decoder jpeg is not available'’ message (the other 54
    tests are OK). Other images are opened and shown with xv, no problem. I
    think that there is something wrong with the libraries or the way they
    linked. ....

    At the last moment I managed to solve this problem and I hope it is
    worth supplying the details here. First there is a file in the install
    directory libImaging/Jpeg.h which has a line:

    #include "jpeglib.h"

    but there is no such header file. On my system I put:

    #include "/usr/local/include/jpeglib.h"

    which is where the JPEG installation put the include files for the
    library. With this change all 55 tests passed successfully. Then I
    copied the PIL library from the installation directory where it was
    built to the Python site-packages location. And then everything worked.
    For some reason it was not enough to do python setup.py install but
    this is probably an artifact of previous failures.

    Hope this helps someone ...

    Peter
     
    Peter, Dec 6, 2005
    #1
    1. Advertising

  2. Peter wrote:
    > At the last moment I managed to solve this problem and I hope it is
    > worth supplying the details here. First there is a file in the install
    > directory libImaging/Jpeg.h which has a line:
    >
    > #include "jpeglib.h"
    >
    > but there is no such header file. On my system I put:
    >
    > #include "/usr/local/include/jpeglib.h"
    >
    > which is where the JPEG installation put the include files for the
    > library. With this change all 55 tests passed successfully.


    This is baaaaad! You're mixing two libraries here, for one the system jpeg
    library and for another your library. Probably the dynamic loader cache
    finds the system library first, so although you included the specifications
    for the library you installed to /usr/local, you link against the system
    library which might be different (in this case it is not and for jpeglib
    will never be, but nevertheless, this is an absolute NONO).

    PIL comes precompiled for SuSE, btw., and the package is called Imaging,
    IIRC (long time since I've tried SuSE).

    Next time round you want to install something, read up on the distinction
    between <pkg> and <pkg>-devel. The former contains only the files necessary
    at runtime (thus, no static libraries, no headers, etc.), while the latter
    contains everything the package installs that isn't in the former. Thus, to
    install PIL you should have done:

    rpm -Uvv libjpeg-devel-<something>.rpm

    or installed

    libjpeg-devel

    using the SuSE package manager. Then the PIL intallation would have found
    the appropriate header files and compiled successfully. Actually, you must
    have installed python-devel for the installation package to succeed. Or did
    you build Python yourself and overwrote the standard python that was
    installed? If so, really do read up on package management using RPM,
    there's quite a lot on this on SuSE's site. Otherwise you'll wreck your
    system in the longrun...

    --- Heiko.
     
    Heiko Wundram, Dec 7, 2005
    #2
    1. Advertising

  3. "Peter" wrote:


    > At the last moment I managed to solve this problem and I hope it is
    > worth supplying the details here. First there is a file in the install
    > directory libImaging/Jpeg.h which has a line:
    >
    > #include "jpeglib.h"
    >
    > but there is no such header file. On my system I put:
    >
    > #include "/usr/local/include/jpeglib.h"
    >
    > which is where the JPEG installation put the include files for the
    > library.


    note that the setup file does in fact pass in /usr/local/include via the
    compiler's -I option, so if the above fix made things work, your compiler
    setup is pretty weird...

    or maybe you have conflicting versions of libjpeg installed in different
    locations? (but I don't think there has ever been conflicting releases
    of libjpeg, so that doesn't seem likely...)

    </F>
     
    Fredrik Lundh, Dec 7, 2005
    #3
  4. Peter

    Paul Dickson Guest

    On 6 Dec 2005 14:02:37 -0800, Peter wrote:

    > I have a problem which seems to come up from time to time but I can't
    > find anything relevant in the archives. I have used PIL v1.1.5 with no
    > problem on Windows for some time but now wish to put it on Linux (Suse
    > Linux v10.0). I obtained and built the JPEG libraries (jpeg-6b) without
    > any problem. The tests for the installation work fine. I built Python
    > 2.4.2 from the sources but with no special options, just 'out of the
    > box'. This works fine. PIL built as it should but the selftest.py fails
    > with the ‘'decoder jpeg is not available'’ message (the other 54
    > tests are OK). Other images are opened and shown with xv, no problem. I
    > think that there is something wrong with the libraries or the way they
    > linked. ....


    It seems you did not build the RPMs for the JPEG libraries, so the
    include files were not placed in the correct location:

    # rpm -ql libjpeg-devel
    ...
    /usr/include/jpeglib.h
    ...

    Perhaps you should try "yum install libjpeg libjpeg-devel" if Suse
    supports yum.

    -Paul
     
    Paul Dickson, Dec 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jbrewer

    PIL FITs image decoder

    jbrewer, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    1,757
    jbrewer
    Nov 23, 2005
  2. lovaspillando
    Replies:
    0
    Views:
    1,064
    lovaspillando
    Aug 26, 2007
  3. Ivan Alameda Carballo
    Replies:
    0
    Views:
    509
    Ivan Alameda Carballo
    Aug 26, 2007
  4. Dario Traverso
    Replies:
    4
    Views:
    4,597
    Zvezdan Petkovic
    Feb 26, 2009
  5. Patrick Sabin

    SVG PIL decoder

    Patrick Sabin, Sep 30, 2009, in forum: Python
    Replies:
    0
    Views:
    319
    Patrick Sabin
    Sep 30, 2009
Loading...

Share This Page