Re: Image Resample

From: Date: Wed, 09 Apr 2003 13:05:37 +0000
Subject: Re: Image Resample
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143068@lists.php.net to get a copy of this message
On Wednesday 09 April 2003 06:42, Jonathan Duncan wrote: > I am trying to upload a file and then resample it to a smaller size. Using > the script below the file gets copied to the server but then it gives me > this error message: > > Warning: Supplied argument is not a valid Image resource in > /path/to/file/do_upload.php on line 8 It would be nice if you indicated which is line 8. > <? > if ($img1_name != "") { > if ($img1_size <= 100000) { > copy("$img1", "pics/$img1_name") or die("Couldn't copy the > file."); > $src_img = "pics/$img1_name"; > $dst_img = "pics/image_resampled.jpg"; > $imageinfo = getimagesize("pics/".$img1_name); > imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 10, 10, > $imageinfo[0], $imageinfo[1]); You're giving the wrong type of parameters to imagecopyresampled(). It requires an image resource, NOT filenames. You need to assign an image resource to both src and dst using (I think) imagecreatefromjpeg() and imagecreatetruecolor() respectively. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* 13. ... r-q1 */

« previous php.general (#143068) next »