Page 1 of 1

Gif Resize

Posted: Tue Feb 04, 2003 1:59 pm
by GuLdaN
im having a problem with resizing gifs. When i resize a gif file it resizes and makes the new file ok but the image is black.

<?php
$new_width = 300;
$new_height = 250;
$imgname = "test.gif";
$size = GetImageSize("$imgname");
$img_in = imagecreatefromgif("test.gif");
$img_out = imagecreate($new_width, $new_height);

ImageCopyResized($img_out, $img_in, 0, 0, 0, 0, $new_width, $new_height, $size[0], $size[1]);
imagegif($img_out, "tempimages/testsmall.gif");
ImageDestroy($img_in);
ImageDestroy($img_out);

?>

<img src=test.gif>
<img src=tempimages/testsmall.gif>


I have GD Library version 2 and it DOES have gif read and create enabled
gd_info(); returns:
["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true)

So any ideas on how to resize a gif and not have the problem im having or a way to fix my problem would be great,

Cheers

Posted: Tue Feb 04, 2003 2:17 pm
by volka
try

Code: Select all

<?php
ini_set('error_reporting', E_ALL);  // only debug
ini_set('display_errors', TRUE);  // only debug
$imgname = 'test.gif';
$new_width = 300;
$new_height = 250;
$img_in = imagecreatefromgif($imgname) or die('could not open '. $imgname);
$img_out = imagecreate($new_width, $new_height) or die('could not create new image object');
imagecopyresized($img_out, $img_in, 0, 0, 0, 0, $new_width, $new_height, imagesx($img_in), imagesy($img_in));
imagegif($img_out, "tempimages/testsmall.gif") or die('could not write new image file');
?>
instead.
I have no gif-support, so I can't test it ;)

no still broken ;p

Posted: Tue Feb 04, 2003 3:15 pm
by GuLdaN
Nah i still get the same fault even with the new code. Just a black image. I've also tried using imagecopypalette() in order to copy the color palette of the test gif over to the newly made one but i get a green image then instead ;p

You can see it at

http://www.tech-trix.co.uk/phluidity/imageresize.php

any more offers on how to fix this? :p

Posted: Tue Feb 04, 2003 4:31 pm
by volka
hmmm...works quite nice for me with png.
without resizing (only loading and displaying it via imagegif) does your script work?