Page 1 of 1

error with imagecopy!!!

Posted: Sat Jun 07, 2008 2:37 pm
by sara933
hi friends
a question:
i want to fetch an image(type:blob) from sql database and then copy it to another image with imagecopy().i use this :
....$row=mysql_fetch_query($query);
$content=$row['image'];

imagecopy($image,$content,0,0,0,0,$w,$h);
imagejpeg($image);
(header is sent and $image made by imagecreate())
but the error says:imagecopy():supplied argument is not a valid image resource
why here is this error
is it nessasary that i first stor the image in a binary temprary file and then send it to the function???
regards

Re: error with imagecopy!!!

Posted: Sat Jun 07, 2008 3:23 pm
by onion2k
When you fetch the data from the database it's just a blob of binary data ... PHP doesn't know it's an image. You need to tell it that it is. Use...

Code: Select all

$image = imagecreatefromstring($content);
You should then be able to use $image where you tried to use $content before.

Re: error with imagecopy!!!

Posted: Sat Jun 07, 2008 3:45 pm
by sara933
thank u very much onion2k it works :D :D :D