本文整理匯總了PHP中Imagick::getVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getVersion方法的具體用法?PHP Imagick::getVersion怎麽用?PHP Imagick::getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagick
的用法示例。
在下文中一共展示了Imagick::getVersion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* 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: prepareOutput
/**
* @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: GetDriverVersion
/**
* 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: isGd
/**
* 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: sendHeaders
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: getVersion
/**
* 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: __construct
/**
* @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: getClass
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: getFacadeAccessor
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: thumbnailFixedShorterSide
/**
* 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: Copyright
<?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: guess_image_type
/**
* 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: getVersion
/**
* 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: file_get_contents
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: array
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);
//.........這裏部分代碼省略.........