JavaScript reduce the size and quality of image with based64 encoded code

I have the based64 encoded code of an image. Now I want to reduce the size and quality of the image. How can I do this in JavaScript or jQuery? Resolve here is the working code : Index.php Here is javascript code which worked form me Show.php file Answer You can use canvas, put image into it, scale it and get image src with new base64 code. Here’s the function doing that, it returns promise object, as image needs to be loaded (cached) first before drawing canvas out of it and getting its encoded src. Can be used like this: