当前位置: 首页>>代码示例>>PHP>>正文


PHP imagick::thumbnailImage方法代码示例

本文整理汇总了PHP中imagick::thumbnailImage方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::thumbnailImage方法的具体用法?PHP imagick::thumbnailImage怎么用?PHP imagick::thumbnailImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imagick的用法示例。


在下文中一共展示了imagick::thumbnailImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makethumb

function makethumb($srcFile, $dstFile, $dstW, $dstH, $imwf = false)
{
    $im = new imagick($srcFile);
    $source_w = $im->getImageWidth();
    $source_h = $im->getImageHeight();
    if ($dstW === 0 && $dstH === 0) {
        $dstW = $source_w;
        $dstH = $source_h;
    } else {
        // 取得縮在此範圍內的比例
        $percent = getResizePercent($source_w, $source_h, $dstW, $dstH);
        $dstW = $source_w * $percent;
        $dstH = $source_h * $percent;
    }
    $im->thumbnailImage($dstW, $dstH);
    $im->writeImage($dstFile);
    $watermarkFile = './logo.png';
    if ($imwf && is_file($watermarkFile) && is_file($dstFile)) {
        $image = new imagick($dstFile);
        $watermark = new imagick($watermarkFile);
        $iWidth = $image->getImageWidth();
        $iHeight = $image->getImageHeight();
        $wWidth = $watermark->getImageWidth();
        $wHeight = $watermark->getImageHeight();
        if ($iHeight < $wHeight || $iWidth < $wWidth) {
            $watermark->scaleImage($iWidth, $iHeight);
            $wWidth = $watermark->getImageWidth();
            $wHeight = $watermark->getImageHeight();
        }
        $x = ($iWidth - $wWidth) / 2;
        $y = ($iHeight - $wHeight) / 2;
        $image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
        $image->writeImage($dstFile);
    }
}
开发者ID:FantasticThought,项目名称:tfsda,代码行数:35,代码来源:image_conver.php

示例2: pdftoimage

function pdftoimage($file, $page)
{
    $filepart = pathinfo($file);
    $save_to = $filepart['filename'] . ".jpg";
    $im = new imagick($file[$page - 1]);
    $im->thumbnailImage(800, 0);
    $im->setImageFormat('jpg');
    $im = $im->flattenImages();
    file_put_contents($save_to, $im);
}
开发者ID:bramleksono,项目名称:mobileid-SI,代码行数:10,代码来源:pdfoperation.php

示例3: isset

 function generate_certificate($user = null)
 {
     isset($user) or $user = $this->myUser;
     $elearning_user = elearning_user::get_instance($user->get_name(), elearning_mediathek::get_instance()->get_course()->get_id());
     if ($elearning_user->has_exam_passed()) {
         //generating cert
         $cert = new elearning_certificate();
         $filename_data = $cert->create_certificate($_SESSION["LMS_USER"]->get_login(), $_SESSION["LMS_USER"]->get_forename() . " " . $_SESSION["LMS_USER"]->get_surname(), $elearning_user->get_exam_sum_score(), $elearning_user->get_exam_sum_points(), date("d.m.Y"));
         //save cert to server
         $elearning_user->get_exam_cert()->set_content($filename_data);
         //save pdf to temp
         $login = $_SESSION["LMS_USER"]->get_login();
         $myFile = PATH_TEMP . "zertifikat_{$login}.pdf";
         $fh = fopen($myFile, 'w') or die("can't open file");
         fwrite($fh, $filename_data);
         fclose($fh);
         //chmod($myFile, 0777);
         //create Thumb
         //$command = "/opt/local/bin/convert $filename -geometry 550 -quality 80 jpg:$filename.jpg";
         putenv("MAGICK_TMPDIR=" . PATH_TEMP);
         $im = new imagick($myFile . '[0]');
         /* Convert to jpg */
         $im->setImageFormat("jpg");
         /* Thumbnail the image */
         $im->thumbnailImage(150, null);
         //save Thumb
         $elearning_user->get_exam_cert_preview()->set_content((string) $im);
         // delete file
         unlink($myFile);
     }
 }
开发者ID:rolwi,项目名称:koala,代码行数:31,代码来源:elearning_exam.class.php

示例4: imagick

 function _resizeImagick(&$model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $image->getImageFormat();
         } catch (Exception $e) {
             $thumbnailType = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}'), array($size, $pathInfo['filename']), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($thumbnailType);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
开发者ID:ryantology,项目名称:upload,代码行数:58,代码来源:upload.php

示例5: _resizeImagick

 public function _resizeImagick(Model $model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH, true);
         $imageGeometry = $image->getImageGeometry();
         $x = ($imageGeometry['width'] - $destW) / 2;
         $y = ($imageGeometry['height'] - $destH) / 2;
         $image->setGravity(Imagick::GRAVITY_CENTER);
         $image->extentImage($destW, $destH, $x, $y);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $imageFormat = $image->getImageFormat();
             // Fix file casing
             while (true) {
                 $ext = false;
                 $pieces = explode('.', $srcFile);
                 if (count($pieces) > 1) {
                     $ext = end($pieces);
                 }
                 if (!$ext || !strlen($ext)) {
                     break;
                 }
                 $low = array('ext' => strtolower($ext), 'thumbnailType' => strtolower($thumbnailType));
                 if ($low['ext'] == 'jpg' && $low['thumbnailType'] == 'jpeg') {
                     $thumbnailType = $ext;
                     break;
                 }
                 if ($low['ext'] == $low['thumbnailType']) {
                     $thumbnailType = $ext;
                 }
                 break;
             }
         } catch (Exception $e) {
             $this->log($e->getMessage(), 'upload');
             $thumbnailType = $imageFormat = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}', '{primaryKey}'), array($size, $pathInfo['filename'], $model->id), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($imageFormat);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
开发者ID:ederdsr,项目名称:civisindicadores,代码行数:84,代码来源:UploadBehavior.php

示例6: Document

}
$id = $_REQUEST['record'];
$document = new Document();
$document->retrieve($id);
$filename = $document->document_revision_id;
$filepath = "upload/{$filename}";
$document_name = $document->get_document_name($id);
// File típusának ellenőrzése
$image_formats = array('JPEG', 'GIF', 'PNG');
$finfo = new finfo();
$fileinfo = $finfo->file($filepath);
$fileinfo_array = explode(" ", $fileinfo);
if ($fileinfo_array[0] == 'PDF') {
    $im = new imagick($filepath . "[0]");
    $im->setImageFormat('png');
    $im->thumbnailImage(300, 0);
    header('Content-Type:image/png');
    ob_clean();
    flush();
    echo $im;
} elseif (!in_array($fileinfo_array[0], $image_formats)) {
    header('Content-Type:image/png');
    ob_clean();
    flush();
    readfile('custom/themes/default/images/unknown.png');
} else {
    //Kép Átméretezése
    $image_attrs = getimagesize("upload/{$filename}");
    $layout = "";
    if ($image_attrs[0] > $image_attrs[1]) {
        $twidth = 300;
开发者ID:summer11123,项目名称:DocumentPreview-1,代码行数:31,代码来源:GetImagePreview.php


注:本文中的imagick::thumbnailImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。