ExifTool Forum

ExifTool => Newbies => Topic started by: steveTu on April 11, 2021, 06:04:59 AM

Title: Linux - Fedora - Symlinks and Newlines
Post by: steveTu on April 11, 2021, 06:04:59 AM
Good morning all - I'm Steve - an exiftool newbie.

I am trying to use exiftool to show and then potentially alter the usercomments on a few of my photos. My photos are in a basic structure and generally maintained by Shotwell.
In this case though, I have a small program (to do with family trees) that symlinks the images that I use within the family tree back to their originals in my photo structure. The symlink is at file level, not directory.
This works ok and I can see the the photo and its comment in the family tree prog fine. The issue is when I try to update the usercomment using:
exiftool -charset UTF8 -UserComment="MYCOMMENT" "MYSYMLINKEDFILE"
 
...this appears to work - BUT - what actually appears to happen is the symlink is broken and a copy of the original photo is placed in the sym link directory with the correctly updated comments. I hadn't realised it was doing this until I tried to see the comments in the original, file (via shotwell) and saw the original and not updated  comments. Is there a way to get exiftool to update the original  'symlinked' photo and to not make a copy?

Secondly, I had expected to be able to add 'new lines' (ASCII(10)/ASCII(13)) to the comments so I could structure them a bit better. But if I add a CR or LF to the usercomment it appears in the exiftool extraction as a dot ('.'). I don't know much about photo metadata - and I have subsequently noticed in shotwell that if I add a 'CR/LF' in a comment - it initially shows ok in the extended data view, but then switches to read 'binary comment'. Obviously I don't expect anyone to have knowledge of how Shotwell works - the question is 'is CR/LF handled within Exif metadata?' and if so is it advised, and then how can i get a CR/LF into the comment without it being converted to a dot ('.').

Thanks in advance.
Steve

Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Luuk2005 on April 11, 2021, 06:27:18 AM
Greetings Steve. There is -Overwrite_Original_In_Place and -Overwrite_Original to forbid creating the backup files.
And the exiftool only presents . for newlines to make it look better for the eyesight on the commandline.

Edit: I found the link for newlines!... https://exiftool.org/faq.html#Q21
Im not sure if you want to present the newlines? but -b can do this for you.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 11, 2021, 06:54:48 AM
Overwrite_original_in_place worked but you don't get the backup file.

Try this is Phil doesn't have an exiftool based solution:

exiftool -artist=clifforda $(readlink linkedfrom.jpg)

I got this:

cellini:temp alan$ ls -l linked*
lrwxr-xr-x  1 alan  staff      12 11 Apr 11:40 linkedfrom.jpg@ -> linkedto.jpg
-rw-r--r--  1 alan  staff  165374 11 Apr 11:49 linkedto.jpg
-rw-r--r--  1 alan  staff  165370 11 Apr 11:41 linkedto.jpg_original


and

cellini:temp alan$ exiftool -artist linked*
======== linkedfrom.jpg
Artist                          : clifforda
======== linkedto.jpg
Artist                          : clifforda
======== linkedto.jpg_original
Artist                          : ALAN
    3 image files read




I haven't tried it going to a different directory.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 11, 2021, 07:04:12 AM
It seems to work with a different directory

cellini:temp alan$ ln -s ./temp/linkedto.jpg linkedfrom.jpg
cellini:temp alan$ exiftool -artist=MrBlobby $(readlink linkedfrom.jpg)


cellini:temp alan$ ls -l linked* ./temp/linkedto.jpg*
-rw-r--r--  1 alan  staff  165374 11 Apr 12:00 ./temp/linkedto.jpg
-rw-r--r--  1 alan  staff  165374 11 Apr 11:57 ./temp/linkedto.jpg_original
lrwxr-xr-x  1 alan  staff      19 11 Apr 12:00 linkedfrom.jpg@ -> ./temp/linkedto.jpg
cellini:temp alan$ exiftool -artist  linked* ./temp/linkedto.jpg*
======== linkedfrom.jpg
Artist                          : MrBlobby
======== ./temp/linkedto.jpg
Artist                          : MrBlobby
======== ./temp/linkedto.jpg_original
Artist                          : clifforda
    3 image files read
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: steveTu on April 11, 2021, 08:02:47 AM
Alan/Luuk
Thank you both for your speedy replies and help. Very much appreciated.
The overwrite_original didn't work, but the overwrite_original_in_place did - but as you say Ala, no 'original' file then created (I'm not sure that matters). I looked at the readlink solution, but I have issues with that (I think!) in as much as that it works for symlinks but doesn't for standard files - so if I ever then use direct images as well as symlinks then I'll need to sort that out (if I remember!). I thought symlinks would do that for me - ie I didn't have to worry about where the image was - if it was symlinked, it would be handled and if it was directly in the family tree folder fine.

What I'm also getting is that now when the -usercomment= is applied, is that the comment carries a prefix charset= as in:
Exif.Photo.UserComment                                          charset=Ascii <COMM LINE> Simple Comment

The -usercommand I used was:
exiftool -overwrite_original_in_place -charset UTF8 -UserComment="<COMM LINE> Simple Comment"  "/u/dev/GENERO/uk/fam/DOCUMENTS/dev/fampers/0000002/Chris - 96-97'ish(?) - Outside A cafe (Legoland?) - Drinking through a Straw and Laughing_01_02_03_04.jpg"

I'm beginning to think I'm tackling this the wrong way and that I should leave the photo metadata alone and simply clone it into my family tree database when the image is first loaded and then manipulate that. I can then leave shotwell to manage the photos in general without the family tree buggering up Shotwell and vice/versa.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 11, 2021, 11:53:35 AM
Quoteas much as that it works for symlinks but doesn't for standard files

If I were doing this for myself, I do it in the exif command line with an "if symlink" but I don't know enough perl to do that.  But I might by the end of this evening.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 11, 2021, 11:55:52 AM
QuoteExif.Photo.UserComment                                          charset=Ascii <COMM LINE> Simple Comment

I don't recognise the syntax Exif.Photo.UserComment.  Did exiftool produce that?
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Luuk2005 on April 11, 2021, 01:52:26 PM
Im thinking that exiv2 is what presented Exif.Photo.UserComment and the value just looks like there was a typo.
A google search for.... exiv2 set Exif.Photo.UserComment presented results with 'charset=Ascii' to set the encoding.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Phil Harvey on April 11, 2021, 04:27:26 PM
This really isn't documented very well, but it is mentioned in the SYMLINK description here (https://exiftool.org/TagNames/Extra.html):

Note that subsequent editing of the file via the symbolic link by exiftool will cause the link to be replaced by the edited file without changing the original unless the -overwrite_original_in_place option is used

Regarding the UserComment character set, Exiv2 may display this while ExifTool does not.  I believe, though, that this depends on the version of Exiv2 you are using, because I seem to remember there was change in the way they handle this.

- Phil
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: steveTu on April 12, 2021, 08:59:54 AM
Phil
Thanks for the clarification on the symlinks.
I am not aware of ever using exiv2 - as I tend to use Shotwell to manage the photos and rely on its comment and tag editors from within its GUI. I was only using exiftool - and only installed it recently (on Saturday) - as I wanted to be able to also now modify comments from my family tree stuff, so was running exiftool to get and update the comments from the family tree.
As I said though, the issues with CR/LF stuff me a bit. Shotwell, that I want to keep using, shows 'binary image' when a CR/LF is entered in the comment (even via its own GUI comment editor), so even if I could get something in via exiftool, it would mess up the comment in Shotwell anyway. So I think I'm forced into keeping my family tree comments outside of the image metadata.

Thank you, you three for all your help
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 12, 2021, 11:38:40 AM
Isn't CR+LF a microsoft thing.  Isn't it just a LF in unixes?
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: Alan Clifford on April 12, 2021, 11:45:53 AM
Quote from: steveTu on April 12, 2021, 08:59:54 AM

I am not aware of ever using exiv2 - as I tend to use Shotwell

From the shotwell website
QuoteThis page describes how Shotwell and other photo programs import and export information through EXIF/IPTC/XMP tags. The metdata "paths" are Exiv2 tags.
https://wiki.gnome.org/Apps/Shotwell/PhotoTags
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: StarGeek on April 12, 2021, 11:51:13 AM
Quote from: steveTu on April 11, 2021, 06:04:59 AMthe question is 'is CR/LF handled within Exif metadata?' and if so is it advised, and then how can i get a CR/LF into the comment without it being converted to a dot ('.').

Since this wasn't explicitly addressed, the answer lies in the first sentence of FAQ #21 (https://sno.phy.queensu.ca/~phil/exiftool/faq.html#Q21) as Luuk2005 linked
    When reading, by default exiftool converts all control characters to "." to avoid messing up the output formatting, so newlines will appear as a "." in the output.

So exiftool is writing correctly, but the output displays the dot because otherwise it would affect the output formatting.
Title: Re: Linux - Fedora - Symlinks and Newlines
Post by: StarGeek on April 12, 2021, 11:53:33 AM
Quote from: Alan Clifford on April 12, 2021, 11:38:40 AM
Isn't CR+LF a microsoft thing.  Isn't it just a LF in unixes?

Pretty much.  But most programs seem to deal with either without problems.  Even though I'm on Windows, I standardize all my metadata to just LFs, though for me, that's actually a holdover from my Amiga days :D