I'm sketching out an application that would automagically do a photo gallery.
As part of this, I want to examine each graphic in the a given directory, look
for an embedded thumbnail and, if present, output it instead of the image.
Version 2... If there is no embedded thumbnail, create one and save it in the
directory.
I have an image from my Sony camera I'm using to test and it does have an
embedded thumbnail. I'm now trying to extract the image and display it
through imagejpeg.
The code fails with
Warning: imagejpeg(): supplied argument is not a valid Image resource
<?
$iname="DSC0052 7.JPG";
$image = exif_thumbnail( $iname, $width, $height, $type);
$type=exif_imag etype($iname);
echo $type;
if ($image!==false ) {
imagejpeg($imag e);
} else {
// no thumbnail available, handle the error here
echo "No thumbnail available";
}
?>
If I replace the call to imagejpeg with
header("Content-type: " .image_type_to_ mime_type($type ));
echo $image;
I see the thumbnail. $type is 2, which is IMAGETYPE_JPEG.
Is the image resource returned from exif_thumbnail different from the resource
expected by imagejpeg?
What has gone over my head?
Thanks.
As part of this, I want to examine each graphic in the a given directory, look
for an embedded thumbnail and, if present, output it instead of the image.
Version 2... If there is no embedded thumbnail, create one and save it in the
directory.
I have an image from my Sony camera I'm using to test and it does have an
embedded thumbnail. I'm now trying to extract the image and display it
through imagejpeg.
The code fails with
Warning: imagejpeg(): supplied argument is not a valid Image resource
<?
$iname="DSC0052 7.JPG";
$image = exif_thumbnail( $iname, $width, $height, $type);
$type=exif_imag etype($iname);
echo $type;
if ($image!==false ) {
imagejpeg($imag e);
} else {
// no thumbnail available, handle the error here
echo "No thumbnail available";
}
?>
If I replace the call to imagejpeg with
header("Content-type: " .image_type_to_ mime_type($type ));
echo $image;
I see the thumbnail. $type is 2, which is IMAGETYPE_JPEG.
Is the image resource returned from exif_thumbnail different from the resource
expected by imagejpeg?
What has gone over my head?
Thanks.
Comment