canvasResize icon indicating copy to clipboard operation
canvasResize copied to clipboard

Is it possible to change .png to .jpeg?

Open stefek99 opened this issue 11 years ago • 2 comments

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

stefek99 avatar Aug 11 '13 22:08 stefek99

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.

gangli2010 avatar Nov 04 '13 17:11 gangli2010

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

tareqlol-zz avatar May 08 '15 08:05 tareqlol-zz