views:

77

answers:

1

I have a script that will output a jpg, gif or png image. It uses the appropriate content-type according to the extension of the file (which in this case will be the right one always).

The problem is, I have a small number of files which will cause a 500 internal server error when I try to access them this way. However they work if I try to access them with a direct link.

These files have one difference: their color profile is not sRGB built-in, but instead it is "sRGB IEC61966-2.1", or "Uncalibrated".

Why am I getting an error?

My script: http://pastie.org/pastes/404257

EDIT: I changed from include to readfile and it worked. But I don't know why...

A: 

No, MIME types do not specify colour profiles. Everything needed to interpret a colour profile is embedded in the data of the image; there is no requirement for extra information at the basic transfer level in order to support colour profiles.

The problem was likely due to something else. For example, if you included them with PHP include(), then an occurence of the byte sequence '<?' may have caused the PHP parser to kick in, generating errors.

Changing to readfile() as you have done looks like the correct solution.

Note: the script you linked to has some serious security problems caused by lack of input validation. You may already know this and were just using it as a simplified example, in which case - hopefully nobody copies the code.

thomasrutter
Thanks, and yes it is only a simplified example.