/** * @return mixed */ function get_mimetype() { $this->_load_data(); if ($this->data) { return imagick_getmimetype($this->data); } }
/** * 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; }
function getimageinfo() { if ($this->uselib == "imagick") { $this->filetype = imagick_getmimetype($this->imagehandle); $this->xsize = imagick_getwidth($this->imagehandle); $this->ysize = imagick_getheight($this->imagehandle); } else { if ($this->uselib == "gd") { $this->xsize = imagesx($this->imagehandle); $this->ysize = imagesy($this->imagehandle); } } }
function get_mimetype() { return imagick_getmimetype($this->data); }
function liberty_imagick0_resize_image(&$pFileHash) { global $gBitSystem; $pFileHash['error'] = NULL; $ret = NULL; 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" ); $destFile = liberty_process_generic($pFileHash, FALSE); } elseif (imagick_iserror($iImg)) { // $pFileHash['error'] = imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg ); $destFile = liberty_process_generic($pFileHash, FALSE); } else { imagick_set_image_quality($iImg, $gBitSystem->getConfig('liberty_thumbnail_quality', 85)); $iwidth = imagick_getwidth($iImg); $iheight = imagick_getheight($iImg); if ($iwidth / $iheight > 0 && !empty($pFileHash['max_width']) && !empty($pFileHash['max_height'])) { // we have a portrait image, flip everything $temp = $pFileHash['max_width']; $pFileHash['max_height'] = $pFileHash['max_width']; $pFileHash['max_width'] = $temp; } $itype = imagick_getmimetype($iImg); // override $mimeExt if we have a custom setting for it if ($gBitSystem->isFeatureActive('liberty_thumbnail_format')) { $mimeExt = $gBitSystem->getConfig('liberty_thumbnail_format'); } else { list($type, $mimeExt) = explode('/', strtolower($itype)); } if ($mimeExt = preg_replace("!^(x-)?(jpeg|png|gif)\$!", "\$2", $mimeExt)) { $targetType = $mimeExt; $destExt = '.' . $mimeExt; } if (!$mimeExt || $mimeExt == 'jpeg') { $targetType = 'jpeg'; $destExt = '.jpg'; } if (!empty($pFileHash['max_width']) && !empty($pFileHash['max_height']) && ($pFileHash['max_width'] < $iwidth || $pFileHash['max_height'] < $iheight || $mimeExt != $targetType)) { // We have to resize. *ALL* resizes are converted to jpeg or png if (!empty($pFileHash['dest_file'])) { $destFile = $pFileHash['dest_file']; } else { $destFile = STORAGE_PKG_PATH . $pFileHash['dest_branch'] . $pFileHash['dest_base_name'] . $destExt; } $pFileHash['name'] = $pFileHash['dest_base_name'] . $destExt; // print " if ( !imagick_resize( $iImg, $pFileHash[max_width], $pFileHash[max_height], IMAGICK_FILTER_LANCZOS, 0.5, $pFileHash[max_width] x $pFileHash[max_height] > ) ) {"; // Alternate Filter settings can seen here http://www.dylanbeattie.net/magick/filters/result.html if (!imagick_resize($iImg, $pFileHash['max_width'], $pFileHash['max_height'], IMAGICK_FILTER_CATROM, 1.0, '>')) { $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg); } if (function_exists('imagick_set_attribute')) { // this exists in the PECL package, but not php-imagick $imagick_set_attribute($iImg, array("quality" => 1)); } if (!imagick_writeimage($iImg, $destFile)) { $pFileHash['error'] .= imagick_failedreason($iImg) . imagick_faileddescription($iImg); } $pFileHash['size'] = filesize($destFile); } else { // print "GENERIC"; $destFile = liberty_process_generic($pFileHash, FALSE); } } $ret = $destFile; } else { $pFileHash['error'] = "No source file to resize"; } return $ret; }