- PHP 手册
- 函数参考
- 图像生成和处理
- ImageMagick
- Imagick
Imagick::valid
(PECL imagick 2, PECL imagick 3)
Imagick::valid — Checks if the current item is valid
说明
public Imagick::valid(): boolChecks if the current item is valid.
参数
此函数没有参数。
返回值
成功时返回 true
。
User Contributed Notes 1 note
up down 1 hyrumt at mediarain dot com ¶12 years ago
We found this method to be of value when checking most image file types. However, it does not appear to be rigorous enough to detect corrupt jpg files. We use the following for jpgs and validate() for everything else.
<?php
// check for the existence of the EOI segment header at the end of the file
if (0 !== fseek($file, -2, SEEK_END) || "\xFF\xD9" !== fread($file, 2)) {
fclose($file);
return FALSE;
}
?>
add a note
官方地址:https://www.php.net/manual/en/imagick.valid.php