Imagick::hasPreviousImage()函數是PHP中的內置函數,用於檢查Imagick對象是否具有先前的圖像。如果Imagick對象具有多個圖像,則返回true,否則返回false。
用法:
bool Imagick::hasPreviousImage( void )
參數:該函數不接受任何參數。
返回值:如果對象在反向移動列表時具有更多圖像,則此函數返回TRUE,否則返回FALSE。
以下示例程序旨在說明PHP中的Imagick::hasPreviousImage()函數:
程序:該程序演示了hasPreviousImage()函數在多幅圖像和無多幅圖像的情況下的工作原理。
<?php
// String array containg path of images
$imagePaths = [
"https://www.geeksforgeeks.org/wp-content/uploads/gfg_200X200.png",
"https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-6.png"
];
// Create new Imagick object
$canvas = new Imagick();
$image = new Imagick(
'https://www.geeksforgeeks.org/wp-content/uploads/gfg_200X200.png');
foreach ($imagePaths as $imagePath) {
// Adding images in the canvas
$canvas->readImage($imagePath);
}
// The pointer points to second image
if($canvas->hasPreviousImage()) {
echo('$canvas has Multiple Images !!');
}
if($image->hasPreviousImage()) {
// With a single image
echo('$image has Multiple Images !!');
}
?>
輸出:
$canvas has Multiple Images !!
參考: https://www.php.net/manual/en/imagick.haspreviousimage.php
相關用法
- PHP Imagick getImageClipMask()用法及代碼示例
- PHP Imagick getImageChannelStatistics()用法及代碼示例
- PHP Imagick getImageCompose()用法及代碼示例
- PHP Imagick setImageClipMask()用法及代碼示例
- PHP Imagick getImageChannelExtrema()用法及代碼示例
- PHP Imagick setImageBorderColor()用法及代碼示例
- PHP Imagick setImageAlphaChannel()用法及代碼示例
- PHP Imagick haldClutImage()用法及代碼示例
- PHP Imagick getImageBackgroundColor()用法及代碼示例
- PHP Imagick getImageChannelDistortion()用法及代碼示例
- PHP Imagick setImageBluePrimary()用法及代碼示例
- PHP Imagick getImageBorderColor()用法及代碼示例
- PHP Imagick setImageBackgroundColor()用法及代碼示例
- PHP Imagick getImageChannelMean()用法及代碼示例
- PHP Imagick getImagesBlob()用法及代碼示例
注:本文由純淨天空篩選整理自piyush25pv大神的英文原創作品 PHP | Imagick hasPreviousImage() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。