【发布时间】:2011-04-14 17:40:01
【问题描述】:
我正在尝试在眩晕服务中使用 Imagick 类
我有这个表格
<form action="thumb.php" method="post" enctype="multipart/form-data">
<p>
<label for="file">Select a file:</label>
<input type="file" name="userfile" id="file"> <br />
<button>Upload File</button>
<p>
</form>
还有这个 php
<?php
error_reporting(-1);
$imagePath = $_FILES["userfile"];
$thumbnailWidth = 100;
$thumbnailHeight = 100;
$srgbPath = 'thumb/sRGB_v4_ICC_preference.icc';
$image = new Imagick($imagePath);
$width = $image->getImageWidth();
$height = $image->getImageHeight();
$srgb = file_get_contents($srgbPath);
$image->profileImage('icc', $srgb);
$image->stripImage();
$image->setImageColorspace(Imagick::COLORSPACE_SRGB);
$fitWidth = ($thumbnailWidth / $width) < ($thumbnailHeight / $height);
$image->thumbnailImage(
$fitWidth ? $thumbnailWidth : 0,
$fitWidth ? 0 : $thumbnailHeight
);
$imagePathParts = pathinfo($imagePath);
$thumbnailPath = "thumb/miniaturas/".
$imagePathParts['filename'].'_'.
$thumbnailWidth.'x'.$thumbnailHeight.'.jpg';
$image->setImageCompressionQuality(90);
$image->writeImage($thumbnailPath);
echo $image;
$image->clear();
$image->destroy();
?>
我收到此错误:
致命错误:未捕获的异常“ImagickException”和消息“无法打开图像‘C:\Users\fel\VertrigoServ\www\login\main_image.jpg’:没有这样的文件或目录@error/blob.c/OpenBlob /2587' 在 C:\Users\fel\VertrigoServ\www\login\thumb.php:12 堆栈跟踪:#0 C:\Users\fel\VertrigoServ\www\login\thumb.php(12):Imagick-> __construct(Array) #1 {main} 在第 12 行的 C:\Users\fel\VertrigoServ\www\login\thumb.php 中抛出
我正在尝试打开位于桌面中的图像,但错误似乎在 localhost 粘贴中搜索:
`C:\Users\fel\VertrigoServ\www\login\main_image.jpg':
有什么想法吗?
如果我改变这个
$imagePath = $_FILES["userfile"];
到这里
$imagePath = 'thumb/main.jpg';
一切正常
谢谢
【问题讨论】: