La función ImagickPixelIterator::setIteratorFirstRow() es una función incorporada en PHP que se usa para establecer el iterador de píxeles en la primera fila de píxeles.
Sintaxis:
bool ImagickPixelIterator::setIteratorFirstRow( void )
Parámetros: Esta función no acepta ningún parámetro.
Valor de retorno: esta función devuelve VERDADERO en caso de éxito.
Los siguientes programas ilustran la función ImagickPixelIterator::setIteratorFirstRow() en PHP:
Programa 1:
<?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the pixel iterator $pixelIterator = $imagick->getPixelIterator(); // Set the pixel iterator to 50 $pixelIterator->setIteratorRow(50); // Get the current iterator row echo "Current row is " . $pixelIterator->getIteratorRow(); // Set the iterator to first row $pixelIterator->setIteratorFirstRow(); // Get the current iterator row echo "<br>Current row is " . $pixelIterator->getIteratorRow(); ?>
Producción:
Current row is 50 Current row is 0
Programa 2:
<?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the pixel iterator $pixelIterator = $imagick->getPixelIterator(); $pixelIterator->setIteratorRow(40); // Get the current iterator row $row = $pixelIterator->getCurrentIteratorRow(); echo "Colors of 61th and 62nd pixel from 40th row are:<br>"; print("Pixel 60:" . "<pre>".print_r($row[60]->getColor(), true)."</pre>"); print("Pixel 61:" . "<pre>".print_r($row[61]->getColor(), true)."</pre>"); // Set the iterator to first row $pixelIterator->setIteratorFirstRow(); // Get the current iterator row $row = $pixelIterator->getCurrentIteratorRow(); echo "First two colors of pixels from first row are:<br>"; print("Pixel 1:" . "<pre>".print_r($row[0]->getColor(), true)."</pre>"); print("Pixel 2:" . "<pre>".print_r($row[1]->getColor(), true)."</pre>"); ?>
Producción:
Colors of 61th and 62nd pixel from 40th row are: Pixel 60: Array ( [r] => 110 [g] => 199 [b] => 131 [a] => 1 ) Pixel 61: Array ( [r] => 23 [g] => 165 [b] => 57 [a] => 1 ) First two colors of pixels from first row are: Pixel 1: Array ( [r] => 255 [g] => 255 [b] => 255 [a] => 1 ) Pixel 2: Array ( [r] => 255 [g] => 255 [b] => 255 [a] => 1 )
Referencia: https://www.php.net/manual/en/imagickpixeliterator.setiteratorfirstrow.php