Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: IPTC display hack (+ simple Google Earth link)  (Read 12325 times)

0 Members and 1 Guest are viewing this topic.

FlemishDreams

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 7
    • Stock Photography Addict
IPTC display hack (+ simple Google Earth link)
« on: April 02, 2006, 08:47:58 pm »

The IPTC meta info display under "file info" in displayimage.php in CPG 1.44 is rather rigid. Photogs that rely a lot on IPTC for tagging might want to change that display. Now what we really need is a iptcmgr.php like the exifmgr.php and I plan to write one soon (unless somebody else is doing it now, PM me).
In the mean time there is a very simple hack to modify IPTC display anybody can do.

The hack is in displayimage.php in the root CPG folder. The file header reads like:
Code: [Select]
  Coppermine version: 1.4.4
  $Source: /cvsroot/coppermine/stable/displayimage.php,v $
  $Revision: 1.23 $
  $Author: gaugau $
  $Date: 2006/02/24 13:30:07 $

IPTC display is done on lines 163-167. It looks like this:
Code: [Select]
        if (isset($iptc['Title'])) $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        if (isset($iptc['Copyright'])) $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        if (!empty($iptc['Keywords'])) $info[$lang_picinfo['iptcKeywords']] = implode(' ',$iptc['Keywords']);
        if (isset($iptc['Category'])) $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        if (!empty($iptc['SubCategories'])) $info[$lang_picinfo['iptcSubCategories']] = implode(' ',$iptc['SubCategories']);

As an example, here is my own hack for those lines, but it really depends on what your needs are for IPTC display. For instance, I use the "credits" tag to indicate wheter a model (person) is model-released or not. I use the "TransmissionReference" tag to put the Google Earth coords in (I'm not rich enough to buy a GPS-enabled cam  ::)). I also added the city, state and country info since many of my pics are travel pics.
Code (1) (see lower)
Code: [Select]
// my additions begin - IPTC display
        if (!empty($iptc['Title'])) $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        if (!empty($iptc['Copyright'])) $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
if (!empty($iptc['Category'])) $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        if (!empty($iptc['SubCategories'])) $info[$lang_picinfo['iptcSubCategories']] = implode(' ',$iptc['SubCategories']);
        if (!empty($iptc['Credit'])) $info[$lang_picinfo['iptcReleased']] = $iptc['Credit'];
        if (!empty($iptc['City'])) $info[$lang_picinfo['iptcCity']] = $iptc['City'];
        if (!empty($iptc['State'])) $info[$lang_picinfo['iptcState']] = $iptc['State'];
        if (!empty($iptc['Country'])) $info[$lang_picinfo['iptcCountry']] = $iptc['Country'];
        if (!empty($iptc['TransmissionReference'])) $info[$lang_picinfo['iptcTransmission']] = $iptc['TransmissionReference'];
        if (!empty($iptc['Keywords'])) $info[$lang_picinfo['iptcKeywords']] = implode(' ',$iptc['Keywords']);
// my additions end - IPTC display

Of course you will need to provide the texts for the extra tags in the language files. You can find those in the CPG subfolder /lang. I only did the english.php file. The file header reads like this:
Code: [Select]
  Coppermine version: 1.4.4
  $Source: /cvsroot/coppermine/stable/lang/english.php,v $
  $Revision: 1.25 $
  $Author: gaugau $
  $Date: 2006/02/18 10:10:12 $

On lines 964-968 you will find:
Code: [Select]
  'iptcTitle'=>'IPTC Title',
  'iptcCopyright'=>'IPTC Copyright',
  'iptcKeywords'=>'IPTC Keywords',
  'iptcCategory'=>'IPTC Category',
  'iptcSubCategories'=>'IPTC Sub Categories',

and here is my hack for these lines:
Code: [Select]
  'iptcTitle'=>'Title', // IPTC my modifications
  'iptcCopyright'=>'Copyright', // IPTC my modifications
  'iptcCity'=>'Place', // IPTC my additions
  'iptcState'=>'Area', // IPTC my additions
  'iptcCountry'=>'Country', // IPTC my additions
  'iptcReleased'=>'Released', // IPTC my additions
  'iptcTransmission'=>'Position', // IPTC my additions
  'iptcKeywords'=>'Keywords', // IPTC my modifications
  'iptcCategory'=>'Category', // IPTC my modifications
  'iptcSubCategories'=>'Other(s)', // IPTC my modifications


Note on IPTC tagging - this is really the standard on Stock sites, and IPTC is a very undervalued tool to meta your pictures. There is a great free tool around to do it: Irfanview http://www.irfanview.com/. You can do it in batch mode, - over selected pictures in a folder, - over an entire folder.

Open any image in a folder, then hit 'T' for thumbnails. You get the thumbnails screen. Here select the picture(s) you want to tag (shift click) (or CTRL-A) for all. Then go to the menu "file|JPG Lossless Operations|Set IPTC data to selected thumbs". You can enter your IPTC tags there.

You don't need to do them all at once. The fields that you leave empty can be filled in later, or can even stay untouched. The last tag in the IPTC mod box reads "options" and you can determine there what will happen to the fields you left empty.
For instance, in a first batch right after I transfered my pics from cam to a folder, I tag "date,city,province,country". Later I can apply titles, keywords and categories to selected pictures in that folder that share the same info, all in one run.

You can even determine what CPG gallery your pictures will be going in. Just add one unique IPTC keyword and you can make a linked gallery later, based on that particular keyword.



The simple Google Earth hack now. If you want a real good mod, check here: http://forum.coppermine-gallery.net/index.php?topic=26939

My hack (hereunder) assumes you have put the Google Earth coords of your pic in the IPTC TransmissionReference field, (latitude,longitude). The previous hack will just show these coords as numbers, and that's it. Now if your client installed Google Earth, instead of showing the coords themselves, displayimage.php will show a button. If your client clicks on that button, his Google Earth application will start up and show him the location of the pic. To implement this, you will need to replace the previous code (1) then by the next one:
Code: [Select]
// my additions begin - IPTC display with Google Earth button
        /*if (isset($iptc['Title'])) $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        if (isset($iptc['Copyright'])) $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
        if (!empty($iptc['Keywords'])) $info[$lang_picinfo['iptcKeywords']] = implode(' ',$iptc['Keywords']);
        if (isset($iptc['Category'])) $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        if (!empty($iptc['SubCategories'])) $info[$lang_picinfo['iptcSubCategories']] = implode(' ',$iptc['SubCategories']);*/
        if (!empty($iptc['Title'])) $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
        //if (!empty($iptc['Copyright'])) $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
if (!empty($iptc['Category'])) $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
        if (!empty($iptc['SubCategories'])) $info[$lang_picinfo['iptcSubCategories']] = implode(' ',$iptc['SubCategories']);
        if (!empty($iptc['Credit'])) $info[$lang_picinfo['iptcReleased']] = $iptc['Credit'];
        if (!empty($iptc['City'])) $info[$lang_picinfo['iptcCity']] = $iptc['City'];
        if (!empty($iptc['State'])) $info[$lang_picinfo['iptcState']] = $iptc['State'];
        if (!empty($iptc['Country'])) $info[$lang_picinfo['iptcCountry']] = $iptc['Country'];
       // if you just want the coord numbers:
       //if (!empty($iptc['TransmissionReference'])) $info[$lang_picinfo['iptcTransmission']] = $iptc['TransmissionReference'];
       // if you also want the Google Earth button:
if (!empty($iptc['TransmissionReference'])) {
$GEOMAP_INFO = array();
$pos_array = explode(",",$iptc['TransmissionReference']);
$GEOMAP_INFO['latitude'] = $pos_array[0];
$GEOMAP_INFO['longitude'] = $pos_array[1];
$GEOMAP_INFO['name'] = $iptc['Title'];
$place = (empty($iptc['City'])) ? "" : $iptc['City'].", ";
$place .= (empty($iptc['State'])) ? "" : $iptc['State'].", ";
$place .= (empty($iptc['Country'])) ? "" : $iptc['Country'];
$GEOMAP_INFO['description'] = ($place) ? $place : "Google Earth";
$GEOMAP_INFO['range'] = "15000"; // vertical view diestance from surface
$GEOMAP_INFO['tilt'] = "";
$GEOMAP_INFO['heading'] = "0";
$info[$lang_picinfo['iptcTransmission']] = <<<EOT
<form method="post" action="geomaps.php">
<input type="hidden" name="name" value="{$GEOMAP_INFO['name']}" />
<input type="hidden" name="description" value="{$GEOMAP_INFO['description']}" />
<input type="hidden" name="range" value="{$GEOMAP_INFO['range']}" />
<input type="hidden" name="tilt" value="{$GEOMAP_INFO['tilt']}" />
<input type="hidden" name="heading" value="{$GEOMAP_INFO['heading']}" />
<input type="hidden" name="latitude" value="{$GEOMAP_INFO['latitude']}" />
<input type="hidden" name="longitude" value="{$GEOMAP_INFO['longitude']}" />
<input type="submit" name="show" value="Google Earth" class="button" />
</form>
EOT;
}
        if (!empty($iptc['Keywords'])) $info[$lang_picinfo['iptcKeywords']] = implode(' ',$iptc['Keywords']);
// my additions end - IPTC display with Google Earth button

And you need to make a file geomaps.php under the root CPG folder with this content:
Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4
  $Author: Flemisdreams $
  $Date: 2006/04/22 $
**********************************************/
// add next 2 lines on the .htaccess file in your root CPG folder (or make such a file if it isn't there yet):
// AddType text/vnd.google-earth.kml+xml kml
//  AddType text/vnd.google-earth.kmz kmz
//
// This is a *very* simple hack, for real GoogleEarth and GoogleMaps integration look here:
// TranzNDance: http://forum.coppermine-gallery.net/index.php?topic=26571.0
// Refs:
// http://www.keyhole.com/kml/kml_tut.html
// http://kml.tjworld.net/#reference (great!)

function get_post_var($name$default '') {
    return isset(
$_POST[$name]) ? $_POST[$name] : $default;
}

$GEOMAP_INFO = array();
$GEOMAP_INFO['name'] get_post_var('name');
$GEOMAP_INFO['description'] get_post_var('description');
$GEOMAP_INFO['longitude'] get_post_var('longitude');
$GEOMAP_INFO['latitude'] get_post_var('latitude');
$GEOMAP_INFO['range'] get_post_var('range');
$GEOMAP_INFO['tilt'] get_post_var('tilt');
$GEOMAP_INFO['heading'] get_post_var('heading');

header("Pragma: public"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/vnd.google-earth.kml+xml kml"); // it really depends on your server config
header("Content-Disposition: attachment; filename=\"GoogleEarth.kml\""); // IE needs this
echo <<<EOT
<kml xmlns="http://www.google.com/earth/kml/2.0">
<Document>
<Style id="khStyle556">
<IconStyle id="khIconStyle557">
<Icon><href>root://icons/palette-4.png</href><x>160</x><y>128</y><w>32</w><h>32</h></Icon>
</IconStyle>
</Style>
<Placemark>
<name>
{$GEOMAP_INFO['name']}</name>
<description>
{$GEOMAP_INFO['description']}</description>
<LookAt>
<longitude>
{$GEOMAP_INFO['longitude']}</longitude>
<latitude>
{$GEOMAP_INFO['latitude']}</latitude>
<range>
{$GEOMAP_INFO['range']}</range>
<tilt>
{$GEOMAP_INFO['tilt']}</tilt>
<heading>
{$GEOMAP_INFO['heading']}</heading>
</LookAt>
<styleUrl>#khStyle556</styleUrl>
<Point>
<coordinates>
{$GEOMAP_INFO['longitude']},{$GEOMAP_INFO['latitude']},0</coordinates>
<altitudeMode>relativeToGround</altitudeMode>
<extrude>0</extrude>
</Point>
</Placemark>
</Document>
</kml>
EOT;
?>




You can check these small hacks on my CPG test site here (did you install Google Earth?):
http://www.flemishdreams.com/cpg/displayimage.php?album=random&cat=0&pos=-52
Caveat: this is a test site, it might not work.

Note: the KML XML file generated by geomaps.php works fine under Firefox and Netscape 7.2, and IE. In the original post, it didn't work under IE but I added the "filename" with extension KML and now (April 6, 2006) it works under IE too. The code on top has been modified accordingly.
« Last Edit: May 04, 2006, 11:17:01 pm by GauGau »
Logged

smcasey

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: IPTC display hack (+ simple Google Earth link)
« Reply #1 on: May 06, 2006, 08:46:14 am »

Hi FlemishDreams,
Great mod!  I was wondering if you have tried reading EXIF tags with GPS coordinates and then mapping them?

I have setup a gallery using TranzDance's mod for Google Maps (http://forum.coppermine-gallery.net/index.php?topic=26571.0) and would like to change the mod to read the EXIF GPS info and then create the Google Map.  I'm using 1.4.5 of coppermine.

Do you think this is viable to do with your mod?  :)
Logged

fotomad

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: IPTC display hack (+ simple Google Earth link)
« Reply #2 on: May 30, 2006, 05:50:56 pm »

if you want the line to stay open even if the iptc field is blank just

for example change :

if (!empty($iptc['State'])) $info[$lang_picinfo['iptcState']] = $iptc['State'];

to

if (isset($iptc['State'])) $info[$lang_picinfo['iptcState']] = $iptc['State'];




hope that helps anyone
Logged

sykocus

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 6
  • iidesune
    • http://www.jgarrido.net
Re: IPTC display hack (+ simple Google Earth link)
« Reply #3 on: June 11, 2006, 09:48:13 am »

Hi FlemishDreams,
Great mod!  I was wondering if you have tried reading EXIF tags with GPS coordinates and then mapping them?

I have setup a gallery using TranzDance's mod for Google Maps (http://forum.coppermine-gallery.net/index.php?topic=26571.0) and would like to change the mod to read the EXIF GPS info and then create the Google Map.  I'm using 1.4.5 of coppermine.

Do you think this is viable to do with your mod?  :)

I'd be interested in this too. As the software I have encodes the lat/long info from my gps tracks into the EXIF, but not the IPTC.
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.