回覆列表
  • 1 # 藍風24

    php_imagick程式示例

    1.建立一個縮圖並顯示出來

    header("Content-type: image/jpeg");

    $image = new Imagick("image.jpg");

    // If 0 is provided as a width or height parameter,// aspect ratio is maintained

    $image->thumbnailImage(100, 0);

    echo $image;

    ?>

    2.建立一個目錄下的縮圖,並儲存

    $images = new Imagick(glob("images/*.JPG"));

    foreach($images as $image) {

    // Providing 0 forces thumbnailImage to maintain aspect ratio

    $image->thumbnailImage(1024,0);

    }

    $images->writeImages();

    ?>

    3.縮略GIF動畫圖片

    /* Create a new imagick object and read in GIF */

    $im = new Imagick(example.gif);

    /* Resize all frames */

    foreach ($im as $frame) {

    /* 50x50 frames */

    $frame->thumbnailImage(50, 50);

    /* Set the virtual canvas to correct size */

    $frame->setImagePage(50, 50, 0, 0);

    }/* Notice writeImages instead of writeImage */

    $im->writeImages(example_small.gif, true);

    ?>

  • 中秋節和大豐收的關聯?
  • 帕金森很難醫治嗎?