Insert metadata of central wavelenghts and bands in tif file

Started by jlapajne, October 30, 2020, 10:43:13 AM

Previous topic - Next topic

jlapajne

Hello,
I have been tring this for a long time, but didnt succeed, thats why I decided I will post here and hope for someone to help.

I am dealing with multispectral photos and I would like to include information about band, wavelenght etc. into metadata of images. Each image represents separate band which is stored as a tif file.
Into separate image I need to include many tags, that is why I am doing it with csv file.

Here is my procedure:
First I create csv file with metadata information I want to include into images. You can see it here where I aligned it for easier visualisation. Also I included just one line.

Than I run the command:
path_to_exiftool -csv="csv_file_path" -overwrite_original output_images_path

The command terminate succefully and I inspect images with:
path_to_exiftool -csv -r -All output_images_path > output.csv

At this point I see that metadata about band, wavelenghts is not included in images. However some metadata is included (GPS data)

Can someone please tell me what am I doing wrong and what else could I try?
I will appriciate any help. Thank you in advance!

StarGeek Edit: fixed link

StarGeek

What is the actual tag you are trying to write, including the Group (add -G1 when listing output)?  From what I can see searching through the Tag Names pages, the Blacklevel tag only appears on various Camera MakerNotes pages (Canon, Nikon, Olympus, Sony, FujiFilm).  MakerNotes cannot be created individually, only edited in existing MakerNotes blocks (see FAQ #23).
* 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).

jlapajne

Hello, thank you for your answer. For now would be enough if I could write this data https://prnt.sc/va7wu6. Among those BandName and centerWavelenght are mising in metadata.

StarGeek

Do you have an image with this data?  If so, what group is the data located in.  Use exiftool -G1 -a -s FILE to see all tags and the groups they belong to.

My quick search of the Tag Names pages doesn't reveal a Bandname or CenterWavelength tag.

Of the rest of those tags, most are writable.  The other exceptions are FocalPlaneXResolution, FocalPlaneYResolution, and FocalPlaneResolutionUnit.  These tags are not writable.
* 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

BandName is part of the XMP-Camera group, which exiftool can't write by default, but it looks like it can be written with the config file in this post

Ah, even better, this post has a config file for both the XMP-Camera tags and the XMP-DLS tags, of which CenterWavelength is part of.  So download the file attached to that post and save it in the same directory as exiftool.  Then start any command in which you want to write BandName or CenterWavelength with
exiftool -config MicaSense.config

As for BlackLevel, I missed that it is also part of the EXIF group.  It is tagged as Unsafe so it is not written unless specified explicitly.  But I can't seem to write it directly, so hopefully Phil can comment on that.
* 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).

Phil Harvey

BlackLevel is writable, but the default write location is the SubIFD because this is used in DNG files.  So it won't get written if the SubIFD doesn't exist.  You can write it elsewhere if you want, but you would have to specify the location.  However, it isn't meant for this purpose.

- 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 ($).

jlapajne

Thank you both for your answers! It now finally works. I am asking myself why I didnt post it earlier - it would save me quite some time.

About blackLevel -  I dont actually need to include it..it just came in the middle of everything, because I was begining to try every option what else need to be included.

Anyways, it seems that now Bandname and Wavelength are included in metadata.
I checked it with proposed method:
exiftool -G1 -a -s FILE

There is just one slight thing I think I need to change, because it throws me a warning when I execute metadata writing:
Warning: [minor] Fixed incorrect tag ID case for XMP-Camera:Bandname

I include bandname and Wavelenght in header as:
XMP-Camera:Bandname
XMP-DLS:CenterWavelength

For CenterWavelength there is no warning.




StarGeek

Quote from: jlapajne on October 31, 2020, 09:40:30 AM
There is just one slight thing I think I need to change, because it throws me a warning when I execute metadata writing:
Warning: [minor] Fixed incorrect tag ID case for XMP-Camera:Bandname

Nothing you need to change.  As it says, it's a minor warning and it has been fixed.  The problem is that the data in your file lists that tag as BandName, but the config file used to write it uses Bandname.  It's very unlikely to cause a problem unless the software that reads it is very badly written.

Though, checking that config file, I notice that it has two listings for BandName, one with upper case N and one with lower case n.  And I would suspect that the one with the upper case N would be correct.  If  you like, you could edit the config file and remove this line
Bandname => { },
* 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).

jlapajne

Oh thanks. Yes I removed the one witn the n and the problem is...gone! Thanks a lot!

jlapajne

Hello, me again. Previously proposed methods how to insert metadata into image work, but I decided to ask, if there exist better, more elegant method to do the insertion.

Images with which I am working include quite a lot of tags. Those tags are lost after I read-process-save the image.
If it is possible I would like to copy all the tags from image before processing and insert it into images saved after processing.

I was thinking to do something like this:

path_to_exiftool -config path_to_micasense.config -csv -r -All path_to_images > output.csv

path_to_exiftool -config path_to_micasense.config -csv output.csv -overwrite_original path_to_images


The problem I think is that the images I am dealing with include special config, so this way values and tags are not inserted from image before processing to image after processing.
My question is than is it even possible to insert metadata this way or must I do it for each tag separately?

Here https://drive.google.com/drive/folders/1Za-UyD_UMIXSnr_ITjgvTGcDN5wCKUg9?usp=sharing is an example of two images, where one includes all metadata and other none. In this case I just saved the same image without metadata.

Thank you in advance.

StarGeek

I would suggest copying the data as a block to exiftool's own MIE sidecar files, then copying back afterwords.  This can copy data as a block so it would copy all tags, even unknown ones that would require a config file.

First, batch create the sidecards.  This command will copy all the EXIF and XMP tags as a block, which would include tags exiftool might not know about, without the need for a config file.  Include other groups, such as ICC_Profiles, as needed.
exiftool -tagsfromfile @ -EXIF -XMP -srcfile %d%f.MIE /path/to/files/

Then afterwards, copy the blocks back into the files
exiftool -tagsfromfile %d%f.MIE -EXIF -XMP /path/to/files/

At least I think I have that correct.  Test it out first (and hopefully Phil will correct if need be).
See MIE sidecar files for more details.

Also, if the output files are in a different directory than the originals, then you can just copy directly from the originals to the output files, skipping the sidecar file.
exiftool -TagsFromFile /path/to/originals/%F -EXIF -XMP /path/to/edited/
* 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).

jlapajne

Hey, thanks for reply, but the first command somehow dont work. It says that @ does not exist for -tagsFromFile option? Should I change it somehow? Additionaly should I first put images with metadata in the folder  (/path/to/files/) and than save metadata. Than delete those with metadata and substitude them with images without metadata and then run the second command?

StarGeek

Can you copy/paste the command and output from that command?  And confirm you're using it directly on the command line, not in a bat file or something?  It work correctly here
C:\>exiftool -tagsfromfile @ -EXIF -XMP -srcfile %d%f.MIE y:\!temp\Test4.jpg
    1 image files created


Quote from: jlapajne on November 05, 2020, 04:35:35 PMAdditionaly should I first put images with metadata in the folder  (/path/to/files/) and than save metadata. Than delete those with metadata and substitude them with images without metadata and then run the second command?

That would be up to you, however you want to go about it.
* 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).

jlapajne

I just substituted "@" with @ and it works. Probably windows problems? Anyways, I succesfully included XMP tags, but did not succeed to include GPS, ExifIFD and IFD0 tags. I did the following:

exiftool -TagsFromFile /path/to/originals/%F -EXIF -XMP -IFD0 -GPS -ExifIFD /path/to/edited/


Should I include some extra flags?

Phil Harvey

Your -ExifIFD, -GPS and -IFD0 tags won't do anything.  These EXIF subdirectories are coping with the -EXIF block copy.  But your command should work if EXIF existed in the original JPG.  Can you try this on one file, and confirm that EXIF exists in the original, then show us the exact commands you used and the output of exiftool -a -G1 -exif:all on both files?

- 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 ($).

jlapajne

Ok here is my transformation flow:
1.) I open original tif file, do something with it and save it in other directory (during this metadata is lost)
2.) I run the following command:

exiftool -TagsFromFile  path/to/original/file -EXIF -XMP path/to/edited/file

Actual command:

C:\Users\janezla\"exiftool.exe" -TagsFromFile C:\Users\janezla\Documents\programs\RedEdgeImageSet\0002SET\000\IMG_0002_1.tif -EXIF -XMP C:\Users\janezla\Documents\programs\RedEdgeImageSet\aligned\IMG_0002_1.tif

3.) I put changed image and original image in different directory and run the following command to check if metadata is copied:

exiftool -a -G1 -exif:all directory/of/both/files

Actual command:

C:\Users\janezla\"exiftool.exe" -a -G1 -exif:all C:\Users\janezla\Documents\programs\RedEdgeImageSet\csv_tt

An here you can see output: http://prntscr.com/veuxp8

StarGeek

I believe the problem is that you can't copy the EXIF as a block from a tiff file because the image data is part of the EXIF block, unlike a jpeg where the image data is separate from the EXIF.
* 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).

jlapajne

hm ok. But I am sure something cen be done right? :)
I mean..if I can insert it one by one, why couldnt I insert it in a bach (at least I hope this)

Phil Harvey

You can't copy an EXIF block from a TIFF file (see the description for the EXIF tag in the Extra tags documentation).  This is because the EXIF block (or what we're calling the EXIF block here... IFD0 and all subdirectories) actually contains the image data in a TIFF file.

- 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

Sorry, I forgot the title.  I shouldn't have mentioned copying EXIF as a block for a tiff file.  You'll have to copy the EXIF tags using the config file and -EXIF:All.  But the XMP tags can be copied as a block as shown.
* 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).