/** * Loads an image * * @param string $image filename * @return bool|PEAR_Error TRUE or a PEAR_Error object on error * @access public */ function load($image) { if (!($this->imageHandle = imagick_readimage($image))) { $this->free(); return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO); } if (imagick_iserror($this->imageHandle)) { return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO); } $this->image = $image; $result = $this->_get_image_details($image); if (PEAR::isError($result)) { return $result; } return true; }
function resize_file_IMagick(&$file, $create) { $handle = imagivk_readimage(getcwd() . '/' . $this->upload->path . '/' . $this->orgFileName); if (imagick_iserror($handle)) { $reason = imagick_failedreason($handle); $description = imagick_faileddescription($handle); echo "Handle failed!<br/>Reason: {$reason}<br/>Description: {$description}"; exit; } if (!imagick_resize($handle, $this->newWidth, $this->newHeight, IMAGICK_FILTER_UNKNOWN, 0, "!")) { $reason = imagick_failedreason($handle); $description = imagick_faileddescription($handle); echo "imagick_resize() failed!<br/>Reason: {$reason}<br/>Description: {$description}"; exit; } //Set the extension of the new file $ext = $this->GetNewfileExtension(); if (file_exists($this->upload->path . '/' . $file->name . "." . $ext) && $file->name . "." . $ext != $file->fileName && $this->upload->nameConflict == "uniq") { $file->setFileName($this->upload->createUniqName($file->name . ".jpg")); } if ($create == "image") { $fileName = $file->name . "." . $ext; @unlink($this->upload->path . '/' . $this->orgFileName); if (!imagick_writeimage($handle, getcwd() . '/' . $this->upload->path . '/' . $fileName)) { $reason = imagick_failedreason($handle); $description = imagick_faileddescription($handle); echo "imagick_writeimage() failed!<br/>Reason: {$reason}<br/>Description: {$description}"; exit; } $file->setFileName($fileName); } else { if ($this->pathThumb == "") { $this->pathThumb = $this->upload->path; } if ($this->naming == "suffix") { $fileName = $file->name . $this->suffix . "." . $ext; } else { $fileName = $this->suffix . $file->name . "." . $ext; } if (!imagick_writeimage($handle, getcwd() . '/' . $this->pathThumb . '/' . $fileName)) { $reason = imagick_failedreason($handle); $description = imagick_faileddescription($handle); echo "imagick_writeimage() failed!<br/>Reason: {$reason}<br/>Description: {$description}"; exit; } $file->setThumbFileName($fileName, $this->pathThumb, $this->naming, $this->suffix); } }
/** * @return bool */ function validhandle() { if (isset($this->imagehandle)) { if ($this->uselib == "imagick") { // seems not to work in imagick 0.95 aahrgh if (imagick_iserror($this->imagehandle)) { return false; } return true; } else { if ($this->uselib == "gd") { if (imagesx($this->imagehandle) == 0) { return false; } return true; } } } return false; }
function liberty_imagick0_rotate_image(&$pFileHash) { $ret = FALSE; if (!empty($pFileHash['source_file']) && is_file($pFileHash['source_file'])) { $iImg = imagick_readimage($pFileHash['source_file']); if (!$iImg) { $pFileHash['error'] = $pFileHash['name'] . ' ' . tra("is not a known image file"); } elseif (imagick_iserror($iImg)) { $pFileHash['error'] = imagick_failedreason($iImg) . imagick_faileddescription($iImg); } elseif (empty($pFileHash['degrees']) || !is_numeric($pFileHash['degrees'])) { $pFileHash['error'] = tra('Invalid rotation amount'); } else { if (!imagick_rotate($iImg, $pFileHash['degrees'])) { $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg); } if (!imagick_writeimage($iImg, $pFileHash['source_file'])) { $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg); } } } else { $pFileHash['error'] = "No source file to resize"; } return empty($pFileHash['error']); }