[Image-SIG] Re: problem decoding JPEG files on freshly built PIL 1.1.2 on BSD unix

Eric Woudenberg eaw@connactivity.connactivity.com
Sun, 10 Feb 2002 11:02:07 -0500


Hi,

First: Thank you for creating PIL, it is very useful!

Just FYI, I found the problem that I previously raised (see quoted
mail at end). The trouble was that there was already an earlier
libjpeg installed on the BSDi4.0 system that was getting picked up
during linking, but the include files used during compilation of PIL
came from a freshly unpacked Jpeg-6b distribution. So this test in
jdapimin.c was failing:

GLOBAL(void)
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
{
  int i;

  /* Guard against version mismatches between library and caller. */
  cinfo->mem = NULL;		/* so jpeg_destroy knows mem mgr not called */
  if (version != JPEG_LIB_VERSION)
    ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);

I found it by enabling the error printf in JpegDecode.c:

METHODDEF(void)
error(j_common_ptr cinfo)
{
  JPEGERROR* error;
  error = (JPEGERROR*) cinfo->err;
#if 1
  /* DEBUG */
  cinfo->err->output_message(cinfo);
#endif
  longjmp(error->setjmp_buffer, 1);
}

My one suggestion would be to always print a message here, it's not
the sort of information that a programmer would not want to know about. 

Thanks,
Eric

Eric Woudenberg writes:

>I'm using PIL 1.1.2 happily under Windows to produce thumbnails from
>.gif and .jpeg files. The final app must run under BSDI4.0. I rebuilt
>PIL from sources, also built Jpeg-6b and zlib-1.1.3. Everything built
>and passed tests (PIL passed up to the point where the image was
>trying to be displayed -- I don't have a screen on this machine):
>
>mook:~/src/Imaging-1.1.2/libImaging $ make check
>./coretest
>>>> processing lena.ppm...
>>>> elapsed time: 10
>>>> as far as we tested, everything seems to be ok...
>xv test.ppm
>xv: Can't open display
>*** Error code 1 (ignored)
>
>
>But when I use it, I always get an error that it couldn't decode the file:
>
>mook:~/src/Imaging-1.1.2/Images $ python
>Python 2.2 (#5, Jan 27 2002, 22:13:28) 
>[GCC 2.7.2.1] on bsdos4
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import Image
>>>> a=Image.open('lena.jpg')
>>>> a.getbbox()
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "/home/minidisc/local/lib/python2.2/site-packages/PIL/Image.py", line 5
>14, in getbbox
>    self.load()
>  File "/home/minidisc/local/lib/python2.2/site-packages/PIL/ImageFile.py", li
>ne 166, in load
>    raise IOError, "decoder error %d when reading image file" % e
>IOError: decoder error -2 when reading image file
>>>> 
>
>Any ideas? My impression was that this should "just work", given that
>it all works so nicely under windows.
>
>The Jpeg decoder is being built in (from ImConfig.h):
>
>/* Define if you have the IJG jpeg library (-ljpeg).  */
>#define HAVE_LIBJPEG 1
>
>GIF files seem to work okay.
>
>Thanks in advance for any help or suggestions.
>
>Eric Woudenberg
>