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

Support MPO #11

Closed
rallant92 opened this issue Feb 20, 2016 · 7 comments
Closed

Support MPO #11

rallant92 opened this issue Feb 20, 2016 · 7 comments

Comments

@rallant92
Copy link

Almost all of my jpeg pictures from various cameras aren't compressing:

picopt -r *
Didn't optimize any files.

Stepping through the code the file is being recognized by PIL as MPO. These are jpeg files with a smaller photo embedded as a thumbnail, commonly done by cameras to speed viewing.

Here's some discussion:
python-pillow/Pillow#1138

  1. Can picopt be updated to compress these jpg files? I have tried jpegrescan and it successfully compresses the files.
  2. Figuring this out was a PITA because the error message is not helpful:
picopt -r P1000223.JPG
Didn't optimize any files.

Can picopt better describe why it won't optimize the file, at least when a single file targeted? Maybe something like one of "Not an image or "Image type foo not recognized"

@ajslater
Copy link
Owner

shouldn't be hard at all. But could you attach an unoptimized test MPO file to this issue report for me?

@rallant92
Copy link
Author

I've added a jpeg that does't optimize. My software to resize it smaller also strips the EXIF info, and therefore fails to demonstrate the problem. I"m hoping this comment system also doesn't strip the info.

p1020437

@ajslater
Copy link
Owner

Downloading it saves it as a .jpg and picopt/PIL detects it as type JPEG and then mozjpeg compresses it by 3.54%.

Maybe take your MPO file and conceal it in a zip or tarball so it's not processed by github.

@ajslater
Copy link
Owner

unreproduceable

@ajslater
Copy link
Owner

I just replicated this exact issue with some GoPro files that the camera exports with the .JPG suffix but PIL recognizes them as ANIMATED_MPO.

@ajslater ajslater reopened this Feb 22, 2020
@ajslater
Copy link
Owner

ajslater commented May 9, 2022

I'd like to work on this, but I'm searching for a tool that explodes MPO files without losing any JPEG fidelity and a tool that creates MPO files from multiple JPEGS.

The python Pillow library can read MPOs, but it lacks a facility for saving these JPEGS without re-encoding them.
Pillow cannot create MPOs.

@ajslater ajslater changed the title Doesn't compress many jpg from cameras Support MPO May 9, 2022
@ajslater
Copy link
Owner

picopt 4.0.0 now supports converting MPOs to regular JPEGS if and only if the MPO has a "Baseline MP Primary Image" tagged.

MPOs contain a series of JPEGS and are used for many different purposes. I think the original conception was for stereo images. For stereo images there is a left and right JPEG, but no primary jpeg. Picopt should not convert these files.

Probably the largest actual usage of MPO is storing thumbnails inside the same file as the primary image. This is frequently done by digital cameras. When you convert MPOs to JPEG with picopt, the primary image is extracted and losslessly optimized and the thumbnails are discarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants