Esempio n. 1
0
 /**
  * @param $format
  */
 function set_format($format)
 {
     $this->_load_data();
     $this->format = $format;
     if ($this->data) {
         imagick_convert($this->data, strtoupper(trim($format)));
     }
 }
Esempio n. 2
0
 /**
  * Displays image without saving and lose changes
  *
  * This method adds the Content-type HTTP header
  *
  * @param string type (JPG,PNG...);
  * @param int quality 75
  *
  * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
  * @access public
  */
 function display($type = '', $quality = null)
 {
     $options = is_array($quality) ? $quality : array();
     if (is_numeric($quality)) {
         $options['quality'] = $quality;
     }
     $quality = $this->_getOption('quality', $options, 75);
     imagick_setcompressionquality($this->imageHandle, $quality);
     if ($type && strcasecomp($type, $this->type) && !imagick_convert($this->imageHandle, $type)) {
         return $this->raiseError('Couldn\'t save image to file (conversion failed).', IMAGE_TRANSFORM_ERROR_FAILED);
     }
     if (!($image = imagick_image2blob($this->imageHandle))) {
         return $this->raiseError('Couldn\'t display image.', IMAGE_TRANSFORM_ERROR_IO);
     }
     header('Content-type: ' . imagick_getmimetype($this->imageHandle));
     echo $image;
     $this->free();
     return true;
 }
 /**
  * Write the image after being processed
  *
  * @param Asido_Image &$image
  * @return boolean
  * @access protected
  */
 function __write(&$tmp)
 {
     $ret = false;
     if ($tmp->save) {
         // convert, then save
         //
         imagick_convert($tmp->target, $this->__mime_map[$tmp->save]);
         $t = $this->__tmpfile();
         if (!imagick_writeImage($tmp->target, $t)) {
             return false;
         }
         $ret = @copy($t, $tmp->target_filename);
         @unlink($t);
     } else {
         // weird ... only works with absolute names
         //
         fclose(fopen($tmp->target_filename, 'w'));
         // no convert, just save
         //
         $ret = imagick_writeImage($tmp->target, realpath($tmp->target_filename));
     }
     // dispose
     //
     @$this->__destroy_source($tmp);
     @$this->__destroy_target($tmp);
     return $ret;
 }
Esempio n. 4
0
        $output = "";
        $query = "convert -size 420x594 {$tmpfname} -resize 420x594 +profile \"*\" png:- 2> /dev/null";
        $sh = popen($query, 'r');
        $data = "";
        while (!feof($sh)) {
            $data .= fread($sh, 4096);
        }
        pclose($sh);
        unlink($tmpfname);
    } else {
        /* Loading image */
        if (!($handle = imagick_blob2image($data))) {
            new log("view", "faxreport/faxreport", "", array(), "Cannot load fax image");
        }
        /* Converting image to PNG */
        if (!imagick_convert($handle, "PNG")) {
            new log("view", "faxreport/faxreport", "", array(), "Cannot convert fax image to png");
        }
        /* Resizing image to 420x594 and blur */
        if (!imagick_resize($handle, 420, 594, IMAGICK_FILTER_GAUSSIAN, 1)) {
            new log("view", "faxreport/faxreport", "", array(), "Cannot resize fax image");
        }
        /* Creating binary Code for the Image */
        if (!($data = imagick_image2blob($handle))) {
            new log("view", "faxreport/faxreport", "", array(), "Reading fax image image failed");
        }
    }
} else {
    /* force download dialog */
    header("Content-type: application/tiff\n");
    if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) || preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) {
 function set_format($format)
 {
     $this->format = $format;
     imagick_convert(&$this->data, strtoupper(trim($format)));
 }