ImageMagick 如何从相对路径 WampServer64 读取图像

时间:2020-12-27 13:34:10

标签: imagick

我正在使用

针对 WampServer64 安装测试 php_imagick 版本 3.4.4.7.4
<?php
/* Create the Imagick object */
$im = new Imagick();
 
/* Read the image file */
try {
    $im->readImage( "test.jpg" );
} catch( \ImagickException $e ) {
    die( $e );
}
/* Thumbnail the image ( width 100, preserve dimensions ) */
$im->thumbnailImage( 100, null );
 
/* Write the thumbail to disk */
$im->writeImage( 'th_test.png' );
 
/* Free resources associated to the Imagick object */
$im->destroy();

它导致引发 ImagickException 没有这样的文件或目录。该文件与 php 文件位于同一文件夹中。 当我用绝对路径替换“test.jpg”时,代码有效,但 writeImage 处的结果文件最终位于文件夹 C:\wamp64\bin\apache\apache2.4.41

这是正常行为吗?我在 https://www.php.net/manual/en/imagick.readimage.php 中没有看到路径应该是绝对的。这是 WampServer64 的怪癖吗?

0 个答案:

没有答案