PHP.mk документација

Imagick::clipPathImage

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

imagick.clippathimage.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека imagick.clippathimage.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Imagick::clipPathImage

Референца за `imagick.clippathimage.php` со подобрена типографија и навигација.

imagick.clippathimage.php

Imagick::clipPathImage

(PECL imagick 2, PECL imagick 3)

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

= NULL

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

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.

Параметри

pathname

The name of the path

inside

Враќа true later operations take effect inside clipping path. Otherwise later operations take effect outside clipping path.

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успешен исход.

Errors/Exceptions

Фрла ImagickException при грешка.

Белешки од корисници 1 белешка

Coleman Nitroy
пред 18 години
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:

<?php
      $img = new Imagick("/Path/To/Test/Image.psd");
      $geometry = $img->getImageGeometry();

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

      // Fill the clipped part with a color
      $draw = new ImagickDraw();
      $draw->setFillColor("#000000");
      $draw->color(0,0, imagick::PAINT_RESET);
      $img->drawImage($draw);

      // Composite the clipped image with the old image. Set the color of the composite to any color you want to be the outside part.
      $composite = new Imagick($path);
      $composite->newImage( $geometry['width'], $geometry['height'], new ImagickPixel("white"), 'png');
      $composite->compositeImage($img, imagick::COMPOSITE_COPY, 0, 0);
?>

Then doing any resizing or creating thumbnails from the resulting image  disregarded all the previous commands so I "saved" it and started with a new Imagick object

<?php
      // Copy the image so clip is "saved"
      $clipped = new Imagick();
      $clipped->readImageBlob($composite->getImageBlob());
?>

I'm sure there is a simpler way, but this took me awhile to get right and there were some hurdles to cross so I hope it is able to help someone on the way.

This is all the convert equivalent of:

$ convert Test.psd -fill white -colorspace rgb -draw "color 0 0 reset" -clip -colorspace rgb -draw "Image Copy 0,0 0,0 'Test.psd'" OutputFile.png
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.