bug in gdImageGetPixel & JPEG Images? (OS X)

[email protected] (Ian Banfield)
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hello!

I'm using OS X 10.4.10, xCode 2.5 (which uses gcc to compile C), GD  
2.034 and libjpeg, installed via macports. (The same problems occures  
if everything is compiled from sources, including 2.035 and the  
latest CVS snapshot). The linker flags are set to "-lgd -lpng -lz - 
ljpeg -lfreetype -lm", library search paths to /opt/local/lib and  
header search paths to /opt/local/include (which should be the  
appropriate settings for GD if it was installed via macports).

My code basically consists of the gdImageGetPixel example in the manual:

#include <stdio.h>
#include "gd.h"

int
main (void)
{
	FILE *in;
	gdImagePtr im;
	int c;
	in = fopen("image.jpg", "rb");
	im = gdImageCreateFromJpeg(in);
	fclose(in);
	printf("%d by %d\n", gdImageSX(im), gdImageSY(im));
	c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);
	printf("The value of the center pixel is %d; RGB values are %d,%d,%d 
\n", c, im->red[c], im->green[c], im->blue[c]);
	gdImageDestroy(im);
	return 0;
}

This works very well for gif files (replacing image.jpg by image.gif  
and ..createfromJpeg by ..fromGif) and it outputs the correct result.  
However, the code above yields a EXC_BAD_RESULT error in the printf 
(...) line. The gdImageSizeSX and .. gdImageSizeSY functions return  
the correct result and the pixel to be selected is certainly inside  
the image (gdImageGetPixel(im,0,0) leads to the same error). JPEG  
Support is certainly enabled and e.g. converting jpeg to png files  
seems to work fine.)

Any ideas?

thanks, ian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.