canvasResize
canvasResize copied to clipboard
Is it possible to change .png to .jpeg?
Here is my use case:
- I have a png image roughly 2.7MB size
- I would like to reduce size client-size
- after drastic resize and compression it's still 1.1MB
- I believe it is still stored as .png
- image of the same size but with .jpeg extension after same resizing parameters is less than 100k.
Here are the available options: https://github.com/gokercebeci/canvasResize#options
Would introducing extension options be much work?
Happy 30 :) Michal
If you check the output base64 string/dataURL, you can see the image type is in the very beginning. I believe .png can be converted to .jpeg, because this is working for me. Btw, for large size image, there may be some bugs, and it also depends on the browser/os you are using. e.g. for IOS, there is sub-sampling problems.
canvas.toDataURL("image/jpeg", 1.0); this will create a base 64 images with the type you want.
For more info check this : https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL