GithubHelp home page GithubHelp logo

Comments (9)

alextanhongpin avatar alextanhongpin commented on August 20, 2024

Hi @Themandunord,

Thanks for noticing that. 😄.
I've included an additional param so that you can customize the output now.

from compress.js.

Themandunord avatar Themandunord commented on August 20, 2024

Thanks !

But I see one more issue.

If I upload a gif, the base64 is not a gif anymore. And the image don't move anymore.
Do you see the problem ?

from compress.js.

alextanhongpin avatar alextanhongpin commented on August 20, 2024

Hi @Themandunord,

Yes, I notice that the animation will be gone for images with the extension image/gif.

At the moment, I'll add a side note at the README.md to inform about this problem. I'll research on this issue now.

from compress.js.

Themandunord avatar Themandunord commented on August 20, 2024

@alextanhongpin For help, I use that :

function getBase64(img, callback) {
    const reader = new FileReader();
    reader.addEventListener('load', () => callback(reader.result));
    reader.readAsDataURL(img);
}

So the base64 image still move.

But I see that you convert your canvas to jpeg, so I think the problem come from here

from compress.js.

Themandunord avatar Themandunord commented on August 20, 2024

const base64 = canvas.toDataURL('image/jpeg', quality) breaks the gif

from compress.js.

alextanhongpin avatar alextanhongpin commented on August 20, 2024

According to the document here from Mozilla Developer,

var fullQuality = canvas.toDataURL("image/jpeg", 1.0);

A Number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp.
If this argument is anything else, the default value for image quality is used. The default value is 0.92. Other arguments are ignored.

It seems like I can only compress the image if they are of type image/jpeg or image/webp.

from compress.js.

Themandunord avatar Themandunord commented on August 20, 2024

You're right :/

image/webp can be animated, but only chrome supported this format.

from compress.js.

alextanhongpin avatar alextanhongpin commented on August 20, 2024

:) I believe in near future the support for other images will be better.

from compress.js.

alextanhongpin avatar alextanhongpin commented on August 20, 2024

If this is no longer an issue, can you close it?

from compress.js.

Related Issues (13)

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.