Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PNG EXIF data to mirror json argument data #72

Open
parlance-zz opened this issue Oct 14, 2022 · 5 comments
Open

Use PNG EXIF data to mirror json argument data #72

parlance-zz opened this issue Oct 14, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@parlance-zz
Copy link
Owner

This better attaches the generation parameters to the actual output image file.

Any code that reads the separated JSON files should be updated to instead pull data from this field, if it is present.

This data should be set in the encoded PNG bytes sent to the GRPC server for ad-hoc protocol extensions.

@parlance-zz parlance-zz self-assigned this Oct 14, 2022
@parlance-zz parlance-zz changed the title Use Request PNG field in EXIF data to mirror json argument data Use PNG EXIF data to mirror json argument data Oct 16, 2022
@parlance-zz
Copy link
Owner Author

cv2 imwrite / imencode do not appear to support EXIF data, need a workaround

@keturn
Copy link

keturn commented Oct 21, 2022

Support for image metadata is not nearly as widespread as I expected!

The best option I've found for EXIF so far is:

  • many file formats supported by PIL take an exif argument to their save method. But it takes the raw EXIF data and doesn't offer a great interface for working with it, so
  • piexif to serialize and deserialize that data.

piexif is in the process of transitioning to a new maintainer, and it looks like they could use some assistance/encouragement in getting things up and running: https://github.com/JEFuller/Piexif/projects/1

@parlance-zz
Copy link
Owner Author

parlance-zz commented Oct 21, 2022

@keturn - thanks for the tip!

I really want to avoid using PIL to do any of the image encoding, serialization, or disk io because in my testing the performance of nearly every function in PIL is extremely bad. It's bad enough that I would hold off until I can find another way to have cv2 write EXIF metadata...

@keturn
Copy link

keturn commented Oct 21, 2022

That bad? I would have assumed that PIL.Image.save ends up being a fairly thin wrapper between the byte array supplied by numpy to a platform-native image encoding library.

@parlance-zz
Copy link
Owner Author

parlance-zz commented Oct 21, 2022

That bad? I would have assumed that PIL.Image.save ends up being a fairly thin wrapper between the byte array supplied by numpy to a platform-native image encoding library.

It's the encoding for formats like PNG that really kill the performance. I'm sure if you were saving something like bmp or other uncompressed it might not be as bad. Bear in mind that I have users saving files that are upwards of 16384x16384 in some cases...

@parlance-zz parlance-zz pinned this issue Oct 21, 2022
@parlance-zz parlance-zz added the enhancement New feature or request label Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants