Linux - Fedora - Symlinks and Newlines

Started by steveTu, April 11, 2021, 06:04:59 AM

Previous topic - Next topic

steveTu

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


Luuk2005

#1
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.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Alan Clifford

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.

Alan Clifford

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

steveTu

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.

Alan Clifford

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.

Alan Clifford

QuoteExif.Photo.UserComment                                          charset=Ascii <COMM LINE> Simple Comment

I don't recognise the syntax Exif.Photo.UserComment.  Did exiftool produce that?

Luuk2005

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.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Phil Harvey

This really isn't documented very well, but it is mentioned in the SYMLINK description here:

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

steveTu

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

Alan Clifford

Isn't CR+LF a microsoft thing.  Isn't it just a LF in unixes?

Alan Clifford

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

StarGeek

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 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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

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
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).