How to copy IPTC data from one image to another?

I am developing an image processor script for resizing images. The problem is that when I make a modified copy of the image, it does not copy the IPTC data. So I tested the PHP IPTC functions (iptcparse and iptcembed), but I'm pretty confused. Using iptcparse is very simple. It gets all the data into an array, and then prints it with print_r. But supposedly useful is iptcembed, because it allows you (as the name says) to embed IPTC in your images. Watching an example from php.net, I do not quite understand. Do I have to create my array manually in order to insert it on a new image. I assume there is an easy way to just copy one image of the IPTC data and paste it into another image.

Any answer would be welcome. Thanks in advance.

+5
source share
1 answer

I think it's pretty simple. To get iptc data from an old image, you just need to use the getimagesize and iptcparse functions.

On php.net you found this example for this

<?php
$size = getimagesize('./test.jpg', $info);
if(isset($info['APP13']))
{
    $iptc = iptcparse($info['APP13']);
    var_dump($iptc);
}
?> 

Combine this sample with the iptcembed method and you have everything you need

+1
source

All Articles