Hi Phil,
Thanks for this piece of work that I am new with and trying to learn to work with.
I am trying to to extract Image data from an ITC file with the following command :
exiftool -b -itc:ImageData art.itc > art.png (this works great)
but I would like to do the same but to save the output to a file with the extension corresponding to : exiftool -itc:ImageType art.itc
The reason for this is that in my recollection the embedded data in ITC can also be a jpg file.
I'd like to combine both with something like this (doesn't work):
exiftool -b -itc:ImageData art.itc > art.${-itc:ImageType art.itc}
What am I missing? how is it suppose to be passed to the shell?
Thanks for your help
The way to do this is to run 2 commands:
exiftool -ext itc -if '$imageType eq "PNG"' -itc:imagedata -b -w png DIR
exiftool -ext itc -if '$imageType eq "JPEG"' -itc:imagedata -b -w jpg DIR
where DIR is the name of a directory containing the ITC files.
Note: the quoting above is for Mac/Linux. Interchange the single and double quotes if you are running on Windows.
- Phil
Edit: Using some of the more advanced features allows this to be done in a single command...
exiftool -if '$imageType eq "PNG"' -w png -execute -if '$imageType eq "JPEG"' -w jpg -common_args -ext itc -itc:imagedata -b DIR
Edit2: Hmmm. I just tried this to be sure I got the command right, and noticed a funny quirk that keeps this from working. I will look into fixing this, but until then, do this:
exiftool -ext itc -if '$imageType =~ /PNG/' -itc:imagedata -b -w png DIR
exiftool -ext itc -if '$imageType !~ /PNG/' -itc:imagedata -b -w jpg DIR
or
exiftool -if '$imageType =~ /PNG/' -w png -execute -if '$imageType !~ /PNG/' -w jpg -common_args -ext itc -itc:imagedata -b DIR
(the problem is that for some reason the print conversion isn't getting applied to $imageType, so I changed the test to work on the unconverted value)
Edit3: It turns out that the print conversion is being disabled by -b (which makes sense), but this also applies to tags in the -if condition (which we don't want here). I'm still working on a solution...
Thanks a lot for your fast reply ;D
I tried the second edit options and they work like a charm.
Is there a way to get the value from a tag by its "identifier" because it seems to me that the output of -itc:imagetype (or any other tag) is a string containing : "Image Type : PNG" instead of a value like 'PNG' (this is at least the output when implemented in an applescript)
I have some last silly questions:
what does the $ in $imageType represents? is it linked to -itc:imageType? how could exiftool link both of them as -itc:ImageType has not been defined in command?
Thanks again for your help. I will use your method for now :)
G.
Quote from: Georges75 on November 09, 2011, 08:11:56 AM
Is there a way to get the value from a tag by its "identifier" because it seems to me that the output of -itc:imagetype (or any other tag) is a string containing : "Image Type : PNG" instead of a value like 'PNG' (this is at least the output when implemented in an applescript)
Yes. There are a multitude of output formats. The
-b option returns only the value of the tag, and doesn't include the tag description. But I'm not sure exactly what you are looking for. Also see the
-s option (use
-s -S to drop the description and tag name from the output when not using
-b).
QuoteI have some last silly questions:
what does the $ in $imageType represents? is it linked to -itc:imageType? how could exiftool link both of them as -itc:ImageType has not been defined in command?
I could have used
$itc:imagetype in the
-if condition with the same result (since there aren't any other ImageType tags in the file). The
$ is just a prefix to introduce a tag name in the expression. See the -if option documentation (https://exiftool.org/exiftool_pod.html#item__2dif_expr) for details.
- Phil
Great thanks for your help, you answered my questions.
I will keep digging into the different command options.
Glad to clear things up.
Regarding the unexpected behaviour with the -b option, I will add this note to the -if documentation:
Note that the -n and -b options also apply to tags used in EXPR.
Also, for this tag (ITC ImageType), I think it is best if I change the decoding to convert the value earlier, rather than using the current lookup table. If I do this, then the original commands I suggested will work. This will be implemented in the next release (version 8.70).
- Phil
ExifTool 9.23 adds a new -W (upper case) option that provides this functionality.
exiftool -a -b -itc:imagedata -W %d%f-%t%c.%s DIR
This writes ITC:ImageData to a file with the same name as the original but with the tag name added (and an index, in case there are more than one ImageData tags, which is why I added the -a option, even though I don't know if it is possible to have multiple ImageData tags). The "%s" gives the file an extension appropriate to the data type (".png", ".jpg", etc). You can extract multiple embedded images with this single command.
- Phil