本文整理匯總了PHP中Imagick::resizeImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::resizeImage方法的具體用法?PHP Imagick::resizeImage怎麽用?PHP Imagick::resizeImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::resizeImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: IMAGEN_tipo_normal
function IMAGEN_tipo_normal()
{
$escalado = 'IMG/i/m/' . $_GET['ancho'] . '_' . $_GET['alto'] . '_' . $_GET['sha1'];
$origen = 'IMG/i/' . $_GET['sha1'];
$ancho = $_GET['ancho'];
$alto = $_GET['alto'];
if (@($ancho * $alto) > 562500) {
die('La imagen solicitada excede el límite de este servicio');
}
if (!file_exists($escalado)) {
$im = new Imagick($origen);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(85);
$im->setImageFormat('jpeg');
$im->stripImage();
$im->despeckleImage();
$im->sharpenImage(0.5, 1);
//$im->reduceNoiseImage(0);
$im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$im->resizeImage($ancho, $alto, imagick::FILTER_LANCZOS, 1);
$im->writeImage($escalado);
$im->destroy();
}
$im = new Imagick($escalado);
$output = $im->getimageblob();
$outputtype = $im->getFormat();
$im->destroy();
header("Content-type: {$outputtype}");
header("Content-length: " . filesize($escalado));
echo $output;
}
示例2: copyResizedImage
static function copyResizedImage($inputFile, $outputFile, $width, $height = null, $crop = true)
{
if (extension_loaded('gd')) {
$image = new GD($inputFile);
if ($height) {
if ($width && $crop) {
$image->cropThumbnail($width, $height);
} else {
$image->resize($width, $height);
}
} else {
$image->resize($width);
}
return $image->save($outputFile);
} elseif (extension_loaded('imagick')) {
$image = new \Imagick($inputFile);
if ($height && !$crop) {
$image->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, true);
} else {
$image->resizeImage($width, null, \Imagick::FILTER_LANCZOS, 1);
}
if ($height && $crop) {
$image->cropThumbnailImage($width, $height);
}
return $image->writeImage($outputFile);
} else {
throw new HttpException(500, 'Please install GD or Imagick extension');
}
}
示例3: draw
public function draw(OsuSignature $signature)
{
parent::draw($signature);
if ($this->width != -1 || $this->height != -1) {
$this->image->resizeImage($this->width == -1 ? $this->image->getImageWidth() : $this->width, $this->height == -1 ? $this->image->getImageHeight() : $this->height, 1, $this->filter);
}
$signature->getCanvas()->compositeImage($this->image, $this->composite, $this->x, $this->y);
}
示例4: executeFilterImagick
/**
* Applies the image effect on an Imagick object. This function should be overridden by the effect.
* @param \Imagick The image object to work with
* @return \Imagick The new image object to use
*/
protected function executeFilterImagick(\Imagick $imageData)
{
$width = $imageData->getImageWidth();
$height = $imageData->getImageHeight();
$imageData->resizeImage(ceil($width / $this->pixelatePercentage), ceil($height / $this->pixelatePercentage), \Imagick::FILTER_LANCZOS, 0, false);
$imageData->resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 0, false);
return $imageData;
}
示例5: _resize
protected function _resize($width, $height)
{
if ($this->im->getNumberImages() > 1) {
$this->im = $this->im->coalesceImages();
foreach ($this->im as $animation) {
// $animation->setImagePage( $animation->getImageWidth(), $animation->getImageHeight(), 0, 0 );
$animation->resizeImage($width, $height, Imagick::FILTER_CUBIC, 0.5);
}
} else {
if ($this->im->resizeImage($width, $height, Imagick::FILTER_CUBIC, 0.5)) {
$this->width = $this->im->getImageWidth();
$this->height = $this->im->getImageHeight();
}
}
}
示例6: writeNewpic
function writeNewpic($old, $new)
{
$maxsize = 600;
$image = new Imagick($old);
if ($image->getImageHeight() <= $image->getImageWidth()) {
$image->resizeImage($maxsize, 0, Imagick::FILTER_LANCZOS, 1);
} else {
$image->resizeImage(0, $maxsize, Imagick::FILTER_LANCZOS, 1);
}
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(90);
$image->stripImage();
$image->writeImage($new);
$image->destroy();
}
示例7: createMissingThumbsAction
public function createMissingThumbsAction()
{
$this->initCommonParams($this->getRequest());
$this->outputMessage('[light_cyan]Creating missing thumbs.');
$dbAdapter = $this->getServiceLocator()->get('dbAdapter');
$apartments = $dbAdapter->createStatement('
SELECT ai.*, a.`name`
FROM `ga_apartment_images` ai LEFT JOIN `ga_apartments` a
ON ai.`apartment_id` = a.`id`
')->execute();
foreach ($apartments as $apartment) {
$this->outputMessage('[cyan]Looking into [light_blue]' . $apartment['name'] . '[cyan] images...');
for ($i = 1; $i <= 32; $i++) {
if ($apartment['img' . $i]) {
$imgPathComponents = explode('/', $apartment['img' . $i]);
$originalFileName = array_pop($imgPathComponents);
$originalFilePath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_APARTMENT . $apartment['apartment_id'] . '/' . $originalFileName;
$thumbFilePath = str_replace('_orig.', '_555.', $originalFilePath);
if (!file_exists($originalFilePath)) {
$this->outputMessage('[error] Original file for image ' . $i . ' is missing.');
} else {
if (file_exists($thumbFilePath)) {
$this->outputMessage('[light_blue] Thumb for image ' . $i . ' exists.');
} else {
$thumb = new \Imagick($originalFilePath);
$thumb->resizeImage(555, 370, \Imagick::FILTER_LANCZOS, 1);
$thumb->writeImage($thumbFilePath);
$this->outputMessage('[success] Added thumb for image ' . $i);
}
}
}
}
}
$this->outputMessage('Done!');
}
示例8: beforeSave
public function beforeSave($options = array())
{
if (isset($this->data['Candidate']['image']) && is_array($this->data['Candidate']['image'])) {
if (!empty($this->data['Candidate']['image']['size'])) {
$im = new Imagick($this->data['Candidate']['image']['tmp_name']);
$im->resizeImage(512, 512, Imagick::FILTER_CATROM, 1, true);
$path = WWW_ROOT . 'media';
$fileName = str_replace('-', '/', String::uuid()) . '.jpg';
if (!file_exists($path . '/' . dirname($fileName))) {
mkdir($path . '/' . dirname($fileName), 0777, true);
}
$im->writeImage($path . '/' . $fileName);
if (file_exists($path . '/' . $fileName)) {
$this->data['Candidate']['image'] = $fileName;
} else {
unset($this->data['Candidate']['image']);
}
} else {
unset($this->data['Candidate']['image']);
}
}
if (isset($this->data['Candidate']['name'])) {
$this->data['Candidate']['name'] = str_replace(array('&bull;', '•', '‧', '.', '•', '..'), '.', $this->data['Candidate']['name']);
}
return parent::beforeSave($options);
}
示例9: renderOriginalImage
function renderOriginalImage()
{
$imagick = new \Imagick(realpath("../imagick/images/FineDetail.png"));
$imagick->resizeImage($imagick->getImageWidth() * 4, $imagick->getImageHeight() * 4, \Imagick::FILTER_POINT, 1);
\header('Content-Type: image/png');
echo $imagick->getImageBlob();
}
示例10: thumbImage
public static function thumbImage($imgPath, $width, $height, $blur = 1, $bestFit = 0, $cropZoom = 1)
{
$dir = dirname($imgPath);
$imagick = new \Imagick(realpath($imgPath));
if ($imagick->getImageHeight() > $imagick->getImageWidth()) {
$w = $width;
$h = 0;
} else {
$h = $height;
$w = 0;
}
$imagick->resizeImage($w, $h, $imagick::DISPOSE_UNDEFINED, $blur, $bestFit);
$cropWidth = $imagick->getImageWidth();
$cropHeight = $imagick->getImageHeight();
if ($cropZoom) {
$imagick->cropImage($width, $height, ($imagick->getImageWidth() - $width) / 2, ($imagick->getImageHeight() - $height) / 2);
}
$direct = 'thumbs/';
$pathToWrite = $dir . "/" . $direct;
//var_dump($pathToWrite);
if (!file_exists($pathToWrite)) {
mkdir($pathToWrite, 0777, true);
}
$newImageName = 'thumb_' . basename($imgPath);
//var_dump($newImageName);
$imagick->writeImage($pathToWrite . 'thumb_' . basename($imgPath));
return $pathToWrite . $newImageName;
}
示例11: makeThumb
public function makeThumb($path, $W = NULL, $H = NULL)
{
$image = new Imagick();
$image->readImage($ImgSrc);
// Trasformo in RGB solo se e` il CMYK
if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
$image->transformImageColorspace(Imagick::COLORSPACE_RGB);
}
$image->profileImage('*', NULL);
$image->stripImage();
$imgWidth = $image->getImageWidth();
$imgHeight = $image->getImageHeight();
if ((!$H || $H == null || $H == 0) && (!$W || $W == null || $W == 0)) {
$W = $imgWidth;
$H = $imgHeight;
} elseif (!$H || $H == null || $H == 0) {
$H = $W * $imgHeight / $imgWidth;
} elseif (!$W || $W == null || $W == 0) {
$W = $H * $imgWidth / $imgHeight;
}
$image->resizeImage($W, $H, Imagick::FILTER_LANCZOS, 1);
/** Scrivo l'immagine */
$image->writeImage($path);
/** IMAGE OUT */
header('X-MHZ-FLY: Nice job!');
header(sprintf('Content-type: image/%s', strtolower($image->getImageFormat())));
echo $image->getImageBlob();
$image->destroy();
die;
}
示例12: resize
public function resize($file, $size = array('width' => 100, 'height' => 100), $type = 'png', $fixed = false)
{
$image = new Imagick($this->file);
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->setImageFormat($type);
if ($fixed === true) {
$newWidth = $size['width'];
$newHeight = $size['height'];
} else {
$imageprops = $image->getImageGeometry();
$width = $imageprops['width'];
$height = $imageprops['height'];
if ($width > $height) {
$newHeight = $size['height'];
$newWidth = $size['height'] / $height * $width;
} else {
$newWidth = $size['width'];
$newHeight = $size['width'] / $width * $height;
}
}
$image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 1);
$image->writeImage($file . '.' . $type);
$image->clear();
$image->destroy();
}
示例13: handleSave
/**
* @param Asset $asset
* @return string
*/
public function handleSave(Asset $asset)
{
$newImage = new \Imagick($asset->getUploadedFile()->getRealPath());
$asset->setHeight($newImage->getImageHeight());
$asset->setWidth($newImage->getImageWidth());
/** @var array $requiredImage */
foreach ($this->requiredImages as $requiredImage) {
$newImage = new \Imagick($asset->getUploadedFile()->getRealPath());
$newFilename = pathinfo($asset->getFilename(), PATHINFO_FILENAME) . '-' . $requiredImage['name'] . '.' . pathinfo($asset->getFilename(), PATHINFO_EXTENSION);
$imageWidth = $newImage->getImageWidth();
$imageHeight = $newImage->getImageHeight();
$isLandscapeFormat = $imageWidth > $imageHeight;
$orientation = $newImage->getImageOrientation();
$newImage->setCompression(\Imagick::COMPRESSION_JPEG);
$newImage->setImageCompressionQuality($requiredImage['quality']);
if ($isLandscapeFormat) {
$desiredWidth = $requiredImage['long'];
$newImage->resizeImage($desiredWidth, 0, \Imagick::FILTER_LANCZOS, 1);
if (isset($requiredImage['short']) && boolval($requiredImage['crop']) == true) {
$newImage->cropImage($desiredWidth, $requiredImage['short'], 0, 0);
} else {
$newImage->resizeImage(0, $requiredImage['short'], \Imagick::FILTER_LANCZOS, 1);
}
} else {
$desiredHeight = $requiredImage['long'];
$newImage->resizeImage(0, $desiredHeight, \Imagick::FILTER_LANCZOS, 1);
if (isset($requiredImage['short']) && boolval($requiredImage['crop']) == true) {
$newImage->cropImage($requiredImage['short'], $desiredHeight, 0, 0);
} else {
$newImage->resizeImage($requiredImage['short'], 0, \Imagick::FILTER_LANCZOS, 1);
}
}
/**
* This unfortunately kills the orientation. Leave EXIF-Info for now.
*
* $newImage->stripImage();
* $newImage->setImageOrientation($orientation);
*/
$this->assetStorage->uploadFile($newFilename, $newImage);
$subAsset = new SubAsset();
$subAsset->setFilename($newFilename);
$subAsset->setType($requiredImage['name']);
$subAsset->setHeight($newImage->getImageHeight());
$subAsset->setWidth($newImage->getImageWidth());
$asset->addSubAsset($subAsset);
}
}
示例14: getOriginalImageResponse
public function getOriginalImageResponse()
{
$imagePath = $this->getOriginalImagePath();
$imagick = new \Imagick(realpath($imagePath));
$imagick->resizeImage($imagick->getImageWidth() * 4, $imagick->getImageHeight() * 4, \Imagick::FILTER_POINT, 1);
header('Content-Type: image/png');
echo $imagick->getImageBlob();
}
示例15: resize
/**
* {@inheritdoc}
*
* @return ImageInterface
*/
public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED)
{
try {
$this->imagick->resizeImage($size->getWidth(), $size->getHeight(), $this->getFilter($filter), 1);
} catch (\ImagickException $e) {
throw new RuntimeException('Resize operation failed', $e->getCode(), $e);
}
return $this;
}