Martyn Ball
Martyn Ball

Reputation: 4895

Display thumbnail image but print full_res using generateimage.php?url=

I have a page which will display photos. I want it to load the thumbnail version of the photo, but when I come to print it should display the highres version.

The photo's are loaded using PHP (imagecreatefromjpeg).

src=\"php/generateimage.php?imgname=".$_SESSION['ROOT_PATH']."data/images/".$value2['location']."&restraint=".$restraint."\"

I have found that by using "display:none" the generateimage.php is not creating the image for print. And when I come to print them, which changes the images to "display:block-inline" the images simply are not available.

Using "visibility:hidden" still loads the images into memory which slows the computer down which is why I don't really want to display them before printing.

I hope this makes sense?

Upvotes: 2

Views: 119

Answers (1)

Dave Chen
Dave Chen

Reputation: 10975

Why not open a new window, load the image, then initiate the print?

<img src="http://lorempixel.com/output/food-q-g-640-480-8.jpg"><br>
<button onclick="printImage();">Print</button>
<script>
function printImage() {
    var popup = window.open();
    var img = popup.document.createElement("img");
    img.src = "http://lorempixel.com/output/food-q-c-640-480-8.jpg";
    img.onload = function() {
        popup.print();
        popup.close();
    };
    popup.document.body.appendChild(img);
}
</script>

Fiddle (Instead of low quality and high quality, it's gray-scale and color)

Upvotes: 1

Related Questions