Difference between imagegif/imagejpeg sending to browser <-> saving to file?

View: New views
2 Messages — Rating Filter:   Alert me  

Difference between imagegif/imagejpeg sending to browser <-> saving to file?

by zyro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello together,

I stumbled onto a curious problem:
i am generating a jpeg/gif with the imagejpeg/imagegif functions (type does not alter the result).

Example color "#ff0000": The hexToRGB coversion etc is all working fine. The image (if its send directly to the browser via header and imagegif/imagejpeg) is displayed 100% correctly.
But if i save it to a file on the servers file system, the red above gets lime green. And not only those two colors are bugged: It looks like the whole palette gets scrambled up ???

So my question: Is there a-n-y difference between sending and saving the image?
Or do I have to do some additional work before an image can be saved correctly? php func reference says something about using imagecolortransparent() on the image first to achieve the 89a format (in case of gif) but again: This does not alter the result either. Also, transparency is not needed at this point but used in images that are merged (gifs) to achieve the final result.

Another interesting point:
- generated image sent to browser, properties: ~3kb
- generated image, saved in filesys, properties: ~15kb
What explains that diff in filesize?

Thanks for your help,

greets,

zyro

Re: Difference between imagegif/imagejpeg sending to browser <-> saving to file?

by zyro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lo again,

found my mistake.. in fact, it was the hex-to-rgb conversion not working properly in some cases.

[SUBJECT CLOSED]

zyro wrote:
Hello together,

I stumbled onto a curious problem:
i am generating a jpeg/gif with the imagejpeg/imagegif functions (type does not alter the result).

Example color "#ff0000": The hexToRGB coversion etc is all working fine. The image (if its send directly to the browser via header and imagegif/imagejpeg) is displayed 100% correctly.
But if i save it to a file on the servers file system, the red above gets lime green. And not only those two colors are bugged: It looks like the whole palette gets scrambled up ???

So my question: Is there a-n-y difference between sending and saving the image?
Or do I have to do some additional work before an image can be saved correctly? php func reference says something about using imagecolortransparent() on the image first to achieve the 89a format (in case of gif) but again: This does not alter the result either. Also, transparency is not needed at this point but used in images that are merged (gifs) to achieve the final result.

Another interesting point:
- generated image sent to browser, properties: ~3kb
- generated image, saved in filesys, properties: ~15kb
What explains that diff in filesize?

Thanks for your help,

greets,

zyro