working with images using GD

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iceangel89
Forum Commoner
Posts: 39
Joined: Mon Jul 02, 2007 7:02 pm

working with images using GD

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: working with images using GD

Post by requinix »

What are you trying to do? What is it you want to accomplish?
iceangel89
Forum Commoner
Posts: 39
Joined: Mon Jul 02, 2007 7:02 pm

Re: working with images using GD

Post 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 */
Post Reply