Reputation: 6197
Im creating images to output. When I call the final imagegif()
I get the usual "the image sdfsdsdf cannot be displayed because it contains errors". But if I save this image by the 2nd parameter, it DOES result in a valid GIF image! And imagegif()
returns true.
Now what?
Upvotes: 0
Views: 937
Reputation: 16214
But if I save this image by the 2nd parameter, it DOES result in a valid GIF image! And imagegif() returns true. Now what?
Check the output of your script - it sends something else to the browser. Typically it could be error/warning/notice messages, text output from that script or from another one included into it, spaces/new lines or something else (like BOM record in case of UTF encoding in script file) before the <?php
tag.
Solution is simple - comment the header('Content-Type: image/gif');
and call script directly (not the page including the images generated by the script). Check for anything before the 'garbage' of the binary content of the image file itself.
You may need to add error_reporting(E_ALL); ini_set('display_errors', 1);
at the top of the script in case error reporting/display is turned off as well.
Upvotes: 1
Reputation: 615
if you use imagegif() with one parameter then need to use and
header('Content-Type: image/gif');
becouse the image is displayed in browser , else the image is saved into file.
Upvotes: 1