/** * @param int $dw * @param bool $pdfLogo * @param int $pdfLogoSize */ public function showImg($dw = 500, $pdfLogo = false, $pdfLogoSize = 128) { $cachename = $this->fullpath . $dw . $this->pageid . ".png"; $cacheimg = $this->cachepath . '/' . $this->_nameFilter($cachename); if (class_exists('Imagick')) { try { $im = $this->_dataCacher($cachename); if ($im === false) { $this->_logToFile('File not in cache'); $im = new imagick($this->fullpath . '[' . $this->pageid . ']'); //$im->setSize($dw*2,$dw*2); $im->setImageFormat("png"); $im->adaptiveResizeImage($dw, $dw, true); // add a border to the image $color = new ImagickPixel(); $color->setColor("rgb(200,200,200)"); $im->borderImage($color, 1, 1); // draw the PDF icon on top of the PDF preview if ($pdfLogo) { $pdflogo = new Imagick($this->assetsPath . $this->deficon); $pdflogo->adaptiveResizeImage($pdfLogoSize, $pdfLogoSize); $im->compositeImage($pdflogo, Imagick::COMPOSITE_DEFAULT, 1, 1); } $this->_dataCacher($cachename, $im); $im->writeImage($cacheimg); } else { $this->_logToFile('File IS cached'); } header("Content-Type: image/png"); header("Content-Disposition: attachment; filename=\"" . $cachename . ".png\";"); $this->getRawFile($cacheimg, false, 'PNG', true); } catch (Exception $e) { return parent::showImg($dw); } } else { return parent::showImg($dw); } }