当前位置:8288分类目录 » 站长资讯 » 编程 » 文章详细

PHP - Manual: Imagick::resampleImage

来源:网络转载 浏览:30080次 时间:2023-11-08
Imagick::resetImagePage » « Imagick::render
  • PHP 手册
  • 函数参考
  • 图像生成和处理
  • ImageMagick
  • Imagick

Imagick::resampleImage

(PECL imagick 2, PECL imagick 3)

Imagick::resampleImage — Resample image to desired resolution

说明

public Imagick::resampleImage(
    float $x_resolution,
    float $y_resolution,
    int $filter,
    float $blur
): bool

Resample image to desired resolution.

参数

x_resolution

y_resolution

filter

blur

返回值

成功时返回 true

范例

示例 #1 Imagick::resampleImage()

<?php
function resampleImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));

    $imagick->resampleImage(200, 200, \Imagick::FILTER_LANCZOS, 1);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>
add a note

User Contributed Notes 3 notes

up down 1 simon6 years ago Please not that I had extremely high CPU usage using this function on Ubuntu linux 15.10. Switching to the resizeImage function fixed the problem. up down 1 bleighty at dvidshub dot net8 years ago Please note that blur of 1 should not affect the image if I'm understanding correctly from this page:
http://www.php.net/manual/en/imagick.resizeimage.php
up down -3 anagai at yahoo dot com10 years ago Lets say you want to reduce the resolution of uploaded images for the web.

The following will load a image at whatever resolution and resample it down to 72 dpi and save as a different file.

The dpi for setImageResolution() and resampleImage() should be whatever dpi your resampling too.

<?php
$image = new Imagick();
$image->readImage('image.jpg');
$image->setImageResolution(72,72);
$image->resampleImage(72,72,imagick::FILTER_UNDEFINED,0);
$image->writeImage('image72.jpg');
?>
add a note

官方地址:https://www.php.net/manual/en/imagick.resampleimage.php



8288分类目录声明:本站部分文章来源于网络,版权属于原作者所有。如有转载或引用文章/图片涉及版权问题,请联系我们处理.我们将在第一时间删除! 联系邮箱:tsk@qq.com

推荐网站

最新加入网站 TOP5

入站排行榜 TOP5