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

Image Orientation meta info are removed with all possible configuration #115

Closed
realamirhe opened this issue Feb 10, 2021 · 6 comments
Closed

Comments

@realamirhe
Copy link

realamirhe commented Feb 10, 2021

First of all THANKS FOR THIS GREAT PACKAGE

Describe the bug
By all closed issues about Image Orientation change, it seems to have a little problem of saving image meta info for sample image in the demo page

To Reproduce
I download the image ant rotate it 90 deg to the right

  1. Input image (original image)
  2. Output image (compressed image)
  3. Output image (compressed image) [checkOrientation=false]
  4. Output image (compressed image) [strict=false]
  5. Output image (compressed image) [checkOrientation=false & strict=false]

Upload each image in metapicz and check the EXIF section

Expected behavior
For the original Image, the EXIF section is like

Orientation Horizontal (normal)
XResolution 72
YResolution 72
ResolutionUnit inches
ExifVersion 0210
FlashpixVersion 0100
ColorSpace sRGB
ExifImageWidth 600
ExifImageHeight 500

But for the rest of the configuration, no EXIF information can be detected from the image

EXIF data not found.

For the 2 and 4 configurations, we must get EXIF information the same as original, I guess

Screenshots
image

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu]
  • Browser [chrome]
  • Version [ 88.0.4324.96]

Additional context
All other options remain the same as default options presented in demo page e.g. quality: 0.8.

Is there any way to save orientation without extracting it separately like the solution posted in #65?
I also check all related Issues: #10 #56 #63 #64 #65 #88

@fengyuanchen
Copy link
Owner

It is designed like this and cannot be changed. The Exif information will be cleared always when the strict option is set to false.

@fengyuanchen
Copy link
Owner

Exactly, the Compressor.js uses the Browser's native canvas.toBlob API to do the compression work, which means all the Exif information are removed by the canvas.toBlob, and it is a native behaviour that cannot be changed.

@realamirhe
Copy link
Author

Thank you @fengyuanchen,
In type 2 Output image (compressed image); I used checkOrientation=true & strict=true .
Should all Exif information be removed in this type too?

@fengyuanchen
Copy link
Owner

Please read the documentation about the strict option carefully.

@realamirhe
Copy link
Author

Let's wrap up everything, I guess I couldn't tell properly what was the problem.

I change the orientation of the image, So I want a method to keep its orientation even after compression.
As far as I know by documentation

Strict Mode keeps original image instead of compressed one
if compression image doesn't satisfy the option we put on width, height , mimeType, minWidth and minHeight.
for example, if the image of 400x20 compresses to 400x40 we use the original image instead if strict mode is true.

checkOrientation
if checkOrientation = true then the orientation of the image is stored and applied after compression.

there are two Notes:

Don't trust this all the time as some JPEG images have incorrect (not standard) Orientation values.
I trust it, it was a demo image and I checked its orientation EXIF before compression.

If the size of target image is too large (e.g., greater than 10 MB), you should disable this option to avoid out-of-memory crash.
The image size was not greater than 10 MB, hence we hope to have no memory issue.


I brute force on all the possible combinations of strict and checkOrientation on the issue I asked, and all of them remove the orientation.

It is designed like this and cannot be changed. The Exif information will be cleared always when the strict option is set to false.
Although It wasn't clear by documentation, you said if strict=false then all Exif information will be cleared

what you said seemed different from documentation, but if consider it as a true statement, so I hope the strict=true with one possible value for checkOrientation gonna keep the orientation. One checkOrientation=true (probably this one by doc) or one with checkOrientation=false.

I think all the process I've taken was meaningful, although it was not very smart.

The only solution I think gonna work, is to keep the EXIF on our side and apply that after compression.
If this is the case, I guess its probably better to mention it more clearly in the documentauton.

@fengyuanchen
Copy link
Owner

Just one new note for this:

The image's Exif information will be removed after compressed, so if you need the Exif information, you may need to upload the original image as well.

fengyuanchen added a commit that referenced this issue Feb 17, 2021
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