greegko / google-metadata-matcher Goto Github PK
View Code? Open in Web Editor NEWGoogle Photos takeout metadata merger
Google Photos takeout metadata merger
I'm seeing a significant increase in the file size when not using the optimize flag. In the below example, the file jumped from 246K to 976K. Why is the file so much larger?
$ls -lhd Takeout/Google\ Photos/Photos\ from\ 2009/IMG_7415*
-rwxrwxrwx+ 1 aciccarello users 246K Feb 22 07:37 'Takeout/Google Photos/Photos from 2009/IMG_7415.JPG'
-rwxrwxrwx+ 1 aciccarello users 915 Feb 22 07:37 'Takeout/Google Photos/Photos from 2009/IMG_7415.JPG.json'
$ ls -lhd Photos/Photos\ from\ 2009/IMG_7415*
-rwxrwxrwx+ 1 aciccarello users 976K Jul 19 2009 'Photos/Photos from 2009/IMG_7415.jpg'
If possible, could the code be updated to extract the "description" from the JSON and merge it info into the photo.jpg file?
Great utility!!
Im runnning on Windows 11 with Python 3.12 installed.
I have a particular folder which contains 312 photos (625 including jsons). Some of it went through but the rest pushes out this following unhandled exception and exits the app.
Traceback (most recent call last):
File "window.py", line 24, in
File "main.py", line 60, in mainProcess
File "PIL\Image.py", line 901, in convert
File "PIL\ImageFile.py", line 251, in load
OSError: image file is truncated (17 bytes not processed)
python3 merge_metadata.py /mnt/DISK2/Takeout/GooglePhotos /mnt/DISK2/googlephotos_fixed/
Total images found: 35331
Traceback (most recent call last):--------------------------------------------------------------------| 0.1%
File "/home/yurividal/google-metadata-matcher/src/merge_metadata.py", line 26, in <module>
processFolder(args.source_folder, args.edited_word, args.optimize, args.output_folder, args.max_dimension)
File "/home/yurividal/google-metadata-matcher/src/process_folder.py", line 65, in processFolder
orientation = image_exif[OrientationTagID]
File "/home/yurividal/.local/lib/python3.10/site-packages/PIL/Image.py", line 3859, in __getitem__
return self._data[tag]
KeyError: 274
Any ideas what could be happening here?
I'm not sure why I'm getting this error when I run the code. What helps is if I find the file in question and then "resize" the file (but putting 100% in the dimensions so I'm not actually resizing it).
Traceback (most recent call last):
File "[python]\lib\site-packages\piexif\_dump.py", line 267, in _value_to_bytes
four_bytes_over = b"" + raw_value
TypeError: can't concat tuple to bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "[python]\lib\site-packages\piexif\_dump.py", line 335, in _dict_to_bytes
length_str, value_str, four_bytes_over = _value_to_bytes(raw_value,
File "[python]\lib\site-packages\piexif\_dump.py", line 269, in _value_to_bytes
raise ValueError("Got invalid type to convert.")
ValueError: Got invalid type to convert.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Photos\google-metadata-matcher-master\google-metadata-matcher-master\src\merge_metadata.py", line 26, in <module>
processFolder(args.source_folder, args.edited_word, args.optimize, args.output_folder, args.max_dimension)
File "D:\Photos\google-metadata-matcher-master\google-metadata-matcher-master\src\process_folder.py", line 96, in processFolder
new_exif = adjust_exif(image.info["exif"], metadata)
File "D:\Photos\google-metadata-matcher-master\google-metadata-matcher-master\src\auxFunctions.py", line 135, in adjust_exif
return piexif.dump(exif_dict)
File "[python]\lib\site-packages\piexif\_dump.py", line 68, in dump
exif_set = _dict_to_bytes(exif_ifd, "Exif", zeroth_length)
File "[python]\lib\site-packages\piexif\_dump.py", line 339, in _dict_to_bytes
raise ValueError(
ValueError: "dump" got wrong type of exif value.
37500 in Exif IFD. Got as <class 'tuple'>.
There is an error that occurs for thumbnails in existing EXIF data.
In my case I added the line:
del exif_dict["thumbnail"]
In a new line after the line 127 of the file https://github.com/Greegko/google-metadata-matcher/blob/master/src/auxFunctions.py#L127
The error:
File "merge_metadata.py", line 26, in <module>
processFolder(args.source_folder, args.edited_word, args.optimize, args.output_folder, args.max_dimension)
File "/home/xxx/google_photos/metadata/src/process_folder.py", line 96, in processFolder
new_exif = adjust_exif(image.info["exif"], metadata)
File "/home/xxx/google_photos/metadata/src/auxFunctions.py", line 136, in adjust_exif
return piexif.dump(exif_dict)
File "/home/xxx/selenium/.venv/lib/python3.8/site-packages/piexif/_dump.py", line 91, in dump
thumbnail = _get_thumbnail(exif_dict["thumbnail"])
File "/home/xxx/selenium/.venv/lib/python3.8/site-packages/piexif/_dump.py", line 154, in _get_thumbnail
segments = split_into_segments(jpeg)
File "/home/xxx/selenium/.venv/lib/python3.8/site-packages/piexif/_common.py", line 10, in split_into_segments
raise InvalidImageDataError("Given data isn't JPEG.")
piexif._exceptions.InvalidImageDataError: Given data isn't JPEG.
It looks like Google outputs a default GPS coordinate of 0 for photos that don't have a location. Perhaps setting these values in the processed files could be skipped so it doesn't look like they have a location when they don't.
{
"geoData": {
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"latitudeSpan": 0.0,
"longitudeSpan": 0.0
},
"geoDataExif": {
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"latitudeSpan": 0.0,
"longitudeSpan": 0.0
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.