Jump to content

Imagick and Thumbnails


-Mike-

Recommended Posts

I'm building an advanced thumbnail generator for my website but am having some issues when try to convert the actual ImageMagick "convert" command into using the Imagick Image Library. Right now I'm using shell_exec to process the command but I am looking to make it to use the library to make my code more uniform. Any help will be appreciated.This is the command:

/usr/local/bin/convert "{$filepath}" -size 1x14 xc:Black  -background Black  -append -gravity South -fill White -draw "text 0,0 '{$filereso['0']}x{$filereso['1']} - {$filesize}" "{$outputpath}";"

I posted this topic in this forum because I'm trying to convert it into PHP but if it is the wrong forum please move or let me know.

Link to comment
Share on other sites

Well, you can do this to create the thumbnail:

$im = new Imagick("image.jpg");$thumb = $im->clone();$thumb->thumbnailImage(100);

I would assume you would use this to draw the rectangle:http://www.php.net/manual/en/function.imag...w-rectangle.phpBut the documentation on php.net doesn't explain how to use it and there aren't any user comments. You can probably find some examples here:http://valokuva.org/?cat=1.

Link to comment
Share on other sites

Well I got the command converted after a little work and for anyone looking to make thumbnails like this one. Try the following code.

<?php$imagick = new Imagick();$canvas = new Imagick();$canvasdraw = new ImagickDraw();$imagick->readImage("shin_chan.jpg");$imagick->thumbnailImage(160, 0);$imagick->setImageFormat("jpeg");$canvas->newImage($imagick->getImageWidth(), ($imagick->getImageHeight() + 14), new ImagickPixel("black"));$canvas->setImageFormat("jpeg");$canvasdraw->setFillColor(new ImagickPixel("white"));$canvasdraw->setFontSize(11);$canvasdraw->setFontWeight(600);$canvasdraw->setGravity(imagick::GRAVITY_SOUTH);$canvas->annotateImage($canvasdraw, 0, 0, 0, "1000x1000 - 16kb");$canvas->compositeImage($imagick, imagick::COMPOSITE_OVER, 0, 0);$canvas->setImageCompression(9);header("Content-Type: image/jpeg");echo $canvas->getImageBlob();?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...