fedejp
fedejp

Reputation: 970

How to copy the IPTC data from one image to another?

I'm developing an image processor script to basically resize images. The problem is that when I make the resized copy of the image, it doesn't copy the IPTC data as well. So I've been checking the IPTC PHP functions (iptcparse and iptcembed) but I'm quite confused. Using iptcparse is very simple. It gets all the data into an array and then I print it out with print_r. But the supposedly useful one is iptcembed because it allows you to (as the name says) embed IPTC on your images. Watching the example from php.net I don't quite get it. Do I have to create my array manually in order to embed it on the new image. I guess there's an easy way to just copy one images IPTC's data and embed it into other image.

Any answer will be welcome. Thanks in advance.

Upvotes: 5

Views: 1184

Answers (1)

Philipp
Philipp

Reputation: 15629

I think, this is quite simple. To get the iptc data from the old image, you just have to use the getimagesize and iptcparse functions.

On php.net you found this example to reach 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

Upvotes: 1

Related Questions