How I solved "Corrupt JPEG data: 295 extraneous bytes before marker 0xd9" error
2008-0903 3:56am -- How I solved "Corrupt JPEG data: 295 extraneous bytes before marker 0xd9" error in apache logs:
Simple! hehe, after searching and searching and getting no help, I got it! :
I edited C source code by hand in libjpeg library and recompiled it.
First, I got rid of RPMs of libjpeg and installed my own. With this, I can now edit source.
First, I've noticed that in jpegsrc.v6b.tar.gz there is a file called jerror.h, which has these lines:
JMESSAGE(JWRN_EXTRANEOUS_DATA,
"Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
Then, I looked for JWRN_EXTRANEOUS_DATA string and found it in jdmarker.c
And then, I commented out the warning line in that file, as below:
if (cinfo->marker->discarded_bytes != 0) {
/*WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); Commented out by Denny! */
cinfo->marker->discarded_bytes = 0;
}
Then I recompiled jlib, then GD, then PHP, and finally apache, and the error was gone !
It's just a warning anyway. It was just severely messing with my PHP scripts and not displaying Pictures when it should have ! !!
Now it is displaying pictures, so good !
Later, I've tested and I only need to recompile jlib, nothing else.
stop and start apache (don't use restart, use stop and start), as sometimes it doesn't catch right away for some reason.