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;
}
?>
Imagick::valid
(PECL imagick 2.0.0)
Imagick::valid — 現在のアイテムが有効かどうかを調べる
説明
bool Imagick::valid
( void
)
現在のアイテムが有効かどうかを調べます。
返り値
成功した場合に TRUE を返します。
hyrumt at mediarain dot com
11-Feb-2010 11:01
