本文整理汇总了PHP中imagick::setSize方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::setSize方法的具体用法?PHP imagick::setSize怎么用?PHP imagick::setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagick
的用法示例。
在下文中一共展示了imagick::setSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showThumb
/**
* Displays the thumbnail on the STDOUT
*
* @param bool $pdfLogo
* @param bool $showPreview
* @return bool
*/
public function showThumb($pdfLogo = false, $showPreview = true)
{
if ($this->thumbSize[0] < 64) {
$showPreview = false;
}
if ($showPreview) {
$divba = 3;
if ($this->thumbSize[0] >= 64) {
$pdfLogo = true;
}
if ($this->thumbSize[0] >= 200) {
$divba = 4;
}
$this->showImg($this->thumbSize[0], $pdfLogo, round($this->thumbSize[0] / $divba));
} else {
$cachename = $this->fullpath . $this->thumbSize[0] . $this->thumbSize[1] . $this->pageid . ".png";
$cacheimg = $this->cachepath . '/' . $this->_nameFilter($cachename);
if ($this->thumbSize[0] == 128 && class_exists('Imagick')) {
try {
if (!($im = $this->_dataCacher($cachename))) {
$this->_logToFile('File not in cache');
$im = new imagick($this->fullpath . '[' . $this->pageid . ']');
$im->setSize(128, 128);
$im->setImageFormat("png");
$im->adaptiveResizeImage($this->thumbSize[0], $this->thumbSize[1]);
// 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->setSize(10,10);
$pdflogo->adaptiveResizeImage(60, 60);
$im->compositeImage($pdflogo, Imagick::COMPOSITE_DEFAULT, 1, 1);
}
$this->_dataCacher($cachename, $im, true);
$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::showThumb();
}
} else {
return parent::showThumb();
}
}
}