Problems importing metadata from csv into images

Started by spippiy, September 25, 2024, 10:55:08 AM

Previous topic - Next topic

spippiy

As stated in title I have difficulties with importing metadata from a csv file into images.
The problems are the following:

1) I have images named as 1.jpg, 2.jpg, 3.jpg, 4.jpg,...
These images are not in the same folder but in different subfolders.
For example C:/Users/exiftool/animals/giraffe/1.jpg, C:/Users/exiftool/animals/elephant/2.jpg, C:/Users/exiftool/animals/hamster/3.jpg,C:/Users/exiftool/animals/tiger/4.jpg,...
It is not possible for me to write in the csv SourceFile column the full path for every image because the subfolders are too many. I tried to write in the SourceFile column like this: C:/Users/exiftool/animals/*/1.jpg, C:/Users/exiftool/animals/*/2.jpg,... but it didn't worked.
In fact if I write in the cmd exiftool -r -overwrite_original -csv="C:\Users\exiftool\import.csv" "C:\Users\exiftool\animals", I get a list of "No SourceFile 'C:/Users/exiftool/animals/giraffe/1.jpg' in imported CSV database",...

Is there a way to use some special characters in the csv SourceFile column without having to write the full file path?

2) If I import csv data into images using this command exiftool -r -overwrite_original -csv="C:\Users\exiftool\import.csv" "C:\Users\exiftool\animals", the images will get only tags from Gps and Exififd groups, while all other tags belonging to other groups (like ICC-header, ICC-Profile, JFIF, MPImage, Apple) are not imported.

Is there a command to import all the tags to images from csv?


I hope there are solutions to these questions because it is important for me..
Thank you :)

Phil Harvey

The -csv option works for same-named files in different directories, so the directory name is significant.

You can use the HardLink feature to flatten your directory structure to achieve what you want.  eg)

1. mkdir tmp

2. cd tmp

3. exiftool -hardlink=%f.%e -r /path/to/root/image/file/dir

4. exiftool -overwrite_original_in_place -csv=/path/to/file.csv .

This should work for a CSV with a SourceFile column with no directory names.  Note the -overwrite_original_in_place option is necessary to avoid breaking the hard links.  After this, you may delete the hard-linked files in the tmp directory.

As usual, be sure to keep backups of the originals in case anything goes wrong.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

spippiy

Thank you! The hardlink command is perfect!

I still have one problem, I have noticed that when importing csv data into images, the images will get only tags from Gps and Exififd groups but they don't get a lot of other tags belonging to groups such as ICC-header, ICC-Profile, JFIF, MPImage, Apple that are present in the csv file.

Is there a way to import also these tags?
Thank you

StarGeek

Most of those tags aren't writable or are binary data which can't be placed in a CSV file. Some of them can be copied as a block from the original file

for example,
exiftool -TagsFromFile source.jpg -ICC_Profile target.jpg
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

spippiy

Thank you for the answer. Unfortunately I can't use -tagsfromfile because I have the data only on a csv file.
The fact is that according to the documentation most of the Apple tags are writable, but I'm not able to import any single Apple tag from csv to images using this command
exiftool -csv="file.csv" "C:\Folder with images"
In the csv I have these tags:Apple:AccelerationVector, Apple:AEAverage, Apple:AEStable, Apple:AETarget, Apple:AFConfidence, Apple:AFMeasuredDepth, Apple:AFPerformance,Apple:AFStable, Apple:CameraType, Apple:ColorTemperature, Apple:FocusDistanceRange, Apple:FocusPosition, Apple:HDRGain, Apple:HDRHeadroom, Apple:ImageCaptureType, Apple:LivePhotoVideoIndex, Apple:MakerNoteVersion, Apple:PhotoIdentifier, Apple:PhotosAppFeatureFlags, Apple:RunTimeEpoch, Apple:RunTimeFlags, Apple:RunTimeScale, Apple:RunTimeValue, Apple:SemanticStyle, Apple:SignalToNoiseRatio.

Is it normal or I am missing a command?

Thank you




Phil Harvey

These are maker note tags, so they may only be written if the maker notes already exist.  Individual maker note tags may not be created.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: spippiy on September 27, 2024, 08:00:37 PMIs it normal or I am missing a command?

-TagsFromFile is your only option for these. They must be copied as a block
exiftool -TagsFromFile source.jpg -ICC_Profile -Makernotes target.jpg

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

spippiy

#7
Quote from: Phil Harvey on September 27, 2024, 08:37:05 PMThese are maker note tags, so they may only be written if the maker notes already exist.  Individual maker note tags may not be created.

- Phil
I'm sorry for the insistence but I've spent a lot of hours in a project but I'm stuck and I'm trying to find a workaround to import the Apple tags from a csv.
 
I have used this code to export in block the apple tags from one iphone picture towards a folder with pictures that have no metadata:

exiftool -TagsFromFile iphonephoto.jpg -Makernotes folderwithimages
After that command, the pictures in the folder obtained the apple tags. So, according to your message the makernotes now exist and could be written. But, unfortunately I'm still unable to modify apple tags:

exiftool -apple:aestable="No" folderwithimages
Warning: [minor] Maker notes could not be parsed

But, if I use the above command on a native iphone image I'm able to modify the apple tag.
Does this mean that I can't modify apple tags if they have been imported in block?





Phil Harvey

OK.  From your description it seems that ExifTool isn't importing the maker note block properly.  I don't have any samples I can test with right now, but I should be able to look into this on Monday when I'm back home.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

spippiy

Thank you very much, this forum has an amazing support :)

Phil Harvey

I should have though of this earlier.  You should also copy Make and Model when you copy the maker notes.  See FAQ 8.

I tried this with various sample iPhone pictures and I could set AEStable with no errors.  If you still have problems, post your sample images or send them to me at philharvey66 at gmail.com.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

spippiy

Quote from: Phil Harvey on October 08, 2024, 08:52:41 AMI should have though of this earlier.  You should also copy Make and Model when you copy the maker notes.  See FAQ 8.

I tried this with various sample iPhone pictures and I could set AEStable with no errors.  If you still have problems, post your sample images or send them to me at philharvey66 at gmail.com.

- Phil
Phil thank you so much!
The problem was in fact that I should have copied also the Make tag.
Right now I'm finally able to set the Apple tags using a csv file on photos that are not native Apple photos or that their Apple tags have been removed.

Anyway, I have encountered new problems.

1) When I import tags from csv to an image, every tag is imported correctly apart from SceneFlags. In fact I get this error "Warning: Invalid value for MakerNotes:SceneFlags". In the csv file the Apple:SceneFlags has value:[2], [3], [7], [10], [12] and in the image that I want to import it the SceneFlags has value [1], [2], [7] and because of the error it doesn't change.
This is strange because a similiar tag in the csv file which is Apple:ImageProcessingFlags with value [13], [17] is correctly imported without errors.

2) In case I want to import only certain tags from a csv file to an image how can I do? I was only able to exclude tags from being imported with this command: exiftool -csv="file.csv" "-Apple:FocusPosition<Apple:FocusPosition" "image.jpg"
3) In case I want to delete a tag in an image using the csv file is it possible?

4) Is there no way to delete specific apple tags, right?

Thank you and sorry for the many questions :)

Phil Harvey

#12
1) I'll look into the SceneFlags issue when I get some time.

2) Currently there is no way to do that, but I will add a feature to ExifTool 13.03 allowing you to specify tags to be included or excluded from the import.

3) From the application documentation:

            When importing, empty values are ignored unless the -f option is
            used and the API MissingTagValue is set to an empty string (in
            which case the tag is deleted).


4) Correct.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

spippiy

I finally finished my personal small project and I wanted to thanks Phil Harvey and StarGeek for the great support.
What I did in my project was to give to some of my non-Apple photos unique apple tags as if they were actual apple photos.

I think I have found two bugs about two apple tags that in the documentation should be writable but when I import them using a csv file into my images, they don't change.
These tags are SceneFlags (that I had already mentioned in previous post and this gives an error on terminal) and FocusDistanceRange (this doesn't give any error but still doesn't import).

Also, I would be curious to know what makes a tag writable or non-writable. Is it possible that a non-writable tag in the future could become writable because something new is discovered?
I'm referring in particular to RunTimeValue tag.

To conclude I want to say that I spent a lot of time in reading exiftool forum and documentation but without the personal support I received I wouldn't be able to achieve what I wanted, so again, thank you :)

Phil Harvey

#14
I played with the SceneFlags but couldn't reproduce the warning you mentioned.  Used this CSV file:

Sourcefile,SceneFlags
*,"[2], [3], [7], [10], [12]"

and this command:

exiftool -csv=test.csv test.jpg

And the SceneFlags were updated as expected.

If you upload your test files somewhere and give me the command you used I can' try to reproduce this.

Non-writable tags my be changed to writable if there is a demand.  If they aren't writable already it is because the effort outweighed the demand.

- Phil

Edit:  I can reproduce the problem with FocusDistanceRange.  This will be fixed in 13.03.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).