1. Reminder: Please use our affiliate links for holiday shopping!

[SOLVED] Exiftool to update ImageDescription for new images

Discussion in 'Image Processing' started by agnieszka, May 13, 2015.

  1. agnieszka

    agnieszka Mu-43 Regular

    71
    May 1, 2015
    Central Coast, NSW Australia
    Agnieszka
    Hi,

    Brand new to exiftool command line, but not afraid! Been scripting in batch for a couple of years, so not completely foreign to the idea.

    What i want in the end is to remove any image description tags that say "OLYMPUS DIGITAL CAMERA".

    I've been following this excellent tutorial (http://carlibrary.org/ExifTool.htm) and modifying it form my own purposes. While exporting tags to csv, fiddling with the data, then reimporting the tags will work (and is an excellent way to review all tags easily), i am looking to make it a little more automated. i've been trying to adjust what i've learned from (http://ninedegreesbelow.com/photography/exiftool-commands.html) but that tute basically deals with copy/move methods, but i do like how the blogger explains each bit. i'm having trouble finding examples of how to use an IF THEN (ELSE) clause in exiftool speak.

    What i want to script is something that does two things. First, to remove the value in the tag if the value meets criteria:
    IF [ImageDescription]="OLYPMUS DIGITAL CAMERA" THEN [ImageDescription]=""

    perhaps something like (e for equals?):
    exiftool -r -if '$ImageDescription e "OLYMPUS DIGITAL CAMERA"' -ImageDescription="" -overwrite_original

    can i have multiple ifs in one line (to cover all the description tags, whether EXIF, IPTC, etc), or is it just one command per line? no problems either way, it's all going into a windows batch file anyhow.

    The second thing i want to do, is restrict the operation to work only if the creation date is greater than whatever date i choose to put in there. this is that that the script doesn't have to bother with all the files, just whatever new ones i have since my selected date. though i guess this is a bit of a moot idea because the script will iterate through all the files anyway to determine the date, so i guess i just wanted to know if this was worth scripting in at all.

    that said, i do have a txt log file of my file transfers (i keep a .bat on every SD, and use xcopy to only copy new files. those that are copied are logged into the txt, the list of files in the log are then part of the 'exclude' clause of the xcopy for next time) - perhaps i can utilise this log somehow to iterate exiftool command through only those files.
     
  2. agnieszka

    agnieszka Mu-43 Regular

    71
    May 1, 2015
    Central Coast, NSW Australia
    Agnieszka
  3. agnieszka

    agnieszka Mu-43 Regular

    71
    May 1, 2015
    Central Coast, NSW Australia
    Agnieszka
    OK, so i have some things working and others not. I can update tags in a 'basic' sense. That is, if the tag contains some value, i can change it. if a tag contains no value, i can update it.

    However, there are a few situations where i cannot make updates. I've tried running a few of these as individual commands (not just a while long set of commands in one string). Here're what i'm having issues with:

    1) The LensID.
    I have learned that this is a 'composite' non-writable tag. I have checked the Olympus Tags page of the ExifTool reference: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Olympus.html (i own an E-M10), but the Lenses listed there are only Olympus/MFT native as far as i can tell (I want to write in my Samyang 500mm MF Reflex lens) - even so, what's the use of knowing these codes if the tag is not writable? and i cannot find the fields the 'composite' is made up from - is 'composite' a minomer in this case? all i can find are 'codes' which don't come from anywhere? I even tried ExifMixer, which another Mu-43 member had success with on his film scans, but even that util cannot write into the LensID tag. I'm assuming Olympus has somehow protected the file, since he can write the data to his scans, but i can't to my native digital files?

    2) Copying from another tag.
    For the life of me i cannot get the copyright tag to update with the string "Copyright 2015 Agnieszka Wiklendt" where "2015" is derived from CreateDate - no matter what the combination i have an error "file not found". I'm wondering if i'm missing something basic. This is a series of attempts i've tried:

    exiftool -overwrite_original -p -m -progress -ext .JPG '-copyright<Copyright -d %Y $CreateDate, Agnieszka Wiklendt' C:\Users\agnieszka\Pictures\__Devices\Olympus-OMD-EM10\EXIF_test

    exiftool -overwrite_original -p -m -progress -ext .JPG "-copyright<Copyright -d %Y $CreateDate, Agnieszka Wiklendt" C:\Users\agnieszka\Pictures\__Devices\Olympus-OMD-EM10\EXIF_test

    exiftool -overwrite_original -p -m -progress -ext .JPG -d %Y "-copyright<Copyright $CreateDate, Agnieszka Wiklendt" C:\Users\agnieszka\Pictures\__Devices\Olympus-OMD-EM10\EXIF_test

    exiftool -overwrite_original -p -m -progress -ext .JPG -copyright="Copyright -d %Y $CreateDate, Agnieszka Wiklendt" C:\Users\agnieszka\Pictures\__Devices\Olympus-OMD-EM10\EXIF_test

    and multiple other little variations: sometimes with "CreateDate" instead of "$CreateDate". One of the above even gave me the full exif program help file instead of the error. The example in the exif documentation shows copyright via an aggregate file (@ARG) - i have no idea what type of file this is or how to use it. i'm assuming it is what ExifMixer uses as it has each 'command' on a separate line. However, i have seen other examples online where the tag copy is in-line.

    EDIT: also, even if i just write something like "-copyright<CreateDate", i still get the "the system cannot find the file specified". however, if i just make it -copyright="Agnieszka Wiklendt", then the tag is updated to Agnieszka Wiklendt.

    3) Edited files.
    So i have edited some photos in GIMP or MS's Image Composite Editor - these also appear to be unaffected by any exiftool commands i throw at them (even when they originated from editable ones). Any ideas here? It doesn't seem to make a difference if the tag is "non-writable" or "writable", i can't make any changes to them (all are JPG, the ones i can update).

    EDIT: i tried adding -progress switch to the command and the edited files it has issues with return a minor error saying there's a duplicate XMP property (exif:ResolutionUnit), even though i have the -m switch to ignore minor errors. they also had the minor error "Bad equipment IFD entry". I think i saw somewhere in the documentation about duplicate tags, so i'll go back and see what that said and whether it'll fix this issue. I'll also google the equipment IFD entry error to see if there are any fixes out there for that.

    Any pointers with these three issues? I'll keep dabbling and googling, but someone might just know the trick!

    Thanks,
    Agnieszka.
     
    Last edited: May 21, 2015
  4. agnieszka

    agnieszka Mu-43 Regular

    71
    May 1, 2015
    Central Coast, NSW Australia
    Agnieszka
    Hi, I have decided I'm probably better off to put these questions in the exiftools forum. I'll do that inthe coming days and report back here with the outcomes so that others in the same boat can see my resolutions.

    Thanks for everyone's patience!
     
    Last edited: May 23, 2015
  5. agnieszka

    agnieszka Mu-43 Regular

    71
    May 1, 2015
    Central Coast, NSW Australia
    Agnieszka
    Hi everyone,

    after much reading and experimenting i have resolved each of my problems. i will detail the solutions below.

    1) Adding details of a non-native (to the camera) lens.

    LensID and LensType are non-writable in the practical sense. Those fields seem to be some sort of 'composite' made up of only same-make lenses, not manual or legacy lenses AFAIK.

    However, I came across this post (http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,3414.msg15375.html#msg15375) in exiftools forum, where Phil Harvey suggests to put manual lens info into LensModel. I also discovered that the tags LensSerialNumber, and LensInfo are all writable. It is still possible to use the LensID tag as a criterion against which to test files and then write the other tags if the criteria is met. The final commands (where DIR is the path to the file folder) for updating info for my manual lens (i have only one so this works well for me until i get another!) is:

    exiftool -if "$LensID eq 'None'" -LensModel="Samyang 500mm MC IF f/8 Mirror Lens" -LensSerialNumber="yourSerialNo" -LensInfo="500mm f/8" DIR

    2) Copying from another tag.

    Copyright tag to update with the string "Copyright 2015 Agnieszka Wiklendt" where "2015" is derived from CreateDate. The basics i found here (u88.n24.queensu.ca/exiftool/forum/index.php/topic,3174.msg14301.html), which is what i wanted instead of the ubiquitous ARG file option and equally ubiquitous File renaming/moving scenario.

    What undid me was the double-percent %%Y required for batch files (this drove me mental for a while until i realised! I was too focused on getting the exiftool commands correct that i completely forgot about batch conventions!). The final command:

    exiftool -a -P -m -progress -ext .JPG "-copyright<filecreatedate" -d "Copyright %%Y Agnieszka Wiklendt" "DIR"

    3) Inability for exiftool to write to files where those files have duplicate tags from GIMP editing software.

    To rectify affected images, I was advised in this post (http://gimpforums.com/thread-broken-tags-gps-data-on-jpg-export?pid=39881#pid39881) to remove tags from the bad (GIMPy)file and re-write them by copying good tags from an original backup - I was sceptical because of the problems I had with the non-writable tags such as LenID, but this mostly works! I say 'mostly' because there were some differences in the tags (see below the command).

    The exiftool command to copy over the tags from one image (source, or "src.jpg") to another (destination, or "dest.jpg") is:

    exiftool -all= -tagsfromfile src.jpg -all dest.jpg

    There were a total of 19 tags that were different between original and edited which was then 'fixed'. Eight tags relate directly to the file which you would expect to be different, these eight are: FileAccessDate, FileCreateDate, FileModifyDate, FileName, FileSize, Image Height, ImageSize, ImageWidth. In fact i am glad these are different, as it means these values are taken from the containing image of the file, rather than just blindly copied from an external image and having wrong values.

    Six tags in the 'fixed' file are have no value where the original had some value in them, these six are: About, Flash, Padding, Rating, RatingPercent, InteropVersion. I would have preferred the rating to have been copied, but for some reason it hasn't, though not a huge deal for my library.

    Lastly, there were five tags which are different between the two files but I am not sure why they should be. These five are: EncodingProcess, PreviewImageStart, ThumbnailOffset, YCbCrPositioning, and YCbCrSubSampling. I expect these are different because the edited file will have obvious changes and perhaps the information in these tags needed to be moved around in the compter-bit-speak.

    Finally, the real test is to see whether these 'fixed' types of files can be written to. I am pleased to say that I was able to change tags in the 'fixed' imaged where exiftools would previously not post-edit but pre-fix.

    4) Future directions

    (A) My next task is to automate the first two commands at file transfer stage from my SD card to the computer. I already use a batch script i'd written to copy only new files since last transfer. i reckon i can make an arg file of the log output that i already make in transfer and use the arg file in place of the "DIR" argument in the exiftool command to cycle through the new images to make the adjustments (and removing "OLYMPUS DIGITAL CAMERA" from the image description - which is the first thing i got working and what prompted me to look into exiftools in the first instance.)

    (B) finding an alternative raster editor to GIMP, so that this tag issue gets nipped in the bud. This will be difficult because i LOVE gimp and up till now it has worked well in my workflow.

    I have downloaded DigiKam and ACDSee trial, and will have a go at those. My post processing needs vary: from layers, to channel mixing, to pixel editing. I use windows live photo gallery for maintaining my library and minor adjustments, and it has so far worked well but since i upgraded to an interchangeable lens system (OMD E-M10) from point&shoot, i am wanting to see what lenses were used in each photo and WLPG does not seem to have that ability (unless i painstakingly add keywords manually - that's right, that particlar tag is non-writable!). i am hoping either digikam or ACDsee will replace both WLPG and GIMP, but i have a steep learning curve and experimenting ahead before i permanently change workflow.


    Wish me luck!
    Agnieszka.
     
    Last edited: May 28, 2015
    • Informative Informative x 2
    • Like Like x 1