Recent Posts

Pages: [1] 2 3 ... 10
1
Developers / Re: Windows filesystem sync issues?
« Last post by ribtoks on Today at 05:31:17 AM »
I have resolved my problem with using -stay_open and writing arguments to stdin instead of argfile.
UTF-8 filepaths work correctly in Windows now with no lags or unexpected things.
2
Newbies / -stay_open input formatting
« Last post by ribtoks on Today at 05:15:33 AM »
Hello

I have a bunch of newbie questions regarding the format of the arguments when using glorious Exiftool with -stay_open magic and writing actual arguments to stdin.

So the use-case:
Set XMP, IPTC, EXIF description, title and keywords (in UTF-8) for 2 images (lets say file1.jpg and file2.jpg)

My current assumption (simplified):

Starting Exiftool with:
Code: [Select]
exiftool.exe -stay_open True -@ -
Data written to stdin separated by "\n":
Code: [Select]
-charset
FileName=UTF8
-XMP:Title=XXXXX
-IPTC:ObjectName=YYYYYYY
-EXIF:ImageDescription=ZZZZZZZ
/path/to/file1.jpg
-XMP:Title=XXXXX
-IPTC:ObjectName=YYYYYYY
-EXIF:ImageDescription=ZZZZZZZ
-XMP:Subject="Keyword1", "Keyword2", "Keyword3"
/path/to/file2.jpg
-stay_open
False

My actual questions:

1. Can it be done for several files as I wrote? Like iteratively options for each file (ending with path to that file).
2. Is that correct format in the assumption? Or maybe do I need to split -XMP:Title and XXXXX to separate lines?
3. How to write XXXXX, YYYYYY and ZZZZZZ if they are UTF-8 strings with spaces and, possibly, newlines?
4. How to write keywods? A keyword is a UTF-8 string with spaces. Do I need to put them into 1 line or to put each one to the separate line or what?

Sorry for a lot of questions and thanks in advance!
3
The "exiftool" Application / Re: Detecting if an EXE file is x86 or x64
« Last post by DavidGDFC on August 22, 2017, 06:54:15 PM »
Thanks anyway, Phil. :-)
4
Developers / Re: How To Output JSON using Image::ExifTool Library Module
« Last post by kennycarruthers on August 22, 2017, 03:45:05 PM »
Thanks for the quick reply Phil, much appreciated.

The snippet is working and I have a (very) rough test app running that is using perlembed. I'm far from having a proper implementation given my complete lack of Perl knowledge, but what I do have working is parsing images in roughly half the time compared to invoking exiftool from the command line using the -@ argument to give it an input file containing all file paths.

I'm curious to see how hard it is to get perlembed running separate interpreters within multiple threads because that would help a lot since this is pretty much CPU bound rather than IO bound when run on an SSD.
5
My application uses ExifTool to write XMP data to PDF files. This usually works just great.
However, for PDF files created with the Microsoft "Print to PDF" print driver which is part of Windows 10, I get one or more errors/warnings from ExifTool:


Info object (17 0 obj) not found at 48889 - <File Name>
Root object (1 0 obj) not found at 4...


Since it's only the PDF produced by the MS Print Driver I assume that this is a problem in the Microsoft software.

I have prepared a one page example PDF which exhibits the problem. The ARGS I use are:

Code: [Select]
-overwrite_original_in_place
-charset
FILENAME=UTF8
-m
-ex
-sep

-XMP-xmp:Rating=4
-xmp:DocumentID=xmp.did:572f3069-dd75-44d1-b4aa-199fc644d9a3
-xmp:OriginalDocumentID=xmp.did:572f3069-dd75-44d1-b4aa-199fc644d9a3
-xmp:InstanceID=xmp.iid:21dd4775-5fc0-4cde-9783-65034e14f466
-XMP:MetadataDate=now
-XMP:ModifyDate=now
6
Developers / Re: How To Output JSON using Image::ExifTool Library Module
« Last post by Phil Harvey on August 22, 2017, 01:07:37 PM »
The JSON output option and most other text output formats are features of the application, not the library.  The coding of this is very simple, all except for the routine to quote the values if necessary.  I attach a routine for you to use.  This routine uses some non-public functions of Image::ExifTool::XMP, but these functions aren't likely to change in future versions.

Code: [Select]
#!/usr/bin/perl -w

use Image::ExifTool;
use Image::ExifTool::XMP;

# lookup for JSON characters that we escape specially
my %jsonChar = ( '"'=>'"', '\\'=>'\\', "\t"=>'t', "\n"=>'n', "\r"=>'r' );

#------------------------------------------------------------------------------
# Escape string for JSON
# Inputs: 0) string, 1) flag to force numbers to be quoted too
# Returns: Escaped string (quoted if necessary)
sub EscapeJSON($;$)
{
    my ($str, $quote) = @_;
    unless ($quote) {
        # JSON boolean (true or false)
        return lc($str) if $str =~ /^(true|false)$/i;
        # JSON/PHP number (see json.org for numerical format)
        # return $str if $str =~ /^-?(\d|[1-9]\d+)(\.\d+)?(e[-+]?\d+)?$/i;
        # (these big numbers caused problems for some JSON parsers, so be more conservative)
        return $str if $str =~ /^-?(\d|[1-9]\d{1,14})(\.\d{1,16})?(e[-+]?\d{1,3})?$/i;
    }
    # encode JSON string as Base64 if necessary
    if (Image::ExifTool::XMP::IsUTF8(\$str) < 0) {
        return '"base64:' . Image::ExifTool::XMP::EncodeBase64($str, 1) . '"';
    }
    # escape special characters
    $str =~ s/(["\t\n\r\\])/\\$jsonChar{$1}/sg;
    # escape other control characters with \u
    $str =~ s/([\0-\x1f])/sprintf("\\u%.4X",ord $1)/sge;
    # JSON strings must be valid UTF8
    Image::ExifTool::XMP::FixUTF8(\$str);
    return '"' . $str . '"';    # return the quoted string
}


- Phil
7
Developers / How To Output JSON using Image::ExifTool Library Module
« Last post by kennycarruthers on August 22, 2017, 12:37:47 PM »
I'm trying to using the Image::ExifTool Library Module within a Perl script but can't figure out how to get it to generated JSON data. The "Options" field doesn't seem to have any support for the output format in the way that the command line does.

Library Documentation I'm referencing:
http://owl.phy.queensu.ca/~phil/exiftool/ExifTool.html

In the opening example, a hash containing the tag/value pairs is created. But I'd rather a string be created that is similar (or ideally identical) to the JSON that would be treated if you called ExifTool from the command line like so:

exiftool -G -j my_image.jpg

Is that possible?

The reason for this is that I'm doing some preliminary investigation of using PerlEmbed in a C++ program to call through to ExifTool so that I can compare the performance differences between that versus spawning multiple processes and piping back-and-forth to it.

http://perldoc.perl.org/perlembed.html

In the PerlEmbed documentation, they have a very straight forward example of how to call a Perl script that sets a variable to a string, and then the extract that string back into a C-string. So if I can get JSON created above and stored into a Perl String, then should be able to get it into a C-string pretty easily and then do whatever I want with it in my native code. At least that's the theory...
8
Apparently this problem also affects the 6D Mark II

- Phil
9
Newbies / Re: Help print full path in the output
« Last post by StarGeek on August 21, 2017, 11:27:42 PM »
You could add -api "Filter=s/\//\\/g" to your command, but that will replace every slash in the all the output with backslashes.

Using the -p option, you could use -p "${filepath;s/\//\\/g}".
10
The "exiftool" Application / Re: Problems extracting cover-images
« Last post by jaybrahms on August 21, 2017, 04:58:14 PM »
I should have thought about that...
Thank you very much, that really helped...

 :)
Pages: [1] 2 3 ... 10