本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
示例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);
}