Q:

How to print image from browser using JavaScript

I'm able to print the webpage with the image using JavaScript. But it will print out the whole page with white spaces. What can I do to be able to just print out the Image using JavaScript?

A:

Load images on your page with just the necessary resolution you need.
In your javascript, pass the highest resolution image url to Print.js for a better print quality.
Import printjs library:  printJS('images/print-01-highres.jpg', 'image')
Check this JavaScript library which provide much more options to print from html view.
http://printjs.crabbly.com/
https://www.cssscript.com/javascript-library-printing-elements-page-print-js/

