How to convert jpg image to png using javascript
If we have a look at the source from the JPG to PNG website which uses pure javascript to convert images from JPG to PNG. We see that they:
- Load the jpg image from file
- Create a canvas of the same size as the jpg
- Draw the jpg image covering the whole canvas
- Convert canvas to blob (if the image is small enough you can also use to
.toDataURL()
) - Download the blob