News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Copying tags from original image to edited one.

Started by Rose, May 18, 2020, 02:39:13 AM

Previous topic - Next topic

Rose

I'm trying to copy my meta data from this image to the same image following some edits so I can use it for reconstruction as the software is picky. I once found a way, but didn't not write down how I did it.
The original file uses these tags:
ExifTool Version Number         : 10.79
File Name                       : Mice_PTA_1W_0000.tif
Directory                       : /Volumes/LaCie/Data/PTA_1W_
File Size                       : 2.0 MB
File Modification Date/Time     : 2018:02:19 14:26:28+00:00
File Access Date/Time           : 2020:05:18 07:12:39+01:00
File Inode Change Date/Time     : 2018:08:04 00:05:29+01:00
File Permissions                : rwxrwxrwx
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian (Intel, II)
Subfile Type                    : Full-resolution Image
Image Width                     : 1024
Image Height                    : 1024
Bits Per Sample                 : 16
Compression                     : Uncompressed
Photometric Interpretation      : BlackIsZero
Strip Offsets                   : (Binary data 316 bytes, use -b option to extract)
Samples Per Pixel               : 1
Rows Per Strip                  : 24
Strip Byte Counts               : (Binary data 257 bytes, use -b option to extract)
X Resolution                    : 1733
Y Resolution                    : 1733
Resolution Unit                 : inches
Image Size                      : 1024x1024
Megapixels                      : 1.0

And the edited file has these:

ExifTool Version Number         : 10.79
File Name                       : PTA_1W_0000.tif
Directory                       : /Users/Rose/Desktop/Rose Matlab code/Dissertation_code/PTA/PTA
File Size                       : 2.0 MB
File Modification Date/Time     : 2020:05:18 07:12:31+01:00
File Access Date/Time           : 2020:05:18 07:26:29+01:00
File Inode Change Date/Time     : 2020:05:18 07:12:31+01:00
File Permissions                : rw-r--r--
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian (Intel, II)
Image Width                     : 1024
Image Height                    : 1024
Bits Per Sample                 : 16
Compression                     : Uncompressed
Photometric Interpretation      : BlackIsZero
Document Name                   :
Strip Offsets                   : (Binary data 1912 bytes, use -b option to extract)
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 1
Rows Per Strip                  : 4
Strip Byte Counts               : (Binary data 1279 bytes, use -b option to extract)
X Resolution                    : 1733
Y Resolution                    : 1733
Planar Configuration            : Chunky
Resolution Unit                 : inches
Page Number                     : 0 1
Software                        : GraphicsMagick 1.3.21 2015-02-28 Q16 http://www.GraphicsMagick.org/
Sample Format                   : Unsigned
Image Size                      : 1024x1024
Megapixels                      : 1.0

I know some of the extra tags cause problems, but cannot for the life of me remember which ones and how to make the tags identical between the two images.

Phil Harvey

You could try this:

exiftool -tagsfromfile SRCFILE -all:all DSTFILE

- 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

A quick look at your output seems to indicate that there isn't actually much data there that can be copied.  You should use exiftool -G1 -a -s on the file (see FAQ #3) to get some idea of what groups the data is located.

Anything in System, File, and Composite groups can be ignored.  They either can't be copied/altered or shouldn't affect loading the image.  Odds are that is leaving EXIF data (groups IFD*, ExifIFD).  You can then check the EXIF tags page to see what is editable and copy those.

A lot of the EXIF tags you're displaying either can't be copied (BitsPerSample, StripOffsets) or are unsafe to copy (RowsPerStrip, anything that has an exclamation point in the Writable column).

You'll probably have to do some careful experimentation to try and figure out the problem.
* 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).

Dave Pitman

Could you share the command string to read the exif data from one directory of images and use them to replace the exif data from another directory containing corresponding edited copies of the same images?

Directory to read:  "original"  has images "1.jpg, 2.jpg, 3.jpg, etc."
Directory to write:  "edited" has images "1.jpg, 2.jpg, 3.jpg, etc."

(Win.10)
Thanks!

StarGeek

Try
exiftool -TagsFromFile /path/to/original/%F -exif:all /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).

Dave Pitman

Thanks for the help.
No success yet, but here is what I get.

C:\Users\Pitman\Desktop\exiftest>exiftool -TagsFromFile original/%F -exif:all edited/
Warning: Error opening file - original/0027.JPG
    1 directories scanned
    0 image files updated
    1 image files unchanged


** I have exiftool.exe located in the folder "exiftest" that contains the 2 folders "original" and "edited".  And, there is only 1 image in each folder for this test.

StarGeek

According to that output, either "C:\Users\Pitman\Desktop\exiftest\original\0027.JPG" doesn't exist or there is a permissions problem.

Try using the full path to the original directory.
* 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).

Dave Pitman

Basically same error.  I know it finds the "original" directory in each case because it names the image, correct?

C:\Users\Pitman\Desktop\exiftest>exiftool -TagsFromFile \C:\Users\Pitman\Desktop\exiftest\original/%F -exif:all edited/
Warning: Error opening file - \C:\Users\Pitman\Desktop\exiftest\original/0027.JPG
    1 directories scanned
    0 image files updated
    1 image files unchanged

Phil Harvey

What is the "\" doing before the -tagsFromFile filename?

Try this:

C:\Users\Pitman\Desktop\exiftest>exiftool -TagsFromFile C:\Users\Pitman\Desktop\exiftest\original/%F -exif:all edited/

or better yet (since you are already in the C:\Users\Pitman\Desktop\exiftest directory:

C:\Users\Pitman\Desktop\exiftest>exiftool -TagsFromFile original/%F -exif:all edited/

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

Dave Pitman

Unfortunately, no change.  Not sure if it makes a difference, but I am opening the cmd prompt as admin.  Thanks for trying.

C:\Users>cd pitman\desktop\exiftest

C:\Users\Pitman\Desktop\exiftest>exiftool -TagsFromFile original/%F -exif:all edited/
Warning: Error opening file - original/DJI_0027.JPG
    1 directories scanned
    0 image files updated
    1 image files unchanged

C:\Users\Pitman\Desktop\exiftest>




StarGeek

Quote from: Dave Pitman on May 30, 2020, 07:04:22 PM
Basically same error.  I know it finds the "original" directory in each case because it names the image, correct?

No, it's just telling you the name of the filepath it is looking for. 

What is the output of
dir original/
* 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).

Dave Pitman

#11
Quote from: StarGeek on May 30, 2020, 10:35:07 PM

No, it's just telling you the name of the filepath it is looking for. 

What is the output of
dir original/

Gotcha.  And you were correct.  I was specifying "original" and the directory is "originals". My bad, rookie mistake.  The script works, thanks to you both.  However, in addition to cloning the exif data, it is also adding a new file in the edited directory that is a duplicate of the file that was replaced except it does not have the .jpg extension and is named "DJI_0027.JPG_original" .   If I manually add the .jpg extension, it opens fine as a jpg.  Is there a way to not get the duplicate file?

Phil Harvey

Add -overwrite_original to the command.

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

Dave Pitman

Perfect.  Thanks again for the help, much appreciated!