List Info

Thread: PelIfd.setThumbnail (PelDataWindow $d) doesn't work!




PelIfd.setThumbnail (PelDataWindow $d) doesn't work!
user name
2006-12-20 03:21:33

Hi all,

 

First, I wanna say thank you to the founders of this very nice open source PEL. Second, I have a problem regarding setThumbnail img and need your helps. Here is my code:

//-------------------------------------------------------------------------------------------------

//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

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )