Thumbnails mit PHP & ImageMagick erstellen

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);

2 Responses to “Thumbnails mit PHP & ImageMagick erstellen”

  1. Sebastian writes:

    Thx for that…

  2. Kamil writes:

    Danke schön!