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

Imagick::getPixelIterator

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

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

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

imagick.getpixeliterator.php

Imagick::getPixelIterator

(PECL imagick 2, PECL imagick 3)

Imagick::getPixelIteratorВраќа MagickPixelIterator

= NULL

public function Imagick::getPixelIterator(): ImagickPixelIterator

Враќа MagickPixelIterator.

Параметри

Оваа функција нема параметри.

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

Враќа ImagickPixelIterator на успех.

Errors/Exceptions

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

Примери

Пример #1 (PECL imagick 2, PECL imagick 3)

<?php
function getPixelIterator($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imageIterator = $imagick->getPixelIterator();

    foreach ($imageIterator as $row => $pixels) { /* Loop through pixel rows */
        foreach ($pixels as $column => $pixel) { /* Loop through the pixels in the row (columns) */
            /** @var $pixel \ImagickPixel */
            if ($column % 2) {
                $pixel->setColor("rgba(0, 0, 0, 0)"); /* Paint every second pixel black*/
            }
        }
        $imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
    }

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

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

Себастијан Херолд
пред 18 години
For me it was very helpful to read a article at Mikko's blog. He showed that the PixelIterator is not read-only, if you sync it regularly:

<?php
      /* Create new object with the image */
      $im = new Imagick( "strawberry.png" );

      /* Get iterator */
      $it = $im->getPixelIterator();
       
      /* Loop trough pixel rows */
      foreach( $it as $row => $pixels )
      {
          /* For every second row */
          if ( $row % 2 )
          {
              /* Loop trough the pixels in the row (columns) */
              foreach ( $pixels as $column => $pixel )
              {
                      /* Paint every second pixel black*/
                      if ( $column % 2 )
                      {
                              $pixel->setColor( "black" );
                      }
              }

          }
         
          /* Sync the iterator, this is important to do on each iteration */
          $it->syncIterator();
      }
       
      /* Display the image */
      header( "Content-Type: image/png" );
      echo $im;
       
?>
Навигација

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

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

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

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

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

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

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