Re: IMAGE COPY PROBLEM !!! PLEASE HELP !!!
| From: | Matt McClanahan | Date: | Fri, 27 Oct 2000 17:16:05 +0000 |
| Subject: | Re: IMAGE COPY PROBLEM !!! PLEASE HELP !!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22351@lists.php.net to get a copy of this message | ||
On Fri, 27 Oct 2000, Giulio Borrini wrote:
> > PLEASE REPLY TO MY EMAIL ADRESS
> >
> > Hi guys i have this problem:
> >
> > from a file input of a form i get an image called $img.
> > I want to copy it to a dir and then resize it. I use this:
> >
> > if($img_name)
> > {
> > $filename="/www/newWWW/superbici/images_bike/".$img_name;
> > copy($img,$filename);
> > chmod($filename,0777);
> > ImageCopy($filename,$filename,0,0,0,0,400,400);
> > }
> >
> > but it return to me:
> >
> > Warning: Supplied argument is not a valid Image resource in
> > /www/newWWW/superbici/admin/ins_prodotti.php3 on line :
> > "ImageCopy($filename,$filename,0,0,0,0,400,400); "
> >
> > I'm sure that the file exist and it is a regural jpeg.
As per the manual page (And the error message you quoted), ImageCopy needs
an Image resource. You're passing it a string.
You need to load the file into an Image resource first:
$res = ImageCreateFromJpeg($filename);
ImageCopy($res,$res,0,0,0,0,400,400);
However, I'm not sure what you're planning on accomplishing with that
ImageCopy call. It will copy a 400x400 area, and paste it back into the
exact same place.
Matt