//-------------------------------------------------------------------------------------------------
//create thumbnail img
$img =
imagecreatefromjpeg("./I1.JPG");
$thumb =
create_thumbnail_image($img, 0.1); //create a
thumbnail image with size = 10% of its org
//insert new thumbnail to img
$jpeg = new PelJpeg();
$jpeg->loadFile("./I1.JPG");
$exif = $jpeg->getExif();
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
$ifd0->setThumbnail(new PelDataWindow($thumb));
$jpeg->setExif($exif);
//write to file
file_put_contents("./out.jpg",$jpeg->getBytes());
//-------------------------------------------------------------------------------------------------
Running above
code, I got this exception:
//-------------------------------------------------------------------------------------------------
Fatal error:
Uncaught exception 'PelDataWindowOffsetException' with message 'Offset -1 not
within [0, 14]' in
D:ProjectsMIPWIPSourceMIP-ServerlibpelPelDataWindow.php:243 Stack
trace: #0 D:ProjectsMIPWIPSourceMIP-ServerlibpelPelDataWindow.php(303):
PelDataWindow->validateOffset(-1) #1
D:ProjectsMIPWIPSourceMIP-ServerlibpelPelIfd.php(549):
PelDataWindow->getByte(-1) #2
D:ProjectsMIPWIPSourceMIP-Serverwebthumb.php(17):
PelIfd->setThumbnail(Object(PelDataWindow)) #3 thrown in D:ProjectsMIPWIPSourceMIP-ServerlibpelPelDataWindow.php
on line 243
//-------------------------------------------------------------------------------------------------
This is due to a incorrect $thumb data is set to the PelDataWindow
constructor. What kind of thumbnail data will I need to set to the
PelDataWindow constructor? Any idea will be much appreciated. Thank you.
VanPH