Thumbnails mit PHP & ImageMagick erstellen
Wednesday, 22 October 2008
Mit PHP (php5-gd) Thumbnails zu erzeugen war für mich immer ein Gefrickel ohne Ende. Mit ImageMagick geht das allerdings ganz leicht.
Mittels shell_exec() und “convert” lassen sich einfach Thumbnails erzeugen:
// erzeugt ein Thumbnail mit 200 Pixel Breit $ convert -thumbnail 200 foo.png thumb.foo.png // erzeugt ein Thumbnail mit 200 Pixel Höhe $ convert -thumbnail x200 foo.png thumb.foo.png
Beispiel:
/*
* creates the thumbnail
* "foo_small.png" with
* 200px height
*/
$image = "foo.png";
$thumb = "foo_small.png";
$cmd = "convert -thumbnail x200 ".$image." ".$thumb;
shell_exec($cmd);
No. 1 — January 30th, 2009 at 10:04
Thx for that…
No. 2 — March 5th, 2009 at 18:48
Danke schön!