Get PrintConv value by providing TagId and ValueConv value

Started by cyber77, April 22, 2013, 11:30:48 AM

Previous topic - Next topic

cyber77

Hi,

I am new to the Exiftool and this forum. First of all, I'd like to congratulate the developers to this very nice tool & framework. I am using Image::Exiftool within my own Perl application, that extracts metadata from various mediafiles and stores them in a relational database.

I would like to store the ValueConv values and not the PrintConv values to have a more consistent view on the meta-information and being able to do things like language translations afterwards. Having the ValueConf values stored leads me to the question, if it is possible to translate them into PrintConv values later on, without having the original mediafile available.

Something like:


$exif->Image::Exiftool->new();
my $PrintConvValue = $exif->PrintConv($tagid,$value);


Is that or something similar possible? As a workaround I could create a XML-file and provide the required datastructures by myself. But that is ugly, since I have an instance of Image::ExifTool loaded anyway into my namespace.

Thanks in advance for your help!

Phil Harvey

Interesting idea, but no, it's not possible to convert the ValueConv values afterward.  In the general case this is not possible, because often the conversion depends on other things (such as the camera Model for example).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

cyber77

Thanks for your quick answer. I've solved the problem in a creative way. I am generating a XML-File using Image::ExifTool::TagInfoXML, read it into a Perl data structure and store it in Storable format. The stored data structure will be loaded every time my Perl application starts. Storable is much faster than reading in XML files. For the 6.5 MB file it just needs some miliseconds.

I've attached a little script, which does the exporting. Maybe it is useful for somebody else that comes across the same problem.

Here's how, you can read the data structure back into the memory:


#!/usr/bin/perl
use Storable;
use Data::Dumper;

my $ref = retrieve('ExifTool.Tables.ds');

print Dumper ($ref);


Just an addtitional note: I am using the method $exif->GetTableName($tag) in order to receive the correct table during the data extraction for each tag. The table name will be stored, together with the tagname in the database.