コード例 #1
0
 /**
  * Creates a new ImagickImageAdapter.
  */
 public function __construct()
 {
     $this->imagick = new \Imagick();
     // check if writing animated gifs is supported
     $version = $this->imagick->getVersion();
     $versionNumber = preg_match('~([0-9]+\\.[0-9]+\\.[0-9]+)~', $version['versionString'], $match);
     if (version_compare($match[0], '6.3.6') < 0) {
         $this->supportsWritingAnimatedGIF = false;
     }
 }
コード例 #2
0
ファイル: Image.php プロジェクト: pixelandtonic/Imagine
 /**
  * @param array  $options
  * @param string $path
  */
 private function prepareOutput(array $options, $path = null)
 {
     if (isset($options['format'])) {
         $this->imagick->setImageFormat($options['format']);
     }
     if (isset($options['animated']) && true === $options['animated']) {
         $format = isset($options['format']) ? $options['format'] : 'gif';
         $delay = isset($options['animated.delay']) ? $options['animated.delay'] : null;
         $loops = 0;
         if (isset($options['animated.loops'])) {
             $loops = $options['animated.loops'];
         } else {
             // Calculating animated GIF iterations is a crap-shoot: https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=23276
             // Looks like it started working around 6.8.8-3: http://git.imagemagick.org/repos/ImageMagick/blob/a01518e08c840577cabd7d3ff291a9ba735f7276/ChangeLog#L914-916
             $versionInfo = $this->imagick->getVersion();
             if (isset($versionInfo['versionString'])) {
                 preg_match('/ImageMagick ([0-9]+\\.[0-9]+\\.[0-9]+-[0-9])/', $versionInfo['versionString'], $versionInfo);
                 if (isset($versionInfo[1])) {
                     if (version_compare($versionInfo[1], '6.8.8-3', '>=')) {
                         $loops = $this->imagick->getImageIterations();
                     }
                 }
             }
         }
         $options['flatten'] = false;
         $this->layers->animate($format, $delay, $loops);
     } else {
         $this->layers->merge();
     }
     $this->applyImageOptions($this->imagick, $options, $path);
     // flatten only if image has multiple layers
     if ((!isset($options['flatten']) || $options['flatten'] === true) && count($this->layers) > 1) {
         $this->flatten();
     }
 }
コード例 #3
0
ファイル: Img.class.php プロジェクト: hard990/altocms
 /**
  * Info about driver's version
  *
  * @param string $sDriver
  *
  * @return bool
  */
 public function GetDriverVersion($sDriver)
 {
     $sVersion = false;
     $sDriver = strtolower($sDriver);
     if (isset($this->aDrivers[$sDriver])) {
         if ($this->aDrivers[$sDriver] == 'Imagick') {
             if (class_exists('Imagick')) {
                 $img = new \Imagick();
                 $aInfo = $img->getVersion();
                 $sVersion = $aInfo['versionString'];
                 if (preg_match('/\\w+\\s\\d+\\.[\\d\\.\\-]+/', $sVersion, $aMatches)) {
                     $sVersion = $aMatches[0];
                 }
             }
         } elseif ($this->aDrivers[$sDriver] == 'Gmagick') {
             if (class_exists('Gmagick')) {
                 $aInfo = Gmagick::getVersion();
                 $sVersion = $aInfo['versionString'];
                 if (preg_match('/\\w+\\s\\d+\\.[\\d\\.\\-]+/', $sVersion, $aMatches)) {
                     $sVersion = $aMatches[0];
                 }
             }
         } else {
             if (function_exists('gd_info')) {
                 $aInfo = gd_info();
                 $sVersion = $aInfo['GD Version'];
                 if (preg_match('/\\d+\\.[\\d\\.]+/', $sVersion, $aMatches)) {
                     $sVersion = $aMatches[0];
                 }
             }
         }
     }
     return $sVersion;
 }
コード例 #4
0
	/**
	 * Returns whether image manipulations will be performed using GD or not.
	 *
	 * @return bool|null
	 */
	public function isGd()
	{
		if ($this->_isGd === null)
		{
			if (craft()->config->get('imageDriver') == 'gd')
			{
				$this->_isGd = true;
			}
			else if (extension_loaded('imagick'))
			{
				// Taken from Imagick\Imagine() constructor.
				$imagick = new \Imagick();
				$v = $imagick->getVersion();
				list($version, $year, $month, $day, $q, $website) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');

				// Update this if Imagine updates theirs.
				if (version_compare('6.2.9', $version) <= 0)
				{
					$this->_isGd = false;
				}
				else
				{
					$this->_isGd = true;
				}
			}
			else
			{
				$this->_isGd = true;
			}
		}

		return $this->_isGd;
	}
コード例 #5
0
 public function sendHeaders($serverErrorString = null)
 {
     // check we can send these first
     if (headers_sent()) {
         throw new ImThumbException("Could not set image headers, output already started", ImThumb::ERR_OUTPUTTING);
     }
     $modifiedDate = gmdate('D, d M Y H:i:s') . ' GMT';
     // get image size. Have to workaround bugs in Imagick that return 0 for size by counting ourselves.
     $byteSize = $this->image->getImageSize();
     if ($this->image->hasBrowserCache()) {
         header('HTTP/1.0 304 Not Modified');
     } else {
         if ($serverErrorString) {
             header('HTTP/1.0 500 Internal Server Error');
             header('X-ImThumb-Error: ' . $serverErrorString);
         } else {
             if (!$this->image->isValid()) {
                 header('HTTP/1.0 404 Not Found');
             } else {
                 header('HTTP/1.0 200 OK');
             }
         }
         header('Content-Type: ' . $this->image->getMime());
         header('Accept-Ranges: none');
         header('Last-Modified: ' . $modifiedDate);
         header('Content-Length: ' . $byteSize);
         if (!$this->image->param('browserCache')) {
             header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
             header("Pragma: no-cache");
             header('Expires: ' . gmdate('D, d M Y H:i:s', time()));
         } else {
             $maxAge = $this->image->param('browserCacheMaxAge');
             $expiryDate = gmdate('D, d M Y H:i:s', strtotime('now +' . $maxAge . ' seconds')) . ' GMT';
             header('Cache-Control: max-age=' . $maxAge . ', must-revalidate');
             header('Expires: ' . $expiryDate);
         }
     }
     // informational headers
     if (!$this->image->param('silent')) {
         $im = new Imagick();
         $imVer = $im->getVersion();
         header('X-Generator: ImThumb v' . ImThumb::VERSION . '; ' . $imVer['versionString']);
         if ($this->image->cache && $this->image->cache->isCached()) {
             header('X-Img-Cache: HIT');
         } else {
             header('X-Img-Cache: MISS');
         }
         if ($this->image->param('debug')) {
             list($startTime, $startCPU_u, $startCPU_s) = $this->image->getTimingStats();
             header('X-Generated-In: ' . number_format(microtime(true) - $startTime, 6) . 's');
             header('X-Memory-Peak: ' . number_format(memory_get_peak_usage() / 1024, 3, '.', '') . 'KB');
             $data = getrusage();
             $memusage = array((double) ($data['ru_utime.tv_sec'] + $data['ru_utime.tv_usec'] / 1000000), (double) ($data['ru_stime.tv_sec'] + $data['ru_stime.tv_usec'] / 1000000));
             header('X-CPU-Utilisation:' . ' Usr ' . number_format($memusage[0] - $startCPU_u, 6) . ', Sys ' . number_format($memusage[1] - $startCPU_s, 6) . '; Base ' . number_format($startCPU_u, 6) . ', ' . number_format($startCPU_s, 6));
         }
     }
 }
コード例 #6
0
ファイル: Magickly.php プロジェクト: gravitymedia/magickly
 /**
  * Get version.
  *
  * @return string
  */
 public function getVersion()
 {
     if (null === self::$version) {
         $imagick = new \Imagick();
         $version = $imagick->getVersion();
         list(self::$version) = sscanf($version['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
     }
     return self::$version;
 }
コード例 #7
0
ファイル: Imagine.php プロジェクト: momoim/momo-api
 /**
  * @throws RuntimeException
  */
 public function __construct()
 {
     if (!class_exists('Imagick')) {
         throw new RuntimeException('Imagick not installed');
     }
     $imagick = new \Imagick();
     $v = $imagick->getVersion();
     list($version, $year, $month, $day, $q, $website) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
     if (version_compare('6.2.9', $version) > 0) {
         throw new RuntimeException('Imagick version 6.2.9 or higher is required');
     }
 }
コード例 #8
0
ファイル: thumb.imagick.php プロジェクト: RicterZ/pixmicat
 function getClass()
 {
     $str = 'Imagick Wrapper';
     if ($this->isWorking()) {
         $a = new Imagick();
         $b = $a->getVersion();
         $b = $b['versionString'];
         $str .= ' : ' . str_replace(strrchr($b, ' '), '', $b);
         unset($a);
         unset($b);
     }
     return $str;
 }
コード例 #9
0
ファイル: Image.php プロジェクト: ngreimel/kovent
 public static function getFacadeAccessor()
 {
     if (class_exists('Imagick')) {
         try {
             $imagick = new \Imagick();
             $v = $imagick->getVersion();
             list($version, $year, $month, $day, $q, $website) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
             if (version_compare($version, '6.2.9') >= 0) {
                 return 'image/imagick';
             }
         } catch (\Exception $foo) {
         }
     }
     return 'image/gd';
 }
コード例 #10
0
ファイル: Pecl.php プロジェクト: Sywooch/forums
 /**
  * Produces a thumbnail of the current image whose shorter side is the specified length
  *
  * @see XenForo_Image_Abstract::thumbnailFixedShorterSide
  */
 public function thumbnailFixedShorterSide($shortSideLength)
 {
     if ($shortSideLength < 10) {
         $shortSideLength = 10;
     }
     $scaleUp = false;
     $ratio = $this->_width / $this->_height;
     if ($ratio > 1) {
         $width = ceil($shortSideLength * $ratio);
         $height = $shortSideLength;
         $scaleUp = $this->_height < $height;
     } else {
         $width = $shortSideLength;
         $height = ceil(max(1, $shortSideLength / $ratio));
         $scaleUp = $this->_width < $width;
     }
     // imagick module < 3 or ImageMagick < 6.3.2 don't support the 4th thumbnailImage param
     $oldImagick = version_compare(phpversion('imagick'), '3', '<');
     $version = $this->_image->getVersion();
     if (preg_match('#ImageMagick (\\d+\\.\\d+\\.\\d+)#i', $version['versionString'], $match)) {
         if (version_compare($match[1], '6.3.2', '<')) {
             $oldImagick = true;
         }
     }
     try {
         foreach ($this->_image as $frame) {
             if ($scaleUp) {
                 $frame->resizeImage($width, $height, Imagick::FILTER_QUADRATIC, 0.5, true);
             } else {
                 if ($oldImagick) {
                     $frame->thumbnailImage($width, $height, true);
                 } else {
                     $frame->thumbnailImage($width, $height, true, true);
                 }
             }
             $frame->setImagePage($width, $height, 0, 0);
         }
         $this->_updateDimensionCache();
     } catch (Exception $e) {
         return false;
     }
 }
コード例 #11
0
ファイル: cb_mod_check.php プロジェクト: Coding110/cbvideo
<?php

/* 
 ***************************************************************
 | Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
 | @ Author : ArslanHassan										
 | @ Software : ClipBucket , © PHPBucket.com					
 ****************************************************************
*/
require '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
/* Assigning page and subpage */
if (!defined('MAIN_PAGE')) {
    define('MAIN_PAGE', 'Tool Box');
}
if (!defined('SUB_PAGE')) {
    define('SUB_PAGE', 'Server Modules Info');
}
$ffmpegVersion = check_ffmpeg("ffmpeg");
assign("ffmpegVersion", $ffmpegVersion);
$phpVersion = check_php_cli("php");
assign("phpVersion", $phpVersion);
$MP4BoxVersion = check_mp4box("MP4Box");
assign("MP4BoxVersion", $MP4BoxVersion);
$imagick_version = Imagick::getVersion();
$imagick_version_string = $imagick_version['versionString'];
assign("imagick_version", $imagick_version_string);
subtitle("ClipBucket Server Module Checker");
template_files("cb_mod_check.html");
display_it();
コード例 #12
0
ファイル: photo_driver.php プロジェクト: phellmes/hubzilla
/**
 * Guess image mimetype from filename or from Content-Type header
 *
 * @arg $filename string Image filename
 * @arg $headers string Headers to check for Content-Type (from curl request)
 */
function guess_image_type($filename, $headers = '')
{
    logger('Photo: guess_image_type: ' . $filename . ($headers ? ' from curl headers' : ''), LOGGER_DEBUG);
    $type = null;
    if ($headers) {
        $hdrs = array();
        $h = explode("\n", $headers);
        foreach ($h as $l) {
            list($k, $v) = array_map("trim", explode(":", trim($l), 2));
            $hdrs[$k] = $v;
        }
        logger('Curl headers: ' . var_export($hdrs, true), LOGGER_DEBUG);
        if (array_key_exists('Content-Type', $hdrs)) {
            $type = $hdrs['Content-Type'];
        }
    }
    if (is_null($type)) {
        $ignore_imagick = get_config('system', 'ignore_imagick');
        // Guessing from extension? Isn't that... dangerous?
        if (class_exists('Imagick') && file_exists($filename) && is_readable($filename) && !$ignore_imagick) {
            $v = Imagick::getVersion();
            preg_match('/ImageMagick ([0-9]+\\.[0-9]+\\.[0-9]+)/', $v['versionString'], $m);
            if (version_compare($m[1], '6.6.7') >= 0) {
                /**
                 * Well, this not much better,
                 * but at least it comes from the data inside the image,
                 * we won't be tricked by a manipulated extension
                 */
                $image = new Imagick($filename);
                $type = $image->getImageMimeType();
            } else {
                // earlier imagick versions have issues with scaling png's
                // don't log this because it will just fill the logfile.
                // leave this note here so those who are looking for why
                // we aren't using imagick can find it
            }
        }
        if (is_null($type)) {
            $ext = pathinfo($filename, PATHINFO_EXTENSION);
            $ph = photo_factory('');
            $types = $ph->supportedTypes();
            foreach ($types as $m => $e) {
                if ($ext == $e) {
                    $type = $m;
                }
            }
        }
        if (is_null($type)) {
            $size = getimagesize($filename);
            $ph = photo_factory('');
            $types = $ph->supportedTypes();
            $type = array_key_exists($size['mime'], $types) ? $size['mime'] : 'image/jpeg';
        }
    }
    logger('Photo: guess_image_type: type=' . $type, LOGGER_DEBUG);
    return $type;
}
コード例 #13
0
ファイル: Imagine.php プロジェクト: jmstan/craft-website
 /**
  * Returns ImageMagick version
  *
  * @param Imagick $imagick
  *
  * @return string
  */
 private function getVersion(Imagick $imagick)
 {
     $v = $imagick->getVersion();
     list($version) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
     return $version;
 }
コード例 #14
0
    echo 'No critical problems found. Lychee should work without problems!' . PHP_EOL;
} else {
    echo $error;
}
# Show separator
echo PHP_EOL . PHP_EOL . 'System Information' . PHP_EOL;
echo '------------------' . PHP_EOL;
# Load json
$json = file_get_contents(LYCHEE_SRC . 'package.json');
$json = json_decode($json, true);
$imagick = extension_loaded('imagick');
if ($imagick === false) {
    $imagick = '-';
}
if ($imagick === true) {
    $imagickVersion = @Imagick::getVersion();
}
if (!isset($imagickVersion, $imagickVersion['versionNumber']) || $imagickVersion === '') {
    $imagickVersion = '-';
} else {
    $imagickVersion = $imagickVersion['versionNumber'];
}
$gdVersion = gd_info();
# Output system information
echo 'Lychee Version:  ' . $json['version'] . PHP_EOL;
echo 'DB Version:      ' . $settings['version'] . PHP_EOL;
echo 'System:          ' . PHP_OS . PHP_EOL;
echo 'PHP Version:     ' . floatval(phpversion()) . PHP_EOL;
echo 'MySQL Version:   ' . $database->server_version . PHP_EOL;
echo 'Imagick:         ' . $imagick . PHP_EOL;
echo 'Imagick Active:  ' . $settings['imagick'] . PHP_EOL;
コード例 #15
0
ファイル: imagemagick.php プロジェクト: goXXip/mihalismmh
 function create_thumbnail($filename, $save2disk = true, $resize_type = 0)
 {
     $filename = $this->basename($filename);
     if ($this->is_image($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $filename) == true) {
         $extension = $this->file_extension($filename);
         $thumbnail = $this->thumbnail_name($filename);
         if ($save2disk == true) {
             // Seemed easier to build the image resize upload
             // option into the already established thumbnail function
             // instead of waisting time trying to chop it up for new one.
             if ($resize_type > 0 && $resize_type <= 8) {
                 $thumbnail = $filename;
                 $this->mmhclass->info->config['advanced_thumbnails'] = false;
                 $size_values = array(1 => array("w" => 100, "h" => 75), 2 => array("w" => 150, "h" => 112), 3 => array("w" => 320, "h" => 240), 4 => array("w" => 640, "h" => 480), 5 => array("w" => 800, "h" => 600), 6 => array("w" => 1024, "h" => 768), 7 => array("w" => 1280, "h" => 1024), 8 => array("w" => 1600, "h" => 1200));
                 $thumbnail_size = $size_values[$resize_type];
             } else {
                 $thumbnail_size = $this->scale($filename, $this->mmhclass->info->config['thumbnail_width'], $this->mmhclass->info->config['thumbnail_height']);
             }
             if ($this->manipulator == "imagick") {
                 // New Design of Advanced Thumbnails created by: IcyTexx - http://www.hostili.com
                 // Classic Design of Advanced Thumbnails created by: Mihalism Technologies - http://www.mihalism.net
                 $canvas = new Imagick();
                 $athumbnail = new Imagick();
                 $imagick_version = $canvas->getVersion();
                 // Imagick needs to start giving real version number, not build number.
                 $new_thumbnails = version_compare($imagick_version['versionNumber'], "1621", ">=") == true ? true : false;
                 $athumbnail->readImage("{$this->mmhclass->info->root_path}{$this->mmhclass->info->config['upload_path']}{$filename}[0]");
                 $athumbnail->flattenImages();
                 $athumbnail->orgImageHeight = $athumbnail->getImageHeight();
                 $athumbnail->orgImageWidth = $athumbnail->getImageWidth();
                 $athumbnail->orgImageSize = $athumbnail->getImageLength();
                 $athumbnail->thumbnailImage($thumbnail_size['w'], $thumbnail_size['h']);
                 if ($this->mmhclass->info->config['advanced_thumbnails'] == true) {
                     $thumbnail_filesize = $this->format_filesize($athumbnail->orgImageSize, true);
                     $resobar_filesize = $thumbnail_filesize['f'] < 0 || $thumbnail_filesize['c'] > 9 ? $this->mmhclass->lang['5454'] : sprintf("%s%s", round($thumbnail_filesize['f']), $this->mmhclass->lang['7071'][$thumbnail_filesize['c']]);
                     if ($new_thumbnails == true) {
                         $textdraw = new ImagickDraw();
                         $textdrawborder = new ImagickDraw();
                         if ($athumbnail->getImageWidth() > 113) {
                             $textdraw->setFillColor(new ImagickPixel("white"));
                             $textdraw->setFontSize(9);
                             $textdraw->setFont("{$mmhclass->info->root_path}css/fonts/sf_fedora_titles.ttf");
                             $textdraw->setFontWeight(900);
                             $textdraw->setGravity(8);
                             $textdraw->setTextKerning(1);
                             $textdraw->setTextAntialias(false);
                             $textdrawborder->setFillColor(new ImagickPixel("black"));
                             $textdrawborder->setFontSize(9);
                             $textdrawborder->setFont("{$mmhclass->info->root_path}css/fonts/sf_fedora_titles.ttf");
                             $textdrawborder->setFontWeight(900);
                             $textdrawborder->setGravity(8);
                             $textdrawborder->setTextKerning(1);
                             $textdrawborder->setTextAntialias(false);
                             $array_x = array("-1", "0", "1", "1", "1", "0", "-1", "-1");
                             $array_y = array("-1", "-1", "-1", "0", "1", "1", "1", "0");
                             foreach ($array_x as $key => $value) {
                                 $athumbnail->annotateImage($textdrawborder, $value, 3 - $array_y[$key], 0, "{$athumbnail->orgImageWidth}x{$athumbnail->orgImageHeight} - {$resobar_filesize}");
                             }
                             $athumbnail->annotateImage($textdraw, 0, 3, 0, "{}x{$athumbnail->orgImageHeight} - {$resobar_filesize}");
                         }
                     } else {
                         $transback = new Imagick();
                         $canvasdraw = new ImagickDraw();
                         $canvas->newImage($athumbnail->getImageWidth(), $athumbnail->getImageHeight() + 12, new ImagickPixel("black"));
                         $transback->newImage($canvas->getImageWidth(), $canvas->getImageHeight() - 12, new ImagickPixel("white"));
                         $canvas->compositeImage($transback, 40, 0, 0);
                         $canvasdraw->setFillColor(new ImagickPixel("white"));
                         $canvasdraw->setGravity(8);
                         $canvasdraw->setFontSize(10);
                         $canvasdraw->setFontWeight(900);
                         $canvasdraw->setFont("AvantGarde-Demi");
                         $canvas->annotateImage($canvasdraw, 0, 0, 0, "{$athumbnail->orgImageWidth}x{$athumbnail->orgImageHeight} - {$resobar_filesize}");
                         $canvas->compositeImage($athumbnail, 40, 0, 0);
                         $athumbnail = $canvas->clone();
                     }
                 }
                 if ($this->mmhclass->info->config['thumbnail_type'] == "jpeg") {
                     $athumbnail->setImageFormat("jpeg");
                     $athumbnail->setImageCompression(9);
                 } else {
                     $athumbnail->setImageFormat("png");
                 }
                 $athumbnail->writeImage($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $thumbnail);
             } else {
                 // I hate GD. Piece of crap supports nothing. NOTHING!
                 if (in_array($extension, array("png", "gif", "jpg", "jpeg")) == true) {
                     $function_extension = str_replace("jpg", "jpeg", $extension);
                     $image_function = "imagecreatefrom{$function_extension}";
                     $image = $image_function($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $filename);
                     $imageinfo = $this->get_image_info($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $this->basename($filename));
                     $thumbnail_image = imagecreatetruecolor($thumbnail_size['w'], $thumbnail_size['h']);
                     $index = imagecolortransparent($thumbnail_image);
                     if ($index < 0) {
                         $white = imagecolorallocate($thumbnail_image, 255, 255, 255);
                         imagefill($thumbnail_image, 0, 0, $white);
                     }
                     imagecopyresampled($thumbnail_image, $image, 0, 0, 0, 0, $thumbnail_size['w'], $thumbnail_size['h'], $imageinfo['width'], $imageinfo['height']);
                     $image_savefunction = sprintf("image%s", $this->mmhclass->info->config['thumbnail_type'] == "jpeg" ? "jpeg" : "png");
                     $image_savefunction($thumbnail_image, $this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $thumbnail);
                     chmod($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $thumbnail, 0644);
                     imagedestroy($image);
                     imagedestroy($thumbnail_image);
                 } else {
                     trigger_error("Image format not supported by GD", E_USER_ERROR);
                 }
             }
             chmod($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $thumbnail, 0644);
         } else {
             readfile($this->mmhclass->info->root_path . $this->mmhclass->info->config['upload_path'] . $thumbnail);
         }
     }
 }
コード例 #16
0
        } else {
            return gettext('The <strong><em>Imagick</em></strong> extension is not available.');
        }
        return '';
    }
}
/**
 * Zenphoto image manipulation functions using the Imagick library
 */
if ($_zp_imagick_present && (getOption('use_imagick') || !extension_loaded('gd'))) {
    $_imagick_temp = new Imagick();
    $_magick_mem_lim = getOption('magick_mem_lim');
    if ($_magick_mem_lim > 0) {
        $_imagick_temp->setResourceLimit(Imagick::RESOURCETYPE_MEMORY, $_magick_mem_lim);
    }
    $_imagemagick_version = $_imagick_temp->getVersion();
    $_lib_Imagick_info = array();
    $_lib_Imagick_info['Library'] = 'Imagick';
    $_lib_Imagick_info['Library_desc'] = sprintf(gettext('PHP Imagick library <em>%s</em>') . '<br /><em>%s</em>', $_imagick_version, $_imagemagick_version['versionString']);
    $_use_imagick_deprecated = version_compare($_imagick_version, '2.3.0b1', '<') && version_compare($_imagemagick_version['versionString'], '6.3.8', '<');
    $_imagick_format_blacklist = array('AVI', 'M2V', 'M4V', 'MOV', 'MP4', 'MPEG', 'MPG', 'WMV', 'HTM', 'HTML', 'MAN', 'PDF', 'SHTML', 'TEXT', 'TXT', 'UBRL', 'DFONT', 'OTF', 'PFA', 'PFB', 'TTC', 'TTF', 'EPI', 'EPS', 'EPS2', 'EPS3', 'EPSF', 'EPSI', 'EPT', 'EPT2', 'EPT3', 'PS', 'PS2', 'PS3', 'CGM', 'EMF', 'FIG', 'FPX', 'GPLT', 'HPGL', 'JBIG', 'RAD', 'WMF', 'WMZ', 'ZIP');
    $_imagick_formats = array_diff($_imagick_temp->queryFormats(), $_imagick_format_blacklist);
    $_lib_Imagick_info += array_combine(array_map('strtoupper', $_imagick_formats), array_map('strtolower', $_imagick_formats));
    define('IMAGICK_RETAIN_PROFILES', version_compare($_imagemagick_version['versionNumber'], '6.3.6', '>='));
    $_imagick_temp->destroy();
    unset($_magick_mem_lim);
    unset($_imagick_format_blacklist);
    unset($_imagick_formats);
    if (DEBUG_IMAGE) {
        debugLog('Loading ' . $_lib_Imagick_info['Library']);
    }
コード例 #17
0
 } else {
     $phpver = false;
     $modx->log(xPDO::LOG_LEVEL_INFO, 'PHP version: ' . PHP_VERSION);
     $modx->log(xPDO::LOG_LEVEL_ERROR, 'Resizer requires PHP 5.3.2 or higher');
 }
 $graphicsSuccess = false;
 $modx->log(xPDO::LOG_LEVEL_INFO, 'Availabe graphics libraries:');
 if (class_exists('Gmagick', false)) {
     $magick = new Gmagick();
     $version = $magick->getversion();
     $modx->log(xPDO::LOG_LEVEL_INFO, "* {$version['versionString']}");
     $graphicsSuccess = true;
 }
 if (class_exists('Imagick', false)) {
     $magick = new \Imagick();
     $v = $magick->getVersion();
     $modx->log(xPDO::LOG_LEVEL_INFO, "* {$v['versionString']}");
     list($version, $year, $month, $day, $q, $website) = sscanf($v['versionString'], 'ImageMagick %s %04d-%02d-%02d %s %s');
     $version = explode('-', $version);
     $version = $version[0];
     if (version_compare('6.2.9', $version) > 0) {
         $modx->log(xPDO::LOG_LEVEL_ERROR, '- ImageMagick 6.2.9 or higher required. Disabling Imagick support.');
         $setting = $modx->getObject('modSystemSetting', 'resizer.graphics_library');
         $setting->set('value', 0);
         $setting->save();
     } else {
         $graphicsSuccess = true;
         if (version_compare('6.5.7', $version) > 0) {
             $modx->log(xPDO::LOG_LEVEL_ERROR, '- ImageMagick < 6.5.7: CMYK to RGB conversions not supported');
         }
         if (version_compare('6.5.4', $version) == 0) {
コード例 #18
0
ファイル: Plugin.php プロジェクト: pabalexa/pdf-light-viewer
 public static function requirements($boolean = false)
 {
     $upload_dir_message = __('Upload folder', PDF_LIGHT_VIEWER_PLUGIN) . ': <code>' . PdfLightViewer_Plugin::getUploadDirectory() . '</code>';
     $host_url = site_url();
     $Imagick = null;
     $ImagickVersion = null;
     $pdf_format_support = array();
     if (class_exists("Imagick")) {
         $Imagick = new Imagick();
         $ImagickVersion = $Imagick->getVersion();
         $pdf_format_support = $Imagick->queryFormats('PDF');
     }
     if (PdfLightViewer_AdminController::getSetting('do-not-check-gs')) {
         $ghostscript_version = true;
     } else {
         if (function_exists('shell_exec')) {
             if (stristr(php_uname('s'), 'win')) {
                 $ghostscript_version = @shell_exec('gs --version');
             } else {
                 $ghostscript_version = @shell_exec('$(command -v gs) --version');
                 if (!$ghostscript_version) {
                     $ghostscript_version = @shell_exec('$(which gs) --version');
                 }
                 if (!$ghostscript_version) {
                     $ghostscript_version = @shell_exec('gs --version');
                 }
             }
         } else {
             $ghostscript_version = false;
         }
     }
     $logs_dir_message = __('Logs folder', PDF_LIGHT_VIEWER_PLUGIN) . ': <code>' . self::getLogsPath() . '</code>';
     $requirements = array(array('name' => 'PHP', 'status' => version_compare(PHP_VERSION, '5.3.0', '>='), 'success' => sprintf(__('is %s or higher', PDF_LIGHT_VIEWER_PLUGIN), '5.3'), 'fail' => sprintf(__('is lower than %s', PDF_LIGHT_VIEWER_PLUGIN), '5.3'), 'description' => ''), array('name' => __('Imagick PHP Extension', PDF_LIGHT_VIEWER_PLUGIN), 'status' => extension_loaded('imagick'), 'success' => __('is loaded', PDF_LIGHT_VIEWER_PLUGIN), 'fail' => __('is not loaded', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("Imagick PHP Extension is required for PDF -> JPEG convertation. It cannot be included with the plugin unfortunately, so you or your hosting provider/server administrator should install it.", PDF_LIGHT_VIEWER_PLUGIN)), array('name' => __('Imagick PHP Wrapper', PDF_LIGHT_VIEWER_PLUGIN), 'status' => class_exists("Imagick"), 'success' => __('is supported', PDF_LIGHT_VIEWER_PLUGIN) . ($ImagickVersion ? '. v.' . $ImagickVersion['versionString'] : ''), 'fail' => __('is not supported', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("Imagick PHP Wrapper is required to make available Imagick PHP Extension functionality in the plugin. Usually it's integrated through the PECL plugin. It cannot be included with the plugin unfortunately, so you or your hosting provider/server administrator should install it.", PDF_LIGHT_VIEWER_PLUGIN)), array('name' => __('Imagick PDF Support', PDF_LIGHT_VIEWER_PLUGIN), 'status' => $Imagick && !empty($pdf_format_support), 'success' => __('is enabled', PDF_LIGHT_VIEWER_PLUGIN), 'fail' => __('is not enabled', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("Imagick PDF Support is required for PDF -> JPEG convertation.", PDF_LIGHT_VIEWER_PLUGIN)), array('name' => 'GhostScript', 'status' => $ghostscript_version, 'success' => __('is supported', PDF_LIGHT_VIEWER_PLUGIN) . ($ghostscript_version && is_string($ghostscript_version) ? '. v.' . $ghostscript_version : ''), 'fail' => __('is not supported', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("GhostScript is required for Imagick PDF Support. For cases, when you are sure that GhostScript is installed, but it was not detected by the plugin correctly you can disable this requirement in options below.", PDF_LIGHT_VIEWER_PLUGIN)), array('name' => $upload_dir_message, 'status' => PdfLightViewer_Plugin::createUploadDirectory(), 'success' => __('is writable', PDF_LIGHT_VIEWER_PLUGIN), 'fail' => __('is not writable', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("This is the folder for converted images.", PDF_LIGHT_VIEWER_PLUGIN)), array('name' => $logs_dir_message, 'status' => self::createLogsDirectory() && is_writable(self::getLogsPath()), 'success' => __('is writable', PDF_LIGHT_VIEWER_PLUGIN), 'fail' => __('is not writable', PDF_LIGHT_VIEWER_PLUGIN), 'description' => __("We will save plugin-specific log files in this folder.", PDF_LIGHT_VIEWER_PLUGIN)));
     if ($boolean) {
         $status = true;
         foreach ($requirements as $requirement) {
             $status = $status && $requirement['status'];
         }
         return $status;
     } else {
         return $requirements;
     }
 }
コード例 #19
0
ファイル: Admin.subs.php プロジェクト: KeiroD/Elkarte
/**
 * Get a list of versions that are currently installed on the server.
 *
 * @package Admin
 * @param string[] $checkFor
 */
function getServerVersions($checkFor)
{
    global $txt, $memcached, $modSettings;
    $db = database();
    loadLanguage('Admin');
    $versions = array();
    // Is GD available?  If it is, we should show version information for it too.
    if (in_array('gd', $checkFor) && function_exists('gd_info')) {
        $temp = gd_info();
        $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']);
    }
    // Why not have a look at ImageMagick? If it is, we should show version information for it too.
    if (in_array('imagick', $checkFor) && class_exists('Imagick')) {
        $temp = new Imagick();
        $temp2 = $temp->getVersion();
        $versions['imagick'] = array('title' => $txt['support_versions_imagick'], 'version' => $temp2['versionString']);
    }
    // Now lets check for the Database.
    if (in_array('db_server', $checkFor)) {
        $conn = $db->connection();
        if (empty($conn)) {
            trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
        } else {
            $versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $db->db_title()), 'version' => '');
            $versions['db_server']['version'] = $db->db_server_version();
        }
    }
    // If we're using memcache we need the server info.
    if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        require_once SUBSDIR . '/Cache.subs.php';
        get_memcached_server();
    } else {
        if (($key = array_search('memcache', $checkFor)) !== false) {
            unset($checkFor[$key]);
        }
    }
    // Check to see if we have any accelerators installed...
    if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) {
        $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION);
    }
    if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) {
        $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION);
    }
    if (in_array('zend', $checkFor) && function_exists('zend_shm_cache_store')) {
        $versions['zend'] = array('title' => 'Zend SHM Accelerator', 'version' => zend_version());
    }
    if (in_array('apc', $checkFor) && extension_loaded('apc')) {
        $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
    }
    if (in_array('memcache', $checkFor) && function_exists('memcache_set')) {
        $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached));
    }
    if (in_array('xcache', $checkFor) && function_exists('xcache_set')) {
        $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
    }
    if (in_array('opcache', $checkFor) && extension_loaded('Zend OPcache')) {
        $opcache_config = @opcache_get_configuration();
        if (!empty($opcache_config['directives']['opcache.enable'])) {
            $versions['opcache'] = array('title' => $opcache_config['version']['opcache_product_name'], 'version' => $opcache_config['version']['version']);
        }
    }
    // PHP Version
    if (in_array('php', $checkFor)) {
        $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION . ' (' . php_sapi_name() . ')', 'more' => '?action=admin;area=serversettings;sa=phpinfo');
    }
    // Server info
    if (in_array('server', $checkFor)) {
        $req = request();
        $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $req->server_software());
        // Compute some system info, if we can
        $versions['server_name'] = array('title' => $txt['support_versions'], 'version' => php_uname());
        $loading = detectServerLoad();
        if ($loading !== false) {
            $versions['server_load'] = array('title' => $txt['load_balancing_settings'], 'version' => $loading);
        }
    }
    return $versions;
}
コード例 #20
0
 static function detect($force = false)
 {
     $cache = dirname(dirname(dirname(__FILE__))) . '/storage/cache/images/provider.cache';
     if (!$force && file_exists($cache)) {
         $cache = unserialize(file_get_contents($cache));
         if ($cache && count($cache) === 2) {
             return $cache;
         }
     }
     $versionString = $className = false;
     if (function_exists('gd_info')) {
         $gd = gd_info();
         $versionString = 'GD ' . $gd['GD Version'];
         $className = 'DarkroomGD2';
     }
     if (MAGICK_PATH_FINAL !== 'gd') {
         if (in_array('imagick', get_loaded_extensions()) && class_exists('Imagick') && MAGICK_PATH_FINAL === 'convert') {
             $im = new Imagick();
             $version = $im->getVersion();
             preg_match('/\\d+\\.\\d+\\.\\d+([^\\s]+)?/', $version['versionString'], $matches);
             $versionString = 'Imagick ' . $matches[0];
             $className = 'DarkroomImagick';
         } else {
             if (self::isCallable('shell_exec') && (DIRECTORY_SEPARATOR == '/' || DIRECTORY_SEPARATOR == '\\' && MAGICK_PATH_FINAL != 'convert')) {
                 $out = shell_exec(MAGICK_PATH_FINAL . ' -version');
                 preg_match('/(?:Image|Graphics)Magick\\s(\\d+\\.\\d+\\.\\d+([^\\s]+))?/', $out, $matches);
                 if ($matches) {
                     $versionString = $matches[0];
                     $className = 'DarkroomImageMagick';
                 }
             }
         }
     }
     $arr = array($versionString, $className);
     file_put_contents($cache, serialize($arr));
     return $arr;
 }
コード例 #21
0
ファイル: checkenv.php プロジェクト: RicterZ/pixmicat
 function checkImagick()
 {
     if (extension_loaded('imagick') && class_exists('Imagick')) {
         $a = new Imagick();
         $b = $a->getVersion();
         $b = $b['versionString'];
         unset($a);
         return $b;
     } else {
         return false;
     }
 }
コード例 #22
0
ファイル: Imagick.php プロジェクト: rundiz/image
 /**
  * Verify PHP Imagick extension and Image Magick version.
  * 
  * @return boolean Return true on success, false on failed. Call to status_msg property to see the details on failure.
  */
 private function verifyImagickVersion()
 {
     if (extension_loaded('imagick') !== true) {
         // imagick extension was not loaded.
         $this->status = false;
         $this->status_msg = 'The PHP Imagick extension was not loaded.';
         return false;
     }
     $imagick_extension_version = phpversion('imagick');
     if (version_compare($imagick_extension_version, '3.4.0', '>=')) {
         // if PHP Imagick extension is equal or greater than 3.4
         $image_magick_v = \Imagick::getVersion();
         if (!is_array($image_magick_v) || is_array($image_magick_v) && !array_key_exists('versionString', $image_magick_v)) {
             // don't know Image Magick version.
             $this->status = false;
             $this->status_msg = 'Unable to verify Image Magick version.';
             unset($image_magick_v);
             return false;
         } else {
             // verify Image Magick version.
             preg_match('/ImageMagick ([0-9]+\\.[0-9]+\\.[0-9]+)/', $image_magick_v['versionString'], $matches);
             unset($image_magick_v);
             if (!is_array($matches) || is_array($matches) && !array_key_exists(1, $matches)) {
                 $this->status = false;
                 $this->status_msg = 'Unable to verify Image Magick version.';
                 unset($matches);
                 return false;
             } else {
                 if (version_compare($matches[1], '6.5.3', '<')) {
                     $this->status = false;
                     $this->status_msg = sprintf('This PHP Imagick extension (%s) require Image Magick 6.5.3+. You have Image Magick %s.', $imagick_extension_version, $matches[1]);
                     unset($matches);
                     return false;
                 }
             }
             unset($matches);
             // verify PHP version
             if (version_compare(phpversion(), '5.4', '<')) {
                 $this->status = false;
                 $this->status_msg = 'This PHP Imagick extension require PHP 5.4.0+.';
                 return false;
             }
         }
         // end verify for PHP Imagick extension v. 3.4+
     }
     unset($imagick_extension_version);
     if (!$this->isPreviousError()) {
         $this->status = true;
         $this->status_msg = null;
     }
     return true;
 }
コード例 #23
0
ファイル: lib-Imagick.php プロジェクト: ariep/ZenPhoto20-DEV
 * Library for image handling using the Imagick library of functions
 *
 * Requires Imagick 3.0.0+ and ImageMagick 6.3.8+
 *
 * @package core
 */
// force UTF-8 Ø
define('IMAGICK_REQUIRED_VERSION', '3.0.0');
define('IMAGEMAGICK_REQUIRED_VERSION', '6.3.8');
$_imagick_version = phpversion('imagick');
$_imagick_version_pass = version_compare($_imagick_version, IMAGICK_REQUIRED_VERSION, '>=');
$_imagemagick_version = '';
$_imagemagick_version_pass = false;
$_zp_imagick_present = extension_loaded('imagick') && $_imagick_version_pass;
if ($_zp_imagick_present) {
    @($_imagemagick_version = Imagick::getVersion());
    preg_match('/\\d+(\\.\\d+)*/', $_imagemagick_version['versionString'], $matches);
    $_imagemagick_version['versionNumber'] = $matches[0];
    $_imagemagick_version_pass = version_compare($_imagemagick_version['versionNumber'], IMAGEMAGICK_REQUIRED_VERSION, '>=');
    $_zp_imagick_present &= $_imagick_version_pass;
    unset($matches);
}
$_zp_graphics_optionhandlers += array('lib_Imagick_Options' => new lib_Imagick_Options());
/**
 * Option class for lib-Imagick
 */
class lib_Imagick_Options
{
    public static $ignore_size = 0;
    function __construct()
    {
コード例 #24
0
ファイル: Bitmap.php プロジェクト: paladox/mediawiki
 /**
  * Transform an image using the Imagick PHP extension
  *
  * @param File $image File associated with this thumbnail
  * @param array $params Array with scaler params
  *
  * @return MediaTransformError Error object if error occurred, false (=no error) otherwise
  */
 protected function transformImageMagickExt($image, $params)
 {
     global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea, $wgJpegPixelFormat;
     try {
         $im = new Imagick();
         $im->readImage($params['srcPath']);
         if ($params['mimeType'] == 'image/jpeg') {
             // Sharpening, see bug 6193
             if (($params['physicalWidth'] + $params['physicalHeight']) / ($params['srcWidth'] + $params['srcHeight']) < $wgSharpenReductionThreshold) {
                 // Hack, since $wgSharpenParameter is written specifically for the command line convert
                 list($radius, $sigma) = explode('x', $wgSharpenParameter);
                 $im->sharpenImage($radius, $sigma);
             }
             $qualityVal = isset($params['quality']) ? (string) $params['quality'] : null;
             $im->setCompressionQuality($qualityVal ?: 80);
             if ($params['interlace']) {
                 $im->setInterlaceScheme(Imagick::INTERLACE_JPEG);
             }
             if ($wgJpegPixelFormat) {
                 $factors = $this->imageMagickSubsampling($wgJpegPixelFormat);
                 $im->setSamplingFactors($factors);
             }
         } elseif ($params['mimeType'] == 'image/png') {
             $im->setCompressionQuality(95);
             if ($params['interlace']) {
                 $im->setInterlaceScheme(Imagick::INTERLACE_PNG);
             }
         } elseif ($params['mimeType'] == 'image/gif') {
             if ($this->getImageArea($image) > $wgMaxAnimatedGifArea) {
                 // Extract initial frame only; we're so big it'll
                 // be a total drag. :P
                 $im->setImageScene(0);
             } elseif ($this->isAnimatedImage($image)) {
                 // Coalesce is needed to scale animated GIFs properly (bug 1017).
                 $im = $im->coalesceImages();
             }
             // GIF interlacing is only available since 6.3.4
             $v = Imagick::getVersion();
             preg_match('/ImageMagick ([0-9]+\\.[0-9]+\\.[0-9]+)/', $v['versionString'], $v);
             if ($params['interlace'] && version_compare($v[1], '6.3.4') >= 0) {
                 $im->setInterlaceScheme(Imagick::INTERLACE_GIF);
             }
         }
         $rotation = isset($params['disableRotation']) ? 0 : $this->getRotation($image);
         list($width, $height) = $this->extractPreRotationDimensions($params, $rotation);
         $im->setImageBackgroundColor(new ImagickPixel('white'));
         // Call Imagick::thumbnailImage on each frame
         foreach ($im as $i => $frame) {
             if (!$frame->thumbnailImage($width, $height, false)) {
                 return $this->getMediaTransformError($params, "Error scaling frame {$i}");
             }
         }
         $im->setImageDepth(8);
         if ($rotation) {
             if (!$im->rotateImage(new ImagickPixel('white'), 360 - $rotation)) {
                 return $this->getMediaTransformError($params, "Error rotating {$rotation} degrees");
             }
         }
         if ($this->isAnimatedImage($image)) {
             wfDebug(__METHOD__ . ": Writing animated thumbnail\n");
             // This is broken somehow... can't find out how to fix it
             $result = $im->writeImages($params['dstPath'], true);
         } else {
             $result = $im->writeImage($params['dstPath']);
         }
         if (!$result) {
             return $this->getMediaTransformError($params, "Unable to write thumbnail to {$params['dstPath']}");
         }
     } catch (ImagickException $e) {
         return $this->getMediaTransformError($params, $e->getMessage());
     }
     return false;
 }
コード例 #25
0
ファイル: intro.php プロジェクト: donseba/Piwigo
    $template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
}
if ($nb_elements > 0) {
    $query = '
SELECT MIN(date_available)
  FROM ' . IMAGES_TABLE . '
;';
    list($first_date) = pwg_db_fetch_row(pwg_query($query));
    $template->assign('first_added', array('DB_DATE' => l10n('first photo added on %s', format_date($first_date))));
}
// graphics library
switch (pwg_image::get_library()) {
    case 'imagick':
        $library = 'ImageMagick';
        $img = new Imagick();
        $version = $img->getVersion();
        if (preg_match('/ImageMagick \\d+\\.\\d+\\.\\d+-?\\d*/', $version['versionString'], $match)) {
            $library = $match[0];
        }
        $template->assign('GRAPHICS_LIBRARY', $library);
        break;
    case 'ext_imagick':
        $library = 'External ImageMagick';
        exec($conf['ext_imagick_dir'] . 'convert -version', $returnarray);
        if (preg_match('/Version: ImageMagick (\\d+\\.\\d+\\.\\d+-?\\d*)/', $returnarray[0], $match)) {
            $library .= ' ' . $match[1];
        }
        $template->assign('GRAPHICS_LIBRARY', $library);
        break;
    case 'gd':
        $gd_info = gd_info();