โดย eange08 » 24/12/2020 7:42 pm
ทำการติดตั้ง imagick บน ubuntu ไปเรียบร้อยแล้ว แต่พอเรียกใช้กับ php ขึ้น Error
อยากจะทราบว่า
1. ต้อง load ไฟล์ dll ของ imagick ได้ที่ไหนและต้องวางที่ใด
2. ในส่วนของไฟล์ php.ini บน ubuntu จะต้องใส่ extention ของ imagick ใน path ใด
เพราะ php.ini จะมีอยู่ในโฟลเดอร์ที่เป็น PHP ที่อยู่ใน etc กับ opt
Error :
โค้ด: เลือกทั้งหมด
Fatal error: Uncaught Error: Class 'Imagick' not found in /opt/lampp/htdocs/imagick/imagick_example.php:3 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/imagick/imagick_example.php on line 3
ส่วนของ code
โค้ด: เลือกทั้งหมด
<?php
/* Read the image */
$im = new Imagick("test.jpg");
/* Thumbnail the image */
$im->thumbnailImage(200, null);
/* Create a border for the image */
$im->borderImage(new ImagickPixel("white"), 5, 5);
/* Clone the image and flip it */
$reflection = $im->clone();
$reflection->flipImage();
/* Create gradient. It will be overlayd on the reflection */
$gradient = new Imagick();
/* Gradient needs to be large enough for the image and the borders */
$gradient->newPseudoImage($reflection->getImageWidth() + 10, $reflection->getImageHeight() + 10, "gradient:transparent-black");
/* Composite the gradient on the reflection */
$reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);
/* Add some opacity. Requires ImageMagick 6.2.9 or later */
$reflection->setImageOpacity( 0.3 );
/* Create an empty canvas */
$canvas = new Imagick();
/* Canvas needs to be large enough to hold the both images */
$width = $im->getImageWidth() + 40;
$height = ($im->getImageHeight() * 2) + 30;
$canvas->newImage($width, $height, new ImagickPixel("black"));
$canvas->setImageFormat("png");
/* Composite the original image and the reflection on the canvas */
$canvas->compositeImage($im, imagick::COMPOSITE_OVER, 20, 10);
$canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 20, $im->getImageHeight() + 10);
/* Output the image*/
header("Content-Type: image/png");
echo $canvas;
?>
ทำการติดตั้ง imagick บน ubuntu ไปเรียบร้อยแล้ว แต่พอเรียกใช้กับ php ขึ้น Error
อยากจะทราบว่า
1. ต้อง load ไฟล์ dll ของ imagick ได้ที่ไหนและต้องวางที่ใด
2. ในส่วนของไฟล์ php.ini บน ubuntu จะต้องใส่ extention ของ imagick ใน path ใด
เพราะ php.ini จะมีอยู่ในโฟลเดอร์ที่เป็น PHP ที่อยู่ใน etc กับ opt
Error :
[code]Fatal error: Uncaught Error: Class 'Imagick' not found in /opt/lampp/htdocs/imagick/imagick_example.php:3 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/imagick/imagick_example.php on line 3[/code]
ส่วนของ code
[code]<?php
/* Read the image */
$im = new Imagick("test.jpg");
/* Thumbnail the image */
$im->thumbnailImage(200, null);
/* Create a border for the image */
$im->borderImage(new ImagickPixel("white"), 5, 5);
/* Clone the image and flip it */
$reflection = $im->clone();
$reflection->flipImage();
/* Create gradient. It will be overlayd on the reflection */
$gradient = new Imagick();
/* Gradient needs to be large enough for the image and the borders */
$gradient->newPseudoImage($reflection->getImageWidth() + 10, $reflection->getImageHeight() + 10, "gradient:transparent-black");
/* Composite the gradient on the reflection */
$reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);
/* Add some opacity. Requires ImageMagick 6.2.9 or later */
$reflection->setImageOpacity( 0.3 );
/* Create an empty canvas */
$canvas = new Imagick();
/* Canvas needs to be large enough to hold the both images */
$width = $im->getImageWidth() + 40;
$height = ($im->getImageHeight() * 2) + 30;
$canvas->newImage($width, $height, new ImagickPixel("black"));
$canvas->setImageFormat("png");
/* Composite the original image and the reflection on the canvas */
$canvas->compositeImage($im, imagick::COMPOSITE_OVER, 20, 10);
$canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 20, $im->getImageHeight() + 10);
/* Output the image*/
header("Content-Type: image/png");
echo $canvas;
?>
[/code]