I'm running a server on Debian (Debian GNU/Linux 7) with php (5.4.35-0+deb7u2) and Apache.
I'm creating an API with Laravel, and i have a problem when i upload a file that Imagick can't use.
Code: Select all
static function createThumbWithHash($filePath, $fileHash) {
try
{
$im = new \imagick();
$im->setResourceLimit(\imagick::RESOURCETYPE_MEMORY, 1024);
$im->setResourceLimit(\imagick::RESOURCETYPE_MAP, 256);
$im->setResourceLimit(\imagick::RESOURCETYPE_AREA, 1512);
$im->setResourceLimit(\imagick::RESOURCETYPE_FILE, 768);
$im->setResourceLimit(\imagick::RESOURCETYPE_DISK, -1);
$tmpFile = tempnam(sys_get_temp_dir(), "thumb_");
$im->readImage($filePath);
$im->setImageFormat('jpg');
//Scale the image
$im->thumbnailImage(200, 200, true);
//Write the new image to a file
$im->writeImage($tmpFile);
} catch (ErrorDelegate $e) {
Log::info("getThumbHash: ".$e->getMessage());
return Response::json(array("error" => "Not image", "id" => "4", "desc" => "not image"), 418);
}
catch (Exception $e){
Log::info("getThumbHash: Unknown Error: " . $e->getMessage());
return Response::json(array("error" => "Unknown", "id" => "5", "desc" => "Unknown", "ErrorLevel" => "Error"), 418);
}
if (!self::moveFileToHash($tmpFile, $fileHash, "thumbnail"))
return false;
return true;
}
Code: Select all
$im->readImage($filePath);
Can you help me guys?
thanks ♥