Comments (9)
Hi @Themandunord,
Thanks for noticing that. 😄.
I've included an additional param so that you can customize the output now.
from compress.js.
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.
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.
@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.
const base64 = canvas.toDataURL('image/jpeg', quality)
breaks the gif
from compress.js.
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.
You're right :/
image/webp can be animated, but only chrome supported this format.
from compress.js.
:) I believe in near future the support for other images will be better.
from compress.js.
If this is no longer an issue, can you close it?
from compress.js.
Related Issues (13)
- How to use this? HOT 1
- Exif orientation support broken with Safari 13.1 (iOS and Desktop) HOT 3
- Cropp error
- Facing issue in importing nextjs HOT 5
- Error when running jest HOT 2
- Upgrading from 1.2.2 to 2.0.0 on NextJS 14.2.3 App throws 'window not defined error' HOT 3
- https://cdn.jsdelivr.net/gh/alextanhongpin/compress.js/build/index.js HOT 3
- Transparency lost on png images HOT 2
- Rotate image on loading from mobile devices. HOT 5
- Make it clearer that units are decimal multiples of bytes HOT 2
- File size from base64 calculation HOT 2
- Fork
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compress.js.