Imagick::optimizeImageLayers

Removes repeated portions of images to optimize

&reftitle.description; public `bool` `Imagick::optimizeImageLayers`

Compares each image the GIF disposed forms of the previous image in the sequence. From this it attempts to select the smallest cropped image to replace each frame, while preserving the results of the animation. &imagick.method.available.0x629;

&reftitle.parameters; &no.function.parameters;
&reftitle.returnvalues;

&imagick.return.success;

&reftitle.errors;

&imagick.imagick.throws;

&reftitle.examples;

### Using `Imagick::optimizeImageLayers`

Reading, optimizing and writing a GIF image

    <?php
    /* create new imagick object */
    $im = new Imagick("test.gif");

    /* optimize the image layers */
    $im->optimizeImageLayers();

    /* write the image back */
    $im->writeImages("test_optimized.gif", true);
    ?>

&reftitle.seealso;

- `Imagick::compareImageLayers`
- `Imagick::writeImages`
- `Imagick::writeImage`