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; }
/** * 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()); }
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]); }
/** * 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(); }
/** * @return string[]|bool The formats supported by Imagick, or false */ public static function query_formats() { try { return @Imagick::queryFormats(); } catch (Exception $ex) { return false; } }
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)); }
/** * 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; } }
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()); }
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.'; } }
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'); } }
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'; } } }
/** * 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; } }
/** * 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.'); }
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 均未安装'; }
/** * 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()); } }
function checkCaptchaSupport() { if (extension_loaded('imagick')) { $imagick = new Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); } if (extension_loaded('gd')) { $gdInfo = gd_info(); } if (isset($imagickFormats) && in_array('PNG', $imagickFormats)) { return ''; } elseif (isset($gdInfo)) { if ($gdInfo['FreeType Support']) { return ''; } return t('yii', 'GD installed,<br />FreeType support not installed'); } return t('yii', 'GD or ImageMagick not installed'); }
public function __construct($ImageLibrary, $aFormValues) { if ($ImageLibrary == '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 { $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'; } } $this->aFormValues = $aFormValues; $this->aFormValues = array('path' => '', 'sub' => '', 'file-regex' => '', 'wrap-columns' => $aFormValues['wrap-columns'], 'build-direction' => $aFormValues['build-direction'], 'use-transparency' => 'on', 'use-optipng' => '', 'vertical-offset' => 50, 'horizontal-offset' => 50, 'background' => '', 'image-output' => $aFormValues['image-output'], 'image-num-colours' => 'true-colour', 'image-quality' => 75, 'width-resize' => 100, 'height-resize' => 100, 'ignore-duplicates' => 'merge', 'class-prefix' => '', 'selector-prefix' => '', 'selector-suffix' => '', 'add-width-height-to-css' => 'off'); }
/** * 检测具体的图像扩展是否加载。 * @param string 要检测的扩展名。可能值为 'gd', 'imagick' 和 null. * 默认值为null,意味着两种扩展都将被检查。 * @return boolean true如果支持PNG的ImageMagick扩展或支持FreeType的GD扩展已经加载,否则返回false。 */ public static function checkRequirements($extension = null) { if (extension_loaded('imagick')) { $imagick = new \Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); } if (extension_loaded('gd')) { $gdInfo = gd_info(); } if ($extension === null) { if (isset($imagickFormats) && in_array('PNG', $imagickFormats)) { return true; } if (isset($gdInfo) && $gdInfo['FreeType Support']) { return true; } } elseif ($extension == 'imagick' && isset($imagickFormats) && in_array('PNG', $imagickFormats)) { return true; } elseif ($extension == 'gd' && isset($gdInfo) && $gdInfo['FreeType Support']) { return true; } return false; }
} \Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem(dirname(__FILE__) . '/templates/'); $twig = new \Twig_Environment($loader); /* Information about maximum upload sizes */ $maxPostSize = PartKeepr::getBytesFromHumanReadable(ini_get("post_max_size")); $maxFileSize = PartKeepr::getBytesFromHumanReadable(ini_get("upload_max_filesize")); $aParameters["maxUploadSize"] = min($maxPostSize, $maxFileSize); if (!class_exists("Imagick")) { $template = $twig->loadTemplate("error.tpl"); echo $template->render(array("title" => PartKeepr::i18n("ImageMagick is not installed"), "error" => PartKeepr::i18n("You are missing the ImageMagick extension. Please install it and restart the setup to verify that the library was installed correctly."))); exit; } /* ImageMagick formats */ $imagick = new \Imagick(); $aParameters["availableImageFormats"] = $imagick->queryFormats(); /* Automatic Login */ if (Configuration::getOption("partkeepr.frontend.autologin.enabled", false) === true) { $aParameters["autoLoginUsername"] = Configuration::getOption("partkeepr.frontend.autologin.username"); $aParameters["autoLoginPassword"] = Configuration::getOption("partkeepr.frontend.autologin.password"); } if (Configuration::getOption("partkeepr.frontend.motd", false) !== false) { $aParameters["motd"] = Configuration::getOption("partkeepr.frontend.motd"); } /* Load and render the template */ $template = $twig->loadTemplate("index.tpl"); $renderParams = array(); $renderParams["debug_all"] = Configuration::getOption("partkeepr.frontend.debug_all", false); $renderParams["debug"] = Configuration::getOption("partkeepr.frontend.debug", false); $renderParams["parameters"] = $aParameters; if ($renderParams["debug_all"]) {
/** * @return array Image formats, supported by current image manipulation driver. * The only formats that being checked are jpg, png and gif. */ public static function getSupportedFormats() { $imagine = Tygh::$app['image']; $supported_formats = array(); if ($imagine instanceof \Imagine\Imagick\Imagine) { $imagick = new \Imagick(); $supported_formats = array_uintersect(array('jpg', 'png', 'gif'), $imagick->queryFormats(), 'strcasecmp'); $supported_formats = array_map('strtolower', $supported_formats); $imagick->clear(); $imagick->destroy(); unset($imagick); } elseif ($imagine instanceof \Imagine\Gd\Imagine) { $gd_formats = imagetypes(); if ($gd_formats & IMG_JPEG) { $supported_formats[] = 'jpg'; } if ($gd_formats & IMG_PNG) { $supported_formats[] = 'png'; } if ($gd_formats & IMG_GIF) { $supported_formats[] = 'gif'; } } return $supported_formats; }
function ewww_image_optimizer_imagick_support() { ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>'); if (extension_loaded('imagick')) { $imagick = new Imagick(); $formats = $imagick->queryFormats(); if (in_array('PNG', $formats) && in_array('JPG', $formats)) { return true; } } return false; }
protected static function registerCoreProviders() { self::registerProvider('OC\\Preview\\TXT'); self::registerProvider('OC\\Preview\\MarkDown'); self::registerProvider('OC\\Preview\\Image'); self::registerProvider('OC\\Preview\\MP3'); // SVG, Office and Bitmap require imagick if (extension_loaded('imagick')) { $checkImagick = new \Imagick(); $imagickProviders = array('SVG' => 'OC\\Preview\\SVG', 'TIFF' => 'OC\\Preview\\TIFF', 'PDF' => 'OC\\Preview\\PDF', 'AI' => 'OC\\Preview\\Illustrator', 'PSD' => 'OC\\Preview\\Photoshop', 'EPS' => 'OC\\Preview\\Postscript'); foreach ($imagickProviders as $queryFormat => $provider) { if (count($checkImagick->queryFormats($queryFormat)) === 1) { self::registerProvider($provider); } } if (count($checkImagick->queryFormats('PDF')) === 1) { // Office previews are currently not supported on Windows if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) { $officeFound = is_string(\OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null)); if (!$officeFound) { //let's see if there is libreoffice or openoffice on this machine $whichLibreOffice = shell_exec('command -v libreoffice'); $officeFound = !empty($whichLibreOffice); if (!$officeFound) { $whichOpenOffice = shell_exec('command -v openoffice'); $officeFound = !empty($whichOpenOffice); } } if ($officeFound) { self::registerProvider('OC\\Preview\\MSOfficeDoc'); self::registerProvider('OC\\Preview\\MSOffice2003'); self::registerProvider('OC\\Preview\\MSOffice2007'); self::registerProvider('OC\\Preview\\OpenDocument'); self::registerProvider('OC\\Preview\\StarOffice'); } } } } // Video requires avconv or ffmpeg and is therefor // currently not supported on Windows. if (!\OC_Util::runningOnWindows()) { $avconvBinary = \OC_Helper::findBinaryPath('avconv'); $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg'); if ($avconvBinary || $ffmpegBinary) { // FIXME // a bit hacky but didn't want to use subclasses \OC\Preview\Movie::$avconvBinary = $avconvBinary; \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary; self::registerProvider('OC\\Preview\\Movie'); } } }
/** * 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 InvalidConfigException 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 InvalidConfigException('Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required.'); }
/** * 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']); } /** * Takes an image filename and returns an Imagick image object * * @param string $imgfile the full path and filename of the image to load * @throws ImagickException * @return Imagick
/** * Проверяем возможность использования расширения PHP GD: * (приватные методы функции, начинаются с подчёркивания) * * @return string **/ private function _checkCaptchaSupport() { if (extension_loaded('imagick')) { $imagick = new Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); } if (extension_loaded('gd')) { $gdInfo = gd_info(); } if (isset($imagickFormats) && in_array('PNG', $imagickFormats)) { return ''; } else { if (isset($gdInfo)) { if ($gdInfo['FreeType Support']) { return ''; } return Yii::t('InstallModule.install', 'GD extension installed {br} without the support of FreeType', ['{br}' => '<br />']); } } return Yii::t('InstallModule.install', 'ImageMagick or GD extension is not installed'); }
public static function getCheckList($checkGroup = "") { $checkLists = ["Checking Directory Permission" => [["title" => 'Checking base directory permissions', "check" => function () { return Setting::checkPath(Setting::getBasePath(), true); }], ["title" => 'Checking app directory permissions', "check" => function () { return Setting::checkPath(Setting::getAppPath()); }], ["title" => 'Checking assets directory permissions', "check" => function () { return Setting::checkPath(Setting::getAssetPath(), true); }], ["title" => 'Checking runtime directory permissions', "check" => function () { return Setting::checkPath(Setting::getRuntimePath(), true); }], ["title" => 'Checking config directory permissions', "check" => function () { return Setting::checkPath(Setting::getConfigPath(), true); }], ["title" => 'Checking repository directory permissions', "check" => function () { $repo = Setting::get('repo.path'); if (!is_dir($repo)) { @mkdir($repo, 0777, true); } return Setting::checkPath(realpath($repo), true); }]], "Checking Framework Requirements" => [['title' => 'Checking PHP Version ( > 5.5.0 )', 'check' => function () { $result = version_compare(PHP_VERSION, "5.5.0", ">"); $msg = "Current PHP version is:" . PHP_VERSION; return $result !== true ? $msg : true; }], ['title' => 'Reflection Extension', 'check' => function () { $result = class_exists('Reflection', false); $msg = "Reflection class does not exists!"; return $result !== true ? $msg : true; }], ['title' => 'PCRE Extension', 'check' => function () { $result = extension_loaded("pcre"); $msg = "Extension \"pcre\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'SPL extension', 'check' => function () { $result = extension_loaded("SPL"); $msg = "Extension \"SPL\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'DOM extension', 'check' => function () { $result = class_exists("DOMDocument", false); $msg = "DomDocument class does not exists!"; return $result !== true ? $msg : true; }], ['title' => 'PDO extension', 'check' => function () { $result = extension_loaded("pdo"); $msg = "Extension \"pdo\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'PDO MySQL extension', 'check' => function () { $result = extension_loaded("pdo_mysql"); $msg = "Extension \"pdo_mysql\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'Mcrypt extension', 'check' => function () { $result = extension_loaded("mcrypt"); $msg = "Extension \"mcrypt\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'CURL extension', 'check' => function () { $result = extension_loaded("curl"); $msg = "Extension \"curl\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'GD extension with FreeType support<br />or ImageMagick extension with <br/> PNG support', 'check' => function () { if (extension_loaded('imagick')) { $imagick = new Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); } if (extension_loaded('gd')) { $gdInfo = gd_info(); } if (isset($imagickFormats) && in_array('PNG', $imagickFormats)) { return true; } elseif (isset($gdInfo)) { if ($gdInfo['FreeType Support']) { return true; } return "GD Extension is loaded but no Freetype support"; } return "GD Extension / ImageMagick is not loaded"; }], ['title' => 'Ctype extension', 'check' => function () { $result = extension_loaded("ctype"); $msg = "Extension \"ctype\" is not loaded"; return $result !== true ? $msg : true; }], ['title' => 'Checking Server variables', 'check' => function () { return Installer::checkServerVar(); }]]]; if ($checkGroup == "") { return $checkLists; } else { return [$checkGroup => $checkLists[$checkGroup]]; } }
<?php /** * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ //both, libreoffice backend and php fallback, need imagick if (extension_loaded('imagick')) { $checkImagick = new Imagick(); if (count($checkImagick->queryFormats('PDF')) === 1) { $isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec'); // LibreOffice preview is currently not supported on Windows if (!\OC_Util::runningOnWindows()) { $whichLibreOffice = $isShellExecEnabled ? shell_exec('command -v libreoffice') : ''; $isLibreOfficeAvailable = !empty($whichLibreOffice); $whichOpenOffice = $isShellExecEnabled ? shell_exec('command -v libreoffice') : ''; $isOpenOfficeAvailable = !empty($whichOpenOffice); //let's see if there is libreoffice or openoffice on this machine if ($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { require_once 'office-cl.php'; } } } }
/** * Register the default providers (if enabled) */ protected function registerCoreProviders() { if ($this->registeredCoreProviders) { return; } $this->registeredCoreProviders = true; $this->registerCoreProvider('OC\\Preview\\TXT', '/text\\/plain/'); $this->registerCoreProvider('OC\\Preview\\MarkDown', '/text\\/(x-)?markdown/'); $this->registerCoreProvider('OC\\Preview\\PNG', '/image\\/png/'); $this->registerCoreProvider('OC\\Preview\\JPEG', '/image\\/jpeg/'); $this->registerCoreProvider('OC\\Preview\\GIF', '/image\\/gif/'); $this->registerCoreProvider('OC\\Preview\\BMP', '/image\\/bmp/'); $this->registerCoreProvider('OC\\Preview\\XBitmap', '/image\\/x-xbitmap/'); $this->registerCoreProvider('OC\\Preview\\MP3', '/audio\\/mpeg/'); // SVG, Office and Bitmap require imagick if (extension_loaded('imagick')) { $checkImagick = new \Imagick(); $imagickProviders = ['SVG' => ['mimetype' => '/image\\/svg\\+xml/', 'class' => '\\OC\\Preview\\SVG'], 'TIFF' => ['mimetype' => '/image\\/tiff/', 'class' => '\\OC\\Preview\\TIFF'], 'PDF' => ['mimetype' => '/application\\/pdf/', 'class' => '\\OC\\Preview\\PDF'], 'AI' => ['mimetype' => '/application\\/illustrator/', 'class' => '\\OC\\Preview\\Illustrator'], 'PSD' => ['mimetype' => '/application\\/x-photoshop/', 'class' => '\\OC\\Preview\\Photoshop'], 'EPS' => ['mimetype' => '/application\\/postscript/', 'class' => '\\OC\\Preview\\Postscript'], 'TTF' => ['mimetype' => '/application\\/(?:font-sfnt|x-font$)/', 'class' => '\\OC\\Preview\\Font']]; foreach ($imagickProviders as $queryFormat => $provider) { $class = $provider['class']; if (!in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) { continue; } if (count($checkImagick->queryFormats($queryFormat)) === 1) { $this->registerCoreProvider($class, $provider['mimetype']); } } if (count($checkImagick->queryFormats('PDF')) === 1) { // Office previews are currently not supported on Windows if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) { $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null)); if (!$officeFound) { //let's see if there is libreoffice or openoffice on this machine $whichLibreOffice = shell_exec('command -v libreoffice'); $officeFound = !empty($whichLibreOffice); if (!$officeFound) { $whichOpenOffice = shell_exec('command -v openoffice'); $officeFound = !empty($whichOpenOffice); } } if ($officeFound) { $this->registerCoreProvider('\\OC\\Preview\\MSOfficeDoc', '/application\\/msword/'); $this->registerCoreProvider('\\OC\\Preview\\MSOffice2003', '/application\\/vnd.ms-.*/'); $this->registerCoreProvider('\\OC\\Preview\\MSOffice2007', '/application\\/vnd.openxmlformats-officedocument.*/'); $this->registerCoreProvider('\\OC\\Preview\\OpenDocument', '/application\\/vnd.oasis.opendocument.*/'); $this->registerCoreProvider('\\OC\\Preview\\StarOffice', '/application\\/vnd.sun.xml.*/'); } } } } // Video requires avconv or ffmpeg and is therefor // currently not supported on Windows. if (in_array('OC\\Preview\\Movie', $this->getEnabledDefaultProvider()) && !\OC_Util::runningOnWindows()) { $avconvBinary = \OC_Helper::findBinaryPath('avconv'); $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg'); if ($avconvBinary || $ffmpegBinary) { // FIXME // a bit hacky but didn't want to use subclasses \OC\Preview\Movie::$avconvBinary = $avconvBinary; \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary; $this->registerCoreProvider('\\OC\\Preview\\Movie', '/video\\/.*/'); } } }
// you may need to adjust this path to the correct Yii framework path $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2'; if (!is_dir($frameworkPath)) { echo '<h1>Error</h1>'; echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>'; echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>'; echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>'; } //teste require_once $frameworkPath . '/requirements/YiiRequirementChecker.php'; $requirementsChecker = new YiiRequirementChecker(); $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; $gdOK = $imagickOK = false; if (extension_loaded('imagick')) { $imagick = new Imagick(); $imagickFormats = $imagick->queryFormats('PNG'); if (in_array('PNG', $imagickFormats)) { $imagickOK = true; } else { $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; } } if (extension_loaded('gd')) { $gdInfo = gd_info(); if (!empty($gdInfo['FreeType Support'])) { $gdOK = true; } else { $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; } } /**
} else { return gettext('The <strong><em>Imagick</em></strong> extension is not available.'); } return ''; } } /** * Image manipulation functions using the Imagick library */ if ($_zp_imagick_present && (getOption('use_imagick') || !extension_loaded('gd'))) { $_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']); $_imagick_format_whitelist = array('BMP' => 'jpg', 'BMP2' => 'jpg', 'BMP3' => 'jpg', 'GIF' => 'gif', 'GIF87' => 'gif', 'JPG' => 'jpg', 'JPEG' => 'jpg', 'PNG' => 'png', 'PNG8' => 'png', 'PNG24' => 'png', 'PNG32' => 'png', 'TIFF' => 'jpg', 'TIFF64' => 'jpg'); $_imagick = new Imagick(); $_imagick_formats = $_imagick->queryFormats(); foreach ($_imagick_formats as $format) { if (array_key_exists($format, $_imagick_format_whitelist)) { $_lib_Imagick_info[$format] = $_imagick_format_whitelist[$format]; } } // set chroma sampling from option if exists $_chromaSampling = getOption('magick_sampling_factor'); if (!empty($_chromaSampling)) { $_imagick->setSamplingFactors(explode(' ', $_chromaSampling)); } unset($_chromaSampling); unset($_imagick_format_whitelist); unset($_imagick_formats); unset($_imagick); unset($format);