Coder Social home page Coder Social logo

google-metadata-matcher's People

Contributors

argothiel avatar greegko avatar sashas777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

google-metadata-matcher's Issues

Why does the file size increase?

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'

image fIle is truncated Error

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)

Script crashes at 1%


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?

Issue with some files "ValueError: "dump" got wrong type of exif value. 37500 in Exif IFD. Got as <class 'tuple'>"

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'>.

Given data isn't JPEG

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.

Skip GPS data if values are 0

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
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.