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

Is it possible to change .png to .jpeg? #13

Open
stefek99 opened this issue Aug 11, 2013 · 2 comments
Open

Is it possible to change .png to .jpeg? #13

stefek99 opened this issue Aug 11, 2013 · 2 comments

Comments

@stefek99
Copy link

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

@gangli2010
Copy link

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.

@tareqlol-zz
Copy link

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

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

3 participants