tags:

views:

57

answers:

2
     if ($img = @imagecreatefromjpeg('./images/upload/13/1.JPG')) {

         imagejpeg($img, $path, 100);
            imagedestroy($img);

     } else {

         die ("image was not created or saved");

     }

I'm getting the message:

Warning: imagejpeg(): 8 is not a valid Image resource in C:\xampp\htdocs\invivid\libraries\photograph_classes.php on line 276

Warning: imagedestroy(): 8 is not a valid Image resource in C:\xampp\htdocs\invivid\libraries\photograph_classes.php on line 277

The image is being created initially, we know this from the if statement, but why doesn't imagejpeg or imagedestroy work properly?

Solution: Ok, I think it had something to do with an incorrect $path variable, it seems to be working fine now.

A: 
ChristopheD
even IF the function is case-sensitive (which indeed is mentioned in the **comments**), Whats the difference between a .jpg and a .JPG file?!?
Bob Fanger
@Bob Fanger: yes, that's why I added the 'particulary implausible' part ;-)
ChristopheD
A: 

I´ve never used it like that (without creating a new image, doing some manipulation, etc.), but it seems the manual is a bit vague: imagecreatefromjpeg returns an image resource identifier and imagejpeg needs an image resource, returned by one of the image creation functions. It certainly looks the same, but perhaps they are not.

jeroen
imagecreatefromjpeg() **reads** jpeg file into memory (as a gdimage resource) and imagejpeg() **writes** a jpeg binairy (from a gdimage)
Bob Fanger
That´s what I thought, although the manual isn´t that clear (image resource vs image resource identifier). Don't see anything else that´s wrong though...
jeroen
selecting this as an answer to get this post out of the way
ThinkingInBits