Quantum-Manager / tracker

Tracker for all questions about Quantum Manager.
3 stars 0 forks source link

Add IPTC metadata to thumbnails #29

Open Sulpher opened 4 years ago

Sulpher commented 4 years ago

I am working on a website for German auditory and found there is a law in Germany: the copyright notices from IPTC should be added to all thumbnails.

In German law is, that IPTC info is a part of the image. So if you e.g. use an image from Unsplash and it includes IPTC with copyright, you should add it to all thumbnails you will make - e.g. if you use img tag with different sizes for different screens - all should have the information about copyright

/*
$fileIn ... original image
$fileOut ... destination image (e.g. thumbnail)
*/
$copyright = array();
$info = array();
$data = '';
$size = getimagesize($fileIn, $info);
if(isset($info['APP13'])){
  $iptc = iptcparse($info['APP13']);
  if(isset($iptc['2#116'][0]) && $iptc['2#116'][0] != ''){
    $iptcEmbed = array('2#116' => $iptc['2#116'][0]);
    foreach($iptcEmbed as $tag => $string) {
      $tag = substr($tag, 2);
      // iptc_make_tag Funktion kann man hier finden:
      // https://www.php.net/manual/en/function.iptcembed.php (example 1)
      $data .= iptc_make_tag(2, $tag, $string);
    }
    $content = iptcembed($data, $fileOut);
    // Man kann hier auch Joomla! JFile Methode benutzen
    // test the $data or $content so the file will be not open and overwritten uselessly
    $fw = fopen($fileOut, 'w');
    fwrite($fw, $content);
    fclose($fw);
  }
}

My proposal is to consider additional option somewhere in component options:

Add IPTC to thumbnails - Yes/No. By default is No.

Then, it could be possible to comply to German law.