Image Magick 설치 확인
웹 호스팅에서 ImageMagic이 서버에 프리 인스톨 되어 있다고 합니다.phpinfo() 출력에서 ImageMagick을 빠르게 검색했지만 아무것도 찾을 수 없었습니다.서버에서 SSH를 할 수 없습니다만, PHP로 인스톨을 확인할 수 있는 방법이 있습니까?
이것은 가능한 한 짧고 달콤한 것입니다.
if (!extension_loaded('imagick'))
echo 'imagick not installed';
이것을 시험해 보세요.
<?php
//This function prints a text array as an html list.
function alist ($array) {
$alist = "<ul>";
for ($i = 0; $i < sizeof($array); $i++) {
$alist .= "<li>$array[$i]";
}
$alist .= "</ul>";
return $alist;
}
//Try to get ImageMagick "convert" program version number.
exec("convert -version", $out, $rcode);
//Print the return code: 0 if OK, nonzero if error.
echo "Version return code is $rcode <br>";
//Print the output of "convert -version"
echo alist($out);
?>
편집: 다음 정보와 스크립트는 iMagick 클래스에만 적용됩니다.ImageMagick 클래스에는 기본적으로 추가되지 않습니다.
imagemagick이 설치되어 있고 실제로 php 확장자로 동작하는지 알고 싶다면 이 스니펫을 웹 액세스 가능한 파일에 붙여넣습니다.
<?php
error_reporting(E_ALL);
ini_set( 'display_errors','1');
/* Create a new imagick object */
$im = new Imagick();
/* Create new image. This will be used as fill pattern */
$im->newPseudoImage(50, 50, "gradient:red-black");
/* Create imagickdraw object */
$draw = new ImagickDraw();
/* Start a new pattern called "gradient" */
$draw->pushPattern('gradient', 0, 0, 50, 50);
/* Composite the gradient on the pattern */
$draw->composite(Imagick::COMPOSITE_OVER, 0, 0, 50, 50, $im);
/* Close the pattern */
$draw->popPattern();
/* Use the pattern called "gradient" as the fill */
$draw->setFillPatternURL('#gradient');
/* Set font size to 52 */
$draw->setFontSize(52);
/* Annotate some text */
$draw->annotation(20, 50, "Hello World!");
/* Create a new canvas object and a white image */
$canvas = new Imagick();
$canvas->newImage(350, 70, "white");
/* Draw the ImagickDraw on to the canvas */
$canvas->drawImage($draw);
/* 1px black border around the image */
$canvas->borderImage('black', 1, 1);
/* Set the format to PNG */
$canvas->setImageFormat('png');
/* Output the image */
header("Content-Type: image/png");
echo $canvas;
?>
hello world 그래픽이 표시됩니다.
배시:
$ convert -version
또는
$ /usr/local/bin/convert -version
확인을 위해 PHP 파일을 쓸 필요는 없습니다.
Imagick 클래스는 PHP에서 쉽게 확인할 수 있습니다.
if( class_exists("Imagick") )
{
//Imagick is installed
}
Bash에서 Imagick이 설치된 모듈인지 확인할 수 있습니다.
$ php -m | grep imagick
응답이 공백일 경우 설치되지 않습니다.
Image Magick이 어디에 있는지, 액세스할 수 있다면 이 원샷 솔루션을 사용해 보십시오.
고다디 진행에서 모든 버전을 찾았어요
이 파일을 서버에 업로드하고 호출합니다.ImageMagick.php
아니면 다른 것을 실행하세요.필요한 모든 정보를 얻을 수 있습니다.바라건대...
행운을 빌어요.
<?
/*
// This file will run a test on your server to determine the location and versions of ImageMagick.
//It will look in the most commonly found locations. The last two are where most popular hosts (including "Godaddy") install ImageMagick.
//
// Upload this script to your server and run it for a breakdown of where ImageMagick is.
//
*/
echo '<h2>Test for versions and locations of ImageMagick</h2>';
echo '<b>Path: </b> convert<br>';
function alist ($array) { //This function prints a text array as an html list.
$alist = "<ul>";
for ($i = 0; $i < sizeof($array); $i++) {
$alist .= "<li>$array[$i]";
}
$alist .= "</ul>";
return $alist;
}
exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of "convert -version"
echo '<br>';
echo '<b>This should test for ImageMagick version 5.x</b><br>';
echo '<b>Path: </b> /usr/bin/convert<br>';
exec("/usr/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of "convert -version"
echo '<br>';
echo '<b>This should test for ImageMagick version 6.x</b><br>';
echo '<b>Path: </b> /usr/local/bin/convert<br>';
exec("/usr/local/bin/convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of "convert -version";
?>
IMagick PHP 확장자(ImageMagick 스위트 전체가 아님)만을 테스트하려면 다음을 PHP 파일(testImagick.php)로 저장한 후 콘솔에서 실행합니다.php
<?php
$image = new Imagick();
$image->newImage(1, 1, new ImagickPixel('#ffffff'));
$image->setImageFormat('png');
$pngData = $image->getImagesBlob();
echo strpos($pngData, "\x89PNG\r\n\x1a\n") === 0 ? 'Ok' : 'Failed';
echo "\n";
크레딧 : https://mlocati.github.io/articles/php-windows-imagick.html
ISP/호스팅 서비스가 ImageMagick을 설치하고 PATH 환경변수에 위치를 지정한 경우 설치된 버전과 사용처를 확인할 수 있습니다.
<?php
echo "<pre>";
system("type -a convert");
echo "</pre>";
?>
Imagick(또는 실제로 PHP 모듈)을 설치한 후 모듈을 phpinfo()로 표시하려면 웹 서버 및/또는 php-fpm을 재시작해야 합니다.
언급URL : https://stackoverflow.com/questions/4208253/verify-imagemagick-installation
'itsource' 카테고리의 다른 글
vue.flash 워치가 업데이트되지 않았습니다. (0) | 2022.12.04 |
---|---|
Angular JS를 사용하여 부트스트랩 네비게이션바의 액티브클래스를 설정하려면 어떻게 해야 하나요? (0) | 2022.12.04 |
JSON Jackson에 대한 날짜 형식 매핑 (0) | 2022.12.04 |
특성 함수를 재정의하고 재정의된 함수에서 호출하려면 어떻게 해야 합니까? (0) | 2022.12.04 |
유닛 테스트를 PHP로 작성하려면 어떻게 해야 하나요? (0) | 2022.12.04 |