當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Imagick::queryFormats方法代碼示例

本文整理匯總了PHP中Imagick::queryFormats方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::queryFormats方法的具體用法?PHP Imagick::queryFormats怎麽用?PHP Imagick::queryFormats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imagick的用法示例。


在下文中一共展示了Imagick::queryFormats方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getThumbnail

 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $mimetype = $fileview->getMimeType($path);
     $path = \OC_Helper::mimetypeIcon($mimetype);
     $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT));
     $svgPath = substr_replace($path, 'svg', -3);
     if (extension_loaded('imagick') && file_exists($svgPath) && count(@\Imagick::queryFormats("SVG")) === 1) {
         // http://www.php.net/manual/de/imagick.setresolution.php#85284
         $svg = new \Imagick();
         $svg->readImage($svgPath);
         $res = $svg->getImageResolution();
         $x_ratio = $res['x'] / $svg->getImageWidth();
         $y_ratio = $res['y'] / $svg->getImageHeight();
         $svg->removeImage();
         $svg->setResolution($maxX * $x_ratio, $maxY * $y_ratio);
         $svg->setBackgroundColor(new \ImagickPixel('transparent'));
         $svg->readImage($svgPath);
         $svg->setImageFormat('png32');
         $image = new \OC_Image();
         $image->loadFromData($svg);
     } else {
         $image = new \OC_Image($path);
     }
     return $image;
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:25,代碼來源:unknown.php

示例2: __construct

 /**
  * Check for the php extension.
  *
  * @throws Exception
  */
 public function __construct()
 {
     if (!extension_loaded('imagick')) {
         throw new Exception(__('The transformation of images via ImageMagick requires the PHP extension "imagick".'));
     }
     $this->_supportedFormats = array_intersect($this->_supportedFormats, Imagick::queryFormats());
 }
開發者ID:pabalexa,項目名稱:UniversalViewer4Omeka,代碼行數:12,代碼來源:Imagick.php

示例3: actionIndex

 public function actionIndex()
 {
     if (version_compare(PHP_VERSION, '4.3', '<')) {
         echo 'php版本過低,請先安裝php4.3以上版本';
         exist;
     }
     $requirementsChecker = new RequirementChecker();
     $gdMemo = $imagickMemo = '啟用驗證碼時需要安裝php的gd組件或imagick組件。';
     $gdOK = $imagickOK = false;
     if (extension_loaded('imagick')) {
         $imagick = new Imagick();
         $imagickFormats = $imagick->queryFormats('PNG');
         if (in_array('PNG', $imagickFormats)) {
             $imagickOK = true;
         } else {
             $imagickMemo = 'Imagick組件不支持png。';
         }
     }
     if (extension_loaded('gd')) {
         $gdInfo = gd_info();
         if (!empty($gdInfo['FreeType Support'])) {
             $gdOK = true;
         } else {
             $gdMemo = 'gd組件不支持FreeType。';
         }
     }
     /**
      * Adjust requirements according to your application specifics.
      */
     $requirements = array(array('name' => 'PHP版本', 'mandatory' => true, 'condition' => version_compare(PHP_VERSION, '5.4.0', '>='), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>', 'memo' => 'PHP 5.4.0及以上'), array('name' => 'config目錄寫權限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@app/config')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'config目錄需要寫權限'), array('name' => 'runtime目錄寫權限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@app/runtime')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'runtime目錄需要寫權限'), array('name' => 'web/assets目錄寫權限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@webroot/assets')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'web/assets目錄需要寫權限'), array('name' => 'web/avatar目錄寫權限', 'mandatory' => true, 'condition' => is_writeable(Yii::getAlias('@webroot/avatar')), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => 'web/avatar目錄需要寫權限'), array('name' => 'PDO擴展', 'mandatory' => true, 'condition' => extension_loaded('pdo'), 'by' => 'DB連接', 'memo' => 'MySQL連接。'), array('name' => 'PDO_MySQL擴展', 'mandatory' => true, 'condition' => extension_loaded('pdo_mysql'), 'by' => 'DB連接', 'memo' => 'MySQL連接。'), array('name' => 'OpenSSL擴展', 'mandatory' => true, 'condition' => extension_loaded('openssl'), 'by' => '<a href="http://simpleforum.org">Simple Forum</a>', 'memo' => '用於用戶密碼加密'), array('name' => 'Memcache(d)擴展', 'mandatory' => false, 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'by' => 'memcache/memcached緩存', 'memo' => '用於開啟緩存'), array('name' => 'APC擴展', 'mandatory' => false, 'condition' => extension_loaded('apc'), 'by' => 'APC緩存', 'memo' => '用於開啟緩存'), array('name' => 'GD擴展(支持FreeType)', 'mandatory' => false, 'condition' => $gdOK, 'by' => '驗證碼', 'memo' => $gdMemo), array('name' => 'ImageMagick擴展(支持png)', 'mandatory' => false, 'condition' => $imagickOK, 'by' => '驗證碼', 'memo' => $imagickMemo), 'phpExposePhp' => array('name' => 'php.ini的expose_php設值', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'by' => '安全問題', 'memo' => '請修改為 expose_php = Off'), 'phpAllowUrlInclude' => array('name' => 'php.ini的allow_url_include設值', 'mandatory' => false, 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'by' => '安全問題', 'memo' => '請修改為 allow_url_include = Off'), 'phpSmtp' => array('name' => 'PHP SMTP郵件', 'mandatory' => false, 'condition' => strlen(ini_get('SMTP')) > 0, 'by' => '郵件', 'memo' => '用於發送郵件'), array('name' => 'MBString擴展', 'mandatory' => true, 'condition' => extension_loaded('mbstring'), 'by' => '<a href="http://www.php.net/manual/en/book.mbstring.php">Multibyte string</a> processing', 'memo' => ''), array('name' => 'Reflection擴展', 'mandatory' => true, 'condition' => class_exists('Reflection', false), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>'), array('name' => 'PCRE擴展', 'mandatory' => true, 'condition' => extension_loaded('pcre'), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>'), array('name' => 'SPL擴展', 'mandatory' => true, 'condition' => extension_loaded('SPL'), 'by' => '<a href="http://www.yiiframework.com">Yii Framework</a>'));
     $requirementsChecker->check($requirements);
     return $this->render('index', ['check' => $requirementsChecker]);
 }
開發者ID:0ps,項目名稱:simpleforum,代碼行數:33,代碼來源:InstallController.php

示例4: createThumbnailWithImagick

 /**
  * Creates a thumbnail with imagick.
  *
  * @param  File    $fileObject           FileObject to add properties
  * @param  string  $httpPathToMediaDir   Http path to file
  * @param  string  $pathToMediaDirectory Local path to file
  * @param  string  $fileName             Name of the image
  * @param  string  $fileExtension        Fileextension
  * @param  integer $width                Width of thumbnail, if omitted, size will be proportional to height
  * @param  integer $height               Height of thumbnail, if omitted, size will be proportional to width
  *
  * @throws ThumbnailCreationFailedException              If imagick is not supported
  * @throws InvalidArgumentException      If both, height and width are omitted or file format is not supported
  */
 private static function createThumbnailWithImagick(File &$fileObject, $httpPathToMediaDir, $pathToMediaDirectory, $fileName, $fileExtension, $width = null, $height = null)
 {
     if (!extension_loaded('imagick')) {
         throw new ExtensionNotLoadedException('Imagick is not loaded on this system');
     }
     if ($width === null && $height === null) {
         throw new InvalidArgumentException('Either width or height must be provided');
     }
     // create thumbnails with imagick
     $imagick = new \Imagick();
     if (!in_array($fileExtension, $imagick->queryFormats("*"))) {
         throw new ThumbnailCreationFailedException('No thumbnail could be created for the file format');
     }
     // read image into imagick
     $imagick->readImage(sprintf('%s/%s.%s', $pathToMediaDirectory, $fileName, $fileExtension));
     // set size
     $imagick->thumbnailImage($width, $height);
     // null values allowed
     // write image
     $imagick->writeImage(sprintf('%s/%sx%s-thumbnail-%s.%s', $pathToMediaDirectory, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     $fileObject->setThumbnailLink(sprintf('%s/%sx%s-thumbnail-%s.%s', $httpPathToMediaDir, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     $fileObject->setLocalThumbnailPath(sprintf('%s/%sx%s-thumbnail-%s.%s', $pathToMediaDirectory, $imagick->getImageWidth(), $imagick->getImageHeight(), $fileName, $fileExtension));
     // free up associated resources
     $imagick->destroy();
 }
開發者ID:rmatil,項目名稱:angular-cms,代碼行數:39,代碼來源:ThumbnailHandler.php

示例5: query_formats

 /**
  * @return string[]|bool The formats supported by Imagick, or false
  */
 public static function query_formats()
 {
     try {
         return @Imagick::queryFormats();
     } catch (Exception $ex) {
         return false;
     }
 }
開發者ID:WildCodeSchool,項目名稱:projet-maison_ados_dreux,代碼行數:11,代碼來源:class-image-editor-imagick.php

示例6: __construct

 public function __construct(array $params = array())
 {
     // check which image library to use
     // Imagick (Image Magick) is preferable
     if (extension_loaded('imagick')) {
         $this->sImageLibrary = 'imagick';
         // what image formats does the installed version of Imagick support
         // probably overkill to call as PNG, GIF, JPEG surely supported but done for completeness
         try {
             // Fixes #473915 as queryformats no longer works as a static method.
             $oImagick = new Imagick();
             $aImageFormats = $oImagick->queryFormats();
         } catch (ImagickException $e) {
             error_log($e->getMessage());
         }
         // store supported formats for populating drop downs etc later
         if (in_array('PNG', $aImageFormats)) {
             $this->aImageTypes[] = 'PNG';
         }
         if (in_array('GIF', $aImageFormats)) {
             $this->aImageTypes[] = 'GIF';
         }
         if (in_array('JPG', $aImageFormats)) {
             $this->aImageTypes[] = 'JPG';
         }
     } else {
         // check for GD, if it fails here there is no point continuing as the tool can't generate sprite images
         // without either library
         if (!extension_loaded('gd')) {
             die('GD and Imagick extensions not loaded. This tool requires one of these to generate sprite graphics.');
         }
         $this->sImageLibrary = 'gd';
         // get info about installed GD library to get image types (some versions of GD don't include GIF support)
         $oGD = gd_info();
         // store supported formats for populating drop downs etc later
         if (array_get_value('PNG Support', $oGD)) {
             $this->aImageTypes[] = 'PNG';
         }
         if (array_get_value('GIF Create Support', $oGD)) {
             $this->aImageTypes[] = 'GIF';
         }
         if (array_get_value('JPG Support', $oGD)) {
             $this->aImageTypes[] = 'JPG';
         }
     }
     /*
      * Сразу выполним подготовку
      */
     $GenParams = array('build-direction' => 'vertical', 'vertical-offset' => 2, 'horizontal-offset' => 2, 'background' => '', 'image-output' => strtoupper(SYSTEM_IMG_TYPE), 'image-num-colours' => 'true-colour', 'image-quality' => 75, 'width-resize' => 100, 'height-resize' => 100, 'ignore-duplicates' => 'ignore', 'class-prefix' => 'sprite-', 'selector-prefix' => '', 'selector-suffix' => '', 'wrap-columns' => true, 'use-transparency' => true, 'add-width-height-to-css' => true);
     //Возможность переопределить параметры генерации
     $GenParams = array_merge($GenParams, $params);
     $isOk = $this->ProcessParams($GenParams);
     check_condition($isOk, __CLASS__ . ' prepearing error: ' . print_r($this->aFormErrors, true));
 }
開發者ID:ilivanoff,項目名稱:www,代碼行數:54,代碼來源:ps-css-sprite-gen.inc.php

示例7: supports_mime_type

 /**
  * Checks to see if editor supports the mime-type specified.
  *
  * @since 3.5.0
  * @access public
  *
  * @param string $mime_type
  * @return boolean
  */
 public static function supports_mime_type($mime_type)
 {
     $imagick_extension = strtoupper(self::get_extension($mime_type));
     if (!$imagick_extension) {
         return false;
     }
     try {
         return (bool) Imagick::queryFormats($imagick_extension);
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:rodrigosantanati,項目名稱:WordPress,代碼行數:21,代碼來源:class-wp-image-editor-imagick.php

示例8: Imagick

 function is_supported($format)
 {
     $image = new Imagick();
     $format = strtoupper(trim($format));
     // Theses formats have pb if multipage document
     switch ($format) {
         case 'PDF':
         case 'PS':
         case 'HTML':
             return false;
     }
     return in_array($format, $image->queryFormats());
 }
開發者ID:Kraiany,項目名稱:kraiany_site_docker,代碼行數:13,代碼來源:imagick_new.php

示例9: checkImagick

 public function checkImagick()
 {
     if (extension_loaded('gd')) {
         print_r(gd_info());
     } else {
         echo 'GD is not available.';
     }
     if (extension_loaded('imagick')) {
         $imagick = new Imagick();
         print_r($imagick->queryFormats());
     } else {
         echo 'ImageMagick is not available.';
     }
 }
開發者ID:benkermode,項目名稱:natwalker.com-2015,代碼行數:14,代碼來源:img.php

示例10: setUp

 public function setUp()
 {
     $checkImagick = new \Imagick();
     if (count($checkImagick->queryFormats('SVG')) === 1) {
         parent::setUp();
         $fileName = 'testimagelarge.svg';
         $this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
         $this->width = 3000;
         $this->height = 2000;
         $this->provider = new \OC\Preview\SVG();
     } else {
         $this->markTestSkipped('No SVG provider present');
     }
 }
開發者ID:evanjt,項目名稱:core,代碼行數:14,代碼來源:svg.php

示例11: __construct

 public function __construct()
 {
     // check which image library to use
     // Imagick (Image Magick) is preferable
     if (extension_loaded('imagick')) {
         $this->sImageLibrary = 'imagick';
         // echo "loaded imagick";
         // what image formats does the installed version of Imagick support
         // probably overkill to call as PNG, GIF, JPEG surely supported but done for completeness
         try {
             // Fixes #473915 as queryformats no longer works as a static method.
             $oImagick = new Imagick();
             $aImageFormats = $oImagick->queryFormats();
         } catch (ImagickException $e) {
             error_log($e->getMessage());
         }
         // store supported formats for populating drop downs etc later
         if (in_array('PNG', $aImageFormats)) {
             $this->aImageTypes[] = 'PNG';
         }
         if (in_array('GIF', $aImageFormats)) {
             $this->aImageTypes[] = 'GIF';
         }
         if (in_array('JPG', $aImageFormats)) {
             $this->aImageTypes[] = 'JPG';
         }
     } else {
         // check for GD, if it fails here there is no point continuing as the tool can't generate sprite images
         // without either library
         if (!extension_loaded('gd')) {
             die('GD and Imagick extensions not loaded. This tool requires one of these to generate sprite graphics.');
         }
         $this->sImageLibrary = 'gd';
         // get info about installed GD library to get image types (some versions of GD don't include GIF support)
         $oGD = gd_info();
         // store supported formats for populating drop downs etc later
         if ($oGD['PNG Support']) {
             $this->aImageTypes[] = 'PNG';
         }
         if ($oGD['GIF Create Support']) {
             $this->aImageTypes[] = 'GIF';
         }
         if ($oGD['JPG Support']) {
             $this->aImageTypes[] = 'JPG';
         }
     }
 }
開發者ID:Peter2121,項目名稱:leonardoxc,代碼行數:47,代碼來源:css-sprite-gen.inc.php

示例12: supports_mime_type

 /**
  * Checks to see if editor supports the mime-type specified.
  *
  * @since 3.5.0
  * @access public
  *
  * @param string $mime_type
  * @return boolean
  */
 public static function supports_mime_type($mime_type)
 {
     $imagick_extension = strtoupper(self::get_extension($mime_type));
     if (!$imagick_extension) {
         return false;
     }
     // setIteratorIndex is optional unless mime is an animated format.
     // Here, we just say no if you are missing it and aren't loading a jpeg.
     if (!method_exists('Imagick', 'setIteratorIndex') && $mime_type != 'image/jpeg') {
         return false;
     }
     try {
         return (bool) @Imagick::queryFormats($imagick_extension);
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:Telemedellin,項目名稱:feriadelasfloresmedellin,代碼行數:26,代碼來源:class-wp-image-editor-imagick.php

示例13: checkRequirements

 /**
  * Checks if there is graphic extension available to generate CAPTCHA images.
  *
  * This method will check the existence of ImageMagick and GD extensions.
  *
  * @return string the name of the graphic extension, either "imagick" or "gd".
  * @throws WidgetException if neither ImageMagick nor GD is installed.
  */
 public static function checkRequirements()
 {
     if (extension_loaded('imagick')) {
         $imagick = new \Imagick();
         $imagickFormats = $imagick->queryFormats('PNG');
         if (in_array('PNG', $imagickFormats)) {
             return 'imagick';
         }
     }
     if (extension_loaded('gd')) {
         $gdInfo = gd_info();
         if (!empty($gdInfo['FreeType Support'])) {
             return 'gd';
         }
     }
     throw new WidgetException('GD with FreeType or ImageMagick PHP extensions are required.');
 }
開發者ID:romeoz,項目名稱:rock-widgets,代碼行數:25,代碼來源:CaptchaWidget.php

示例14: checkCaptchaSupport

 public static function checkCaptchaSupport()
 {
     if (extension_loaded('imagick')) {
         $imagick = new Imagick();
         $imagickFormats = $imagick->queryFormats('PNG');
         if (in_array('PNG', $imagickFormats)) {
             return 'ok';
         }
     }
     if (extension_loaded('gd')) {
         $gdInfo = gd_info();
         if ($gdInfo['FreeType Support']) {
             return 'ok';
         }
         return 'GD 庫已安裝,<br />FreeType 未安裝';
     }
     return 'GD or ImageMagick 均未安裝';
 }
開發者ID:sym660,項目名稱:lulucms2,代碼行數:18,代碼來源:Utility.php

示例15: __construct

 /**
  * Check for the imagick extension at creation.
  *
  * @throws Exception
  */
 public function __construct()
 {
     // For simplicity, the check is prepared here, without load of classes.
     // If available, use GD when source and destination formats are managed.
     if (extension_loaded('gd')) {
         $this->_gdMimeTypes = array('image/jpeg' => true, 'image/png' => true, 'image/tiff' => false, 'image/gif' => true, 'application/pdf' => false, 'image/jp2' => false, 'image/webp' => true);
         $gdInfo = gd_info();
         if (empty($gdInfo['GIF Read Support']) || empty($gdInfo['GIF Create Support'])) {
             $this->_gdMimeTypes['image/gif'] = false;
         }
         if (empty($gdInfo['WebP Support'])) {
             $this->_gdMimeTypes['image/webp'] = false;
         }
     }
     if (extension_loaded('imagick')) {
         $iiifMimeTypes = array('image/jpeg' => 'JPG', 'image/png' => 'PNG', 'image/tiff' => 'TIFF', 'image/gif' => 'GIF', 'application/pdf' => 'PDF', 'image/jp2' => 'JP2', 'image/webp' => 'WEBP');
         $this->_imagickMimeTypes = array_intersect($iiifMimeTypes, Imagick::queryFormats());
     }
 }
開發者ID:pabalexa,項目名稱:UniversalViewer4Omeka,代碼行數:24,代碼來源:Auto.php


注:本文中的Imagick::queryFormats方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。