php[tek] 2018 : Call for Speakers


(PECL imagick 2.0.0)

Imagick::clipPathImageClips along the named paths from the 8BIM profile


bool Imagick::clipPathImage ( string $pathname , bool $inside )

Clips along the named paths from the 8BIM profile, if present. Later operations take effect inside the path. It may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.



The name of the path


If TRUE later operations take effect inside clipping path. Otherwise later operations take effect outside clipping path.

Valorile întoarse

Întoarce TRUE în caz de succes.


Emite ImagickException în caz de eroare.

add a note add a note

User Contributed Notes 1 note

Coleman Nitroy
9 years ago
I found Imagick::clipPathImage and Imagic::clipImage did not work as I had expected. I thought they would just clip the path and throw away the extra data and you are done. Not the case.

Here is how I was able to use a clipping path:

      $img = new ("/Path/To/Test/Image.psd");
= ->();

// Uses the first path as the clipping path
->("#1", );

// Fill the clipped part with a color
= new ();
->(,, ::);

// Composite the clipped image with the old image. Set the color of the composite to any color you want to be the outside part.
= new ();
->( ['width'], ['height'], new ("white"), 'png');
->(, ::, , );

      // Copy the image so clip is "saved"
= new ();