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

GIF images are unexpectedly converted to PNG #78

Closed
Arkshine opened this issue Jan 23, 2020 · 8 comments
Closed

GIF images are unexpectedly converted to PNG #78

Arkshine opened this issue Jan 23, 2020 · 8 comments

Comments

@Arkshine
Copy link

Describe the bug
GIF image are converted to PNG and there is no documentation/setting about this behavior.

To Reproduce
Compress a GIF image.

Expected behavior
A compressed GIF image.

Screenshots
Before compression:
image

After compression:
image

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 79

Additional context
Code used:

new Compressor(file, {
  quality: 0.6,
  strict: true,
  mimeType: 'auto',
  checkOrientation: true,
  maxWidth: 1000,
  maxHeight: 1000,
  convertSize: 'Infinity',
  success(result) {
    console.log('before', file)
    console.log('after', result)
    //
  },
})
@pdt590
Copy link

pdt590 commented Feb 4, 2020

+1
I have same issue

@fengyuanchen
Copy link
Owner

Just set the mimeType option to image/gif or any other types.

@pdt590
Copy link

pdt590 commented Feb 24, 2020

@fengyuanchen
I checked on https://fengyuanchen.github.io/compressorjs/ but it did not work

image

@fengyuanchen
Copy link
Owner

Okey. It seems the image/gif type is not supported by the browser.

If the requested type is not image/png, but the returned value starts with data:image/png, then the requested type is not supported.
From https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL

@DmitryEfimenko
Copy link

what does it mean for us?
I'd think that if the compress.js can't handle a particular file format, then it should not modify the file type and just return the file as is

@mohammad5055
Copy link

mohammad5055 commented Feb 6, 2023

Have there been any updates on this?
@fengyuanchen

@alanhg
Copy link

alanhg commented Apr 5, 2023

So I think it's better to just go back to the original file, at least if you don't exceed the size limit, etc., and trigger the type conversion.

@fengyuanchen
Copy link
Owner

fengyuanchen commented Apr 5, 2023

what does it mean for us? I'd think that if the compress.js can't handle a particular file format, then it should not modify the file type and just return the file as is

It means: DON'T compress GIF images with Compressor.js as it does not support it.

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

6 participants