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";

Link to comment
Share on other sites

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�

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.