Imagick::setCompression()函數是PHP中的內置函數,用於設置對象的默認壓縮類型。
用法:
bool Imagick::setCompression( int $compression )
參數:此函數接受單個參數$compression,該參數持有與Imagick::COMPRESSION_ *常量之一匹配的整數。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的Imagick::setCompression()函數:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/20190823154611/geeksforgeeks24.png');
// Get the Compression
$compression = $imagick->getCompression();
echo $compression;
?>
輸出:
0 (which corresponds with imagick::COMPRESSION_UNDEFINED)
程序2:
<?php
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/20190823154611/geeksforgeeks24.png');
// Set the Compression
$imagick->setCompression(5);
// Get the Compression
$compression = $imagick->getCompression();
echo $compression;
?>
輸出:
5 (which corresponds with imagick::COMPRESSION_JPEG)
參考: https://www.php.net/manual/en/imagick.setcompression.php
相關用法
- PHP Imagick linearStretchImage()用法及代碼示例
- PHP Imagick colorFloodfillImage()用法及代碼示例
- PHP Imagick morphImages()用法及代碼示例
- PHP Imagick levelImage()用法及代碼示例
- PHP Imagick setImageDispose()用法及代碼示例
- PHP Imagick profileImage()用法及代碼示例
- PHP Imagick coalesceImages()用法及代碼示例
- PHP Imagick identifyFormat()用法及代碼示例
- PHP Imagick smushImages()用法及代碼示例
- PHP Imagick functionImage()用法及代碼示例
- PHP Imagick readImageBlob()用法及代碼示例
- PHP Imagick addImage()用法及代碼示例
- PHP Imagick colorizeImage()用法及代碼示例
- PHP Imagick clear()用法及代碼示例
- PHP Imagick getPage()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | Imagick setCompression() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。