Trying to create a perl script to take DateTimeOriginal tag from .insp files (Insta360 image files) and put them in jpeg screenshots.
https://github.com/chuckkahn/EXIF-tags-from-.insp-into-jpeg/blob/main/exif_change.pl
But I'm getting the error Can't call method "SetNewValuesFromFile" on an undefined value:
zCKAvid:EXIF scripts charleskahn$ perl '/Volumes/CK_10TB/Downloads iMac/code/EXIF scripts/exif_change.pl'
======================================== go through screenshots
PATH is /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio/
screenshot #1
screenshot = /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio/IMG_20220318_094121_00_866_2022-03-27_13-57-02_screenshot.jpg DateTimeOriginal =
insp_ref = IMG_20220318_094121_00_866.insp
insp_path = /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/DCIM/Camera01/IMG_20220318_094121_00_866.insp DateTimeOriginal = 2022:03:18 14:52:07
Can't call method "SetNewValuesFromFile" on an undefined value at /Volumes/CK_10TB/Downloads iMac/code/EXIF scripts/exif_change.pl line 64.
You need to define the $exifTool variable, ie)
my $exifTool = new Image::ExifTool;
You should do this outside of the loop, then clear the queued new values before re-using the ExifTool object in the loop:
$exifTool->SetNewValue();
- Phil
Thanks!
Now I discover that the premise of my perl script won't work because the naming structure of the original .insp files has duplicates. So I'm at a loss how to trace the exported jpeg "IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg" back to its original .insp.
======== /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/DCIM/Camera01/IMG_20220318_094121_00_016.insp
Date/Time Original : 2022:03:18 13:41:21
======== /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/DCIM/Camera02/IMG_20220318_094121_00_016.insp
Date/Time Original : 2022:03:18 15:04:33
2 image files read
There is nothing in a jpeg export's metadata pointing to its origin:
zCKAvid:_FOR EXIFTOOL charleskahn$ exiftool /Volumes/CK_10TB/Downloads\ iMac/_media\ for\ unRAID/Insta360\ ONE\ X/2022-03-18\ -\ Toronto\ Comicon\ Day\ 1/_Studio/IMG_20220318_094121_00_016_2022-03-31_08-56-55_screenshot.jpg
ExifTool Version Number : 12.30
File Name : IMG_20220318_094121_00_016_2022-03-31_08-56-55_screenshot.jpg
Directory : /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio
File Size : 4.0 MiB
File Modification Date/Time : 2022:03:31 08:57:04-04:00
File Access Date/Time : 2022:03:31 08:57:20-04:00
File Inode Change Date/Time : 2022:03:31 08:57:20-04:00
File Permissions : -rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 72
Y Resolution : 72
Image Width : 6080
Image Height : 3040
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 6080x3040
Megapixels : 18.5
It is difficult when the exported file contains essentially no metatata.
I associate my files entirely using metadata timestamps.
- Phil
So I've defined the $exifTool variable outside the loop (exiting the loop just to see if this is working on the first file) and cleared the queued new values at the end of the loop.
But SetNewValuesFromFile & WriteInfo doesn't seem to be doing anything. (tagsFromFile as a system command worked as a test, commented those out). SetNewValuesFromFile is the perl equivalent of tagsFromFile I thought? A Shift was added because a GMT/EST shift needed to be added, and that worked (also commented out).
zCKAvid:Perl charleskahn$ perl '/Volumes/CK_10TB/Downloads iMac/code/EXIF scripts/exif_change.pl'
======================================== go through screenshots
PATH is /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio/Camera01/
=========================== screenshot #1 from .insp =========================================================
IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg 2022:03:18 01:41:21 IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
IMG_20220318_094121_00_016.insp 2022:03:18 13:41:21 Insta360 One2 IMG_20220318_094121_00_016.insp
exifTool = Image::ExifTool=HASH(0x7fb02e8aab60)
info = HASH(0x7fb02ed83a88)
errcode = 2
info_screenshot = HASH(0x7fb02f337390)
IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg 2022:03:18 01:41:21
https://github.com/chuckkahn/EXIF-tags-from-.insp-into-jpeg/blob/main/exif_change.pl
Suggest you "use strict;" to weed out your Perl bugs. (eg. undefined $insp_path variable)
Also, you may want to check for Error and/or Warning returns from SetNewValuesFromFile.
- Phil
Why do repeated runs that include this line:
$exifTool->SetNewValue(DateTimeOriginal => '4:00', Shift => -1); # shift time by 4 hours for GMT to EST
Cause the time to go down by another 4 hours? Shouldn't SetNewValuesFromFile command that precedes it reset the time on each execution?
my $info = $exifTool->SetNewValuesFromFile($insp_path{$insp_ref}, 'DateTimeOriginal', 'Model'); # attempting to use the .insp file as the source for DateTimeOriginal
Date/Time Original Camera CameraXX/FileName
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016.insp
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
zCKAvid:EXIF-tags-from-.insp-into-jpeg charleskahn$ perl /Users/charleskahn/Documents/GitHub/EXIF-tags-from-.insp-into-jpeg/exif_change.pl
=================== go through screenshots under /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio/
=========================== screenshot #1 from .insp to .jpeg =========================================================
Date/Time Original Camera CameraXX/FileName
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016.insp
2022:03:18 09:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
zCKAvid:EXIF-tags-from-.insp-into-jpeg charleskahn$ perl /Users/charleskahn/Documents/GitHub/EXIF-tags-from-.insp-into-jpeg/exif_change.pl
=================== go through screenshots under /Volumes/CK_10TB/Downloads iMac/_media for unRAID/Insta360 ONE X/2022-03-18 - Toronto Comicon Day 1/_Studio/
=========================== screenshot #1 from .insp to .jpeg =========================================================
Date/Time Original Camera CameraXX/FileName
2022:03:18 09:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
2022:03:18 13:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016.insp
2022:03:18 05:41:21 Insta360 One2 Camera01/IMG_20220318_094121_00_016_2022-03-25_09-40-20_screenshot.jpg
Quote from: chuckkahn on April 01, 2022, 12:29:40 PM
Shouldn't SetNewValuesFromFile command that precedes it reset the time on each execution?
The time shift always applies to the original time, and your shift command overrides the time read by SetNewValuesFromFile.
If you want to copy a time with SetNewValuesFromFile, then write a shifted value, you could set the GlobalTimeShift API option (https://exiftool.org/ExifTool.html#GlobalTimeShift) before calling SetNewValuesFromFile. Of course, this would then apply to all date/time tags copied.
- Phil