function _load_data() { if (!$this->loaded) { if (!empty($this->filename)) { $this->data = imagick_readimage($this->filename); $this->loaded = true; } elseif (!empty($this->data)) { $this->data = imagick_blob2image($this->data); $this->loaded = true; } if ($this->loaded && ($t = imagick_failedreason($this->data))) { $this->data = NULL; } } }
/** * RaiseError Method - shows imagick Raw errors. * * @param string $message message = prefixed message.. * @param int $code error code * @return PEAR error object * @access protected */ function raiseError($message, $code = 0) { if (is_resource($this->imageHandle)) { $message .= "\nReason: " . imagick_failedreason($this->imageHandle) . "\nDescription: " . imagick_faileddescription($this->imageHandle); } return PEAR::raiseError($message, $code); }
/** * @param $newx * @param $newy * @return bool */ function resizeImage($newx, $newy) { if (!isset($this->imagehandle)) { $this->readimagefromstring(); } if (!isset($this->xsize)) { $this->getimageinfo(); } if ($this->xsize * $this->ysize == 0) { $this->repairimageinfo(); } if ($this->uselib == "imagick") { if (!imagick_scale($this->imagehandle, $newx, $newy, "!")) { $reason = imagick_failedreason($handle); $description = imagick_faileddescription($handle); // todo: Build in error handler in imagegallib exit; } } else { if ($this->uselib == "gd") { if ($this->gdversion >= 2.0) { $t = imagecreatetruecolor($newx, $newy); imagecopyresampled($t, $this->imagehandle, 0, 0, 0, 0, $newx, $newy, $this->xsize, $this->ysize); } else { $t = imagecreate($newx, $newy); $this->ImageCopyResampleBicubic($t, $this->imagehandle, 0, 0, 0, 0, $newx, $newy, $this->xsize, $this->ysize); } $this->imagehandle = $t; } } // fill $this->image for writing or output $this->writeimagetostring(); // reget sizes $this->getimageinfo(); //set new sizes $this->xsize = $newx; $this->ysize = $newy; return true; }
function bilder($width,$height,$dest) { //Wenn auf dem Server die php_imagick nicht installiert werden kann: //$rc=@exec("/usr/bin/convert -resize ".$width."x".$height." tmp/tmp.file_org tmp/tmp.file_$dest",$aus,$rc2); //if ($rc2>0) { echo "[Bildwandeln: $image.$dest]<br>"; return false; }; if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; }; $handle=imagick_readimage("./tmp/tmp.file_org"); if (!$handle) { $reason = imagick_failedreason( $handle ) ; print "Lesen: $reason<BR>\n" ; flush(); return false; } if (!imagick_resize( $handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) { $reason = imagick_failedreason( $handle ) ; print "Resize: $reason<BR>\n" ; flush(); return false; } if (!imagick_writeimage( $handle,"./tmp/tmp.file_$dest")) { $reason = imagick_failedreason( $handle ) ; print "Schreiben: $reason<BR>\n" ; flush(); return false; } return true; }
function bilder($width, $height, $dest) { if (!function_exists("imagick_readimage")) { echo "Imagick-Extention nicht installiert"; return false; } $handle = imagick_readimage("./tmp/tmp.file_org"); if (!$handle) { $reason = imagick_failedreason($handle); print "Lesen: {$reason}<BR>\n"; flush(); return false; } if (!imagick_resize($handle, $width, $height, IMAGICK_FILTER_UNKNOWN, 0)) { $reason = imagick_failedreason($handle); print "Resize: {$reason}<BR>\n"; flush(); return false; } if (!imagick_writeimage($handle, "./tmp/tmp.file_{$dest}")) { $reason = imagick_failedreason($handle); print "Schreiben: {$reason}<BR>\n"; flush(); return false; } 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); } }
public function getError() { return imagick_failedreason($this->img); }
/** * エラー終了 * * エラー終了します。 * * @param string $func コール元のメソッド名 * @param string $msg エラーメッセージ * * @return void * @throws BEAR_Img_Adapter_Magick_Exception */ private function _thisError($func, $msg = null) { //エラーヘッダー $reason = is_resource($this->image) ? imagick_failedreason($this->image) : "no image resource"; $description = is_resource($this->image) ? imagick_faileddescription($this->image) : "no image resource"; $isResource = is_resource($this->image) ? 'true' : 'false'; $msg .= 'iMagcik Error:' . $msg; $info = array('func' => $func, 'isResource' => $isResource, 'reason' => $reason, 'description' => $description); throw $this->_exception($msg, array('info' => $info)); }
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']); }