Page 1 of 1

working with images using GD

Posted: Sat Nov 15, 2008 3:14 am
by iceangel89
i am trying to do something like ... sorry i am not so sure how to explain this...

i have 2 images

$image created using imagecreatefromjpeg and $image_thumb created by imagecreatetruecolor then imagecopyresampled.

what i want to do is something like $image = $image_thumb

but $image becomes an invalid image resource... how do i fix this? i can't do a $image = $image_thumb

Re: working with images using GD

Posted: Sat Nov 15, 2008 3:25 am
by requinix
What are you trying to do? What is it you want to accomplish?

Re: working with images using GD

Posted: Sat Nov 15, 2008 7:48 am
by iceangel89
simply put, i want to set a variable = another image variable

Code: Select all

$image = $image_thumb
why i want to do that is ONLY IF the image is too big, exceeds a certain file size, i want to resize it (to $image_thumb), then set $image = $image_thumb for use for further processing

Code: Select all

if (image too big) {
  //resize image
  imagecopyresampled($image_thumb, $image, 0, 0, 0, 0, $new_w, $new_h, $w, $h); 
  //set $image = $image_thumb ...
  $image = $image_thumb ...
}
//.. because i want to use the $image after the if loop
 
/******** else i can use ...
if (isset($image_thumb)) {
  //use $image_thumb
} else {
  //use $image
}
****** ... but i think this is a bit more code */