function __construct($image, $isfile = false) { if ($isfile) { $blob = imagick_readimage($image); parent::__construct($blob, false); } else { parent::__construct($image, false); $this->data = imagick_blob2image($image); } }
function resizethumb() { if ($this->thumb !== null) { $this->data = imagick_blob2image($this->thumb); $this->loaded = true; } else { $this->_load_data(); } if ($this->data) { return parent::resizethumb(); } }
/** * @return bool */ function readimagefromstring() { if (!isset($this->image)) { return false; } //avoid error messages if (isset($this->filetype)) { if (!$this->issupported($this->filetype)) { return false; } } if ($this->uselib == "imagick") { $this->imagehandle = imagick_blob2image($this->image); } else { if ($this->uselib == "gd") { $this->imagehandle = imagecreatefromstring($this->image); } } }
$temp = fopen($tmpfname, "w"); fwrite($temp, $data); fclose($temp); /* Read data written by convert */ $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"); } }