Re: [PEL] PelIfd.setThumbnail (PelDataWindow $d) doesn't work!

2006-12-20 Thread Martin Geisler
Pham Hoai Van [EMAIL PROTECTED] writes:


 First, I wanna say thank you to the founders of this very nice open
 source PEL.

Thanks, I appreciate it!

 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();


Just a hint: you can now simply do $jpeg = new PelJpeg(./I1.JPG);
and PEL will load the data from the file.

 $exif = $jpeg-getExif();
 $tiff = $exif-getTiff();
 $ifd0 = $tiff-getIfd();

 $ifd0-setThumbnail(new PelDataWindow($thumb));


Another hint: this is not necessary (it does nothing in this case).
When the $exif object is changed, then $jpeg will see the change as
well since $jpeg has a reference (pointer) to $exif.

 Running above code, I got this exception:

 Fatal error: Uncaught exception 'PelDataWindowOffsetException' with
 message 'Offset -1 not within [0, 14]' in
 Stack trace: #0
 PelDataWindow-validateOffset(-1) #1
 PelDataWindow-getByte(-1) #2
 PelIfd-setThumbnail(Object(PelDataWindow)) #3 {main} thrown in
 D:\Projects\MIP\WIP\Source\MIP-Server\lib\pel\PelDataWindow.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

The thumbnail data is supposed to be JPEG normal data, wrapped in a
PelDataWindow. I assume your create_thumbnail_image() function return
an Image resource like the ImageCreateFromJpeg() function?

If so, then you need to extract the JPEG data from this resource. I've
just committed some code that will let you do what you tried:
construct a PelDataWindow from an image resource. So you can update
From SVN and it should work.

Or you can use this piece of code:

  $window = new PelDataWindow(ob_get_clean());

$window now has your data and you should be able to use it with the
setThumbnail() method.

As a side remark, then why do you want to update the thumbnail? The
Exif standard indicates that the thumbnail should always be 160x120
pixels. You're not even allowed to rotate it which is kind of silly...

Anyway, please let me know if the new code works as expected.

Martin Geisler  ---  [EMAIL PROTECTED]  ---

Read, write, create Exif data in PHP with PEL:
Take control of your webserver with PHP Shell:

Description: PGP signature
Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys - and earn cash
PEL-devel mailing list

Re: pel and php 5.0.3

2006-05-16 Thread Martin Geisler
On 16 maj 2006, [EMAIL PROTECTED] wrote:

Hi Michael

I haven't left yet for my trip to Switzerland, so I can just answer
this one...

 I don't get pel to work with php 5.0.3 - I always get a result file
 of 0kb I tried with 5.1.1 too and and then some duplicate constants
 where found. I removed them and then at least I go an output image.

 Does anyone know about a restriction of 5.0.3?

I believe there has been some trouble with the different 5.x versions
of PHP -- I'm not sure if this is the fault of PEL or what.

But I would recommend that you upgrade to version 5.1 if you have the

Martin Geisler GnuPG Key: 0x7E45DD38

PHP Exif Library  |  PHP Weather |  PHP Shell|  |
Read/write Exif data  |  Show current weather|  A shell in a browser

Description: PGP signature

Re: Pel minimal version

2006-05-11 Thread Martin Geisler
TinyWebGallery [EMAIL PROTECTED] writes:

Hi Michael,

I would appreciate it if you could follow up to the PEL development
list too so that the messages can be archived.  Go to

to subscribe.

 I have a nice webgallery ( and want to
 integrate pel to my application because I want to keep the exif info
 if someone uploads images and select my resize option. Right now the
 exif data is lost.

Good idea -- having a simple resize_and_keep_my_exif_data() function
would be a nice feature (probably with a shorter name, though...)

 Do you have a minimal version where I simply read about 8 tags
 from the exif data and write it to the new file again?

No, there is no such thing right now. But the core of PEL isn't that
big anyway: I just downloaded PEL 0.9 and after removing the doc,
test, po, locale, and examples directories I ended up with 644 KiB of
uncompressed code.  Zipping that up gives me 123 KiB.  Going for bzip2
is even better: just 71 KiB.

I saw your zip download is 1.8 MiB, so is 123 KiB really that much of
a problem?

Since you know which tags you want you could even trim the content of
the files. Simply removing all comments, squizzing multiple blank
lines into one, and removing INSTALL, NEWS, etc. gets the zip file
down to just 41 KiB.

 Its for jpgs only. I want to keep my download as small as possible
 (its too big already :()

I don't know how big a role that plays today, but 1.8 MiB sounds like
a lot of a gallery that calls itself tiny :-)  But I'm sure that it
has lots of features and they come at a price.


Martin Geisler GnuPG Key: 0x7E45DD38

PHP Exif Library  |  PHP Weather |  PHP Shell|  |
Read/write Exif data  |  Show current weather|  A shell in a browser

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
PEL-devel mailing list

Re: PEL library support

2006-03-04 Thread Max

P, I was so tired 
I have forgotten, I have sent the first 

I hope I'm not in your spammer list !!! 

Once again thanks 

and Max

  - Original Message - 
  Sent: Saturday, March 04, 2006 12:51 
  Subject: Fwd: PEL library support
  Another mail from Max :-)- Forwarded message from 
  Date: Fri, 3 Mar 2006 19:28:01 +0100 From: Max [EMAIL PROTECTED]Reply-To: Max [EMAIL PROTECTED]Subject: PEL 
  library support To: [EMAIL PROTECTED]HelloI'm 
  french and i have some problems to show XP tags.I think that XP tags are 
  commonly in the IFD0.I tried this 
  = new 
  = $app1-getTiff();$ifd0 = $tiff-getIfd();echo 
  $ifd0[XP_AUTHOR];but it doesn't work. I explore all the IFDS, but 
  they are never the XP Tags,only classic tags (MODELE, RESOLUTION 
  )I hope you have understood me 
  thxmax- End forwarded message 
  --- Martin Geisler


  I'm french and i have some problems to show XP 
  I think that XP tags are commonly in the 
  I tried this code:
  = new PelJpeg();$jpeg-loadFile($filename);
  $app1=$jpeg-getSection(PelJpegMarker::APP1);$tiff = 
  $ifd0 = $tiff-getIfd();
  echo $ifd0[XP_AUTHOR];
  but it doesn't work. I explore all the IFDS, but 
  they are never the XP Tags, only classic tags (MODELE, RESOLUTION 
  I hope you have understood me