Martin Geisler wrote:
> dave <[EMAIL PROTECTED]> writes:
>
>   
>> dave wrote:
>>     
>>> hello
>>>
>>> i'm working on a photo gallery for my site which uses gd to resize
>>> pictures, this strips the exif metadata from the image file
>>>
>>> my plan was to grab the exif data first (this was ok), then add it
>>> back to the resized image (this was not ok)
>>>
>>> [...]
>>>       
>>   
>> oops, can't believe i didn't see this earlier
>> just get the exif data of the old file, load a new peljpeg with the
>> new file and use insertSection to add the APP1 section to the new
>> jpeg
>>
>> easy :D
>>     
>
> Well, it is meant to be easy :-)
>
> Please, if you get a piece of working code for this, then I would love
> to include it as an example in the PEL distribution. Both as a
> commandline and as a webserver script. I'm sure a lot of people would
> appreciate it!
>
> Also, you might want to take a look at the code in SVN if you haven't
> already. I've recently added a getExif() and a setExif() method to
> PelJpeg. The setExif() method is the non-trivial one: it will insert
> the PelExif object at the correct position amoung the other sections.
>
>   http://tinyurl.com/ve6nu
>
>   
well, it's a part of a larger base of code that i am working on, but 
basically, this is all i did
// create the new PelJpeg object
// load the local path of the jpeg to the object, this all happens after 
the file has been uploaded and moved to a permanent location
            $origJpeg = new PelJpeg();
            $origJpeg->loadFile($fullFilePath);

// get the APP1 marker out, which will prolly contain the exif data
            $exif = $origJpeg->getSection(PelJpegMarker::APP1);

// now process the image, $imageResource is a php image resource, the 
image has been manipulated, eg. resized, watermarked, etc.
            imagejpeg($imageResource, $fullFilePath, $maxQuality);

// if the original file contains exif data, we want to add that data to 
the newly modified image
            if (!is_null($exif)) {
// the newly created image will probably have the exif data stripped by 
gd, so we add the exif taken from the original file into the new image
                $newJpeg = new PelJpeg();
                $newJpeg->loadFile($fullFilePath);

                $newJpeg->insertSection(PelJpegMarker::APP1, $exif, 1);
// and then save the file again
                file_put_contents($fullFilePath, $newJpeg->getBytes());
            }

i think the getExif and setExif methods should make that code even 
simpler, i only grabbed some updated code for PelEntryAscii from SVN, 
but i'll have a look for some more stuff now

haven't really looked at modifying the exif data fields yet, but i'll be 
having a play with that later as well

dave
>   
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> PEL-devel mailing list
> PEL-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pel-devel
>   


-- 
http://dtracorp.com

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PEL-devel mailing list
PEL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pel-devel

Reply via email to