예제 #1
0
파일: Imagick2.php 프로젝트: joeymetal/v1
 /**
  * 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);
 }
예제 #2
0
 /**
  * @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;
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 public function getErrorDescription()
 {
     return imagick_faileddescription($this->img);
 }
예제 #5
0
 /**
  * エラー終了
  *
  * エラー終了します。
  *
  * @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));
 }
예제 #6
0
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']);
}