Jump to content

Warning: imagecopyresized(): supplied argument is not a valid Image resource


Sabmin

Recommended Posts

so I have an array with a bunch of photos, and I'm trying to create a thumbnail of each to display on a page with a link to the full sized image but I'm getting the error in the subject title... if I just display the images in the array without trying to resize them it works fine... can anyone clue me into why this isn't working please.

 

	echo ("<a href='" . $img['file'] . "'>");
$new_width = (floor($img['size'][0] * ".25"));
$new_height = (floor($img['size'][1] * ".25"));
$tmp_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresized($tmp_img, $img['file'], 0, 0, 0, 0, $new_width, $new_height, $img['size'][0], $img['size'][1]);
echo ("<img src='" . $tmp_img . " . $img['size'][3] , "' alt=''><br>\n");
echo basename($img['file']);
echo "</a><br>\n";

alright so I got rid of the warning and later fatal error with the imagecreatefromjpeg and imagejpeg functions but now instead of a picture I get a whole lot of �����JFIF���������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ���C�

I'm sure that can't be all the code.

 

If using gd are supposed to send out the header of the image type, is why are seeing the garble, plus the img as basename, pretty much the code that makes the image.

 

Try reading some gd tutorials to do what you need, or find one already made, is plenty out there very similar to what you want to accomplish.

 

http://www.php.net/manual/en/function.imagecopyresized.php

 

Or this script may do everything you need already

 

http://phpthumb.sourceforge.net/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.