Forum Moderators: coopster

Message Too Old, No Replies

imagecopyresampled problem

Image in db unable to be used with imagecopyresampled

         

mattbyrnes

5:56 am on Sep 22, 2007 (gmt 0)

10+ Year Member



Hi,

This displays the image from the database without issue:

12 $source_image=// image retrieved from db
19 // Output
20 header('Content-type: image/jpeg');
21 echo $source_image;

This displays a 'canvas' destination image without issue:

14 $dst_image=imagecreatetruecolor(100, 100);
19 // Output
20 header('Content-type: image/jpeg');
24 imagejpeg($dst_image);

However, when I try to combine the two in order to resize the image in the database, I get a 'Warning</b>: imagecopyresampled(): supplied argument is not a valid Image resource'

// Get image from database
12 $source_image=$image_obj->decodeImage($row->image);
13
14 $dst_image=imagecreatetruecolor($get_obj->dst_w_int, $get_obj->dst_h_int);
15
16 // Resize
17 imagecopyresampled($dst_image, $source_image, $get_obj->dst_x_int, $get_obj->dst_y_int, $get_obj->src_x_int, $get_obj->src_y_int, $get_obj->dst_w_int, $ get_obj->dst_h_int, $get_obj->src_w_int, $get_obj->src_h_int);
18
19 // Output
20 header('Content-type: image/jpeg');
24 imagejpeg($dst_image);

(The get_obj values are values passed in via _GET and all are successfully set.)

Thanks for any help!

mattbyrnes

4:44 pm on Sep 22, 2007 (gmt 0)

10+ Year Member



Ok, I found the answer.

I needed to use imagecreatefromstring in order to get the image into php as a resource:

[php.net...]

coopster

2:03 am on Sep 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Glad you got it, mattbyrnes. And welcome to WebmasterWorld!