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


PHP imagick::scaleImage方法代码示例

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


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

示例1: pdftojpg

function pdftojpg($pdfFile, $jpgFile)
{
    /*  
     * imagemagick and php5-imagick required 
     * 
     * all options for imagick: 
     *           http://php.net/manual/fr/class.imagick.php 
     * 
     */
    $pdf_file = $pdfFile;
    $save_to = $jpgFile;
    $img = new imagick();
    //this must be called before reading the image, otherwise has no effect - "-density {$x_resolution}x{$y_resolution}"
    //this is important to give good quality output, otherwise text might be unclear
    $img->setResolution(200, 200);
    //read the pdf
    $img->readImage("{$pdf_file}[0]");
    //reduce the dimensions - scaling will lead to black color in transparent regions
    $img->scaleImage(1920, 1080);
    //set new format
    $img->setCompressionQuality(80);
    $img->setImageFormat('jpg');
    // -flatten option, this is necessary for images with transparency, it will produce white background for transparent regions
    $img = $img->flattenImages();
    //save image file
    $img->writeImages($save_to, false);
    //clean
    $img->clear();
    $img->destroy();
}
开发者ID:beemoon,项目名称:signage,代码行数:30,代码来源:function.php

示例2: 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

示例3: thumbnail

 function thumbnail($file, $width = '120')
 {
     $name = $this->_dir . DS . $file . '[0]';
     $im = new imagick($name);
     $im->setImageFormat('jpg');
     $im->scaleImage($width, 0);
     header('Content-Type: image/jpeg');
     echo $im;
 }
开发者ID:agus-ariyanto,项目名称:koio,代码行数:9,代码来源:pdf.php

示例4: createThumb

 private function createThumb($filePath, $fileName)
 {
     if (!extension_loaded('imagick')) {
         $errorMessage = "Error: 874";
         $this->error($errorMessage);
     }
     try {
         $fileNameWithoutExt = $fileName;
         $imagePreview = new imagick($this->uploadsDir . $fileName);
         $imagePreview->scaleImage(300, 0);
         $imagePreview->writeImage($this->thumbDir . $fileNameWithoutExt);
     } catch (ImagickException $e) {
         $errorMessage = "Error: 3435";
         $this->error($errorMessage);
     }
     return $fileNameWithoutExt;
 }
开发者ID:mawilliamson,项目名称:wordpress,代码行数:17,代码来源:file_uploader.php

示例5: imagick

 function get_texture($uuid, $x = null, $y = null)
 {
     $image = $this->ci->curl->simple_get($this->asset_service . $uuid);
     if ($image == null) {
         return null;
     }
     $im = new imagick();
     $im->readImageBlob($image);
     $im->setImageFormat("jpeg");
     if ($x != null && $y != null) {
         $im->scaleImage(200, 200, true);
     }
     return $im;
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:14,代码来源:SimianGrid.php

示例6: mysql_insert_id

ignore_user_abort(true);
set_time_limit(0);
// pixel cache max size
IMagick::setResourceLimit(imagick::RESOURCETYPE_MEMORY, 256);
// maximum amount of memory map to allocate for the pixel cache
IMagick::setResourceLimit(imagick::RESOURCETYPE_MAP, 256);
$mid = $_REQUEST['mid'];
mkdir("../upload/");
$fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
while (file_exists("../../magazine/" . $mid . "/" . $fname)) {
    $fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
}
move_uploaded_file($_FILES["file"]["tmp_name"], "../upload/" . $fname);
$img = new imagick();
$img->setResolution(500, 500);
$img->readimage("../upload/" . $fname);
$img->scaleImage(1000, 0);
$img->writeImage("../../magazine/" . $mid . "/" . $fname);
$img->scaleImage(200, 0);
$img->writeImage("../../magazine/" . $mid . "/small/" . $fname);
include "conn.php";
$sql = "SELECT `magazine`.`size` FROM `magazine` WHERE `magazine`.`id`=" . $mid . "";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$sql = "INSERT INTO `pages` (`magazine`, `name`, `position`) VALUES (" . $mid . ", '" . $fname . "', '" . $row[0] . "');";
mysql_query($sql, $conn);
$sql = "UPDATE `magazine` SET size=size+1 WHERE `magazine`.`id`='" . $mid . "'";
mysql_query($sql, $conn);
echo mysql_insert_id($conn);
mysql_close($conn);
开发者ID:byliuyang,项目名称:readerin.com,代码行数:30,代码来源:uploadPage.php

示例7: makethumbnail

function makethumbnail($page, $pdf_file, $thumb_path)
{
    $pdf_file = $pdf_file;
    $thumb_page = $page + 1;
    $img_save_to = $thumb_path . '/thumbnail_' . $thumb_page . '.jpg';
    $img = new imagick($pdf_file . "[" . $page . "]");
    $img->scaleImage(76, 100);
    $img->setImageFormat('jpg');
    $img = $img->flattenImages();
    $img->writeImage($img_save_to);
    chmod($img_save_to, 0777);
}
开发者ID:raymundcuizon,项目名称:lectureclip,代码行数:12,代码来源:api.php


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