|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58880 Implement some kind of direct pixel access?
Submitted: 2009-10-06 13:55 UTC Modified: 2010-06-19 04:24 UTC
From: evan at digitalflophouse dot com Assigned: vitoc (profile)
Status: Closed Package: gmagick (PECL)
PHP Version: 5.2.6 OS: Ubuntu 9.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: evan at digitalflophouse dot com
New email:
PHP Version: OS:


 [2009-10-06 13:55 UTC] evan at digitalflophouse dot com
It would be very useful to have some kind of direct access to colors at a given pixel coordinate, or (even better) to have some kind of pixel iterator access.

Imagick currently does this with the Imagick::getImagePixelColor method or the ImagickPixelIterator class.

Reproduce code:

an example of how it could work (similar to
Imagick's implementation)
$image = new Gmagick();
$iterator = $image->getpixeliterator();

foreach($iterator as $row) {
    foreach ($row as $pixel) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-19 04:24 UTC]
PixelIterator is not included to be consistent with the interface of the GraphicsMagick Wand C library. 
There are many ways of getting to pixels. For example, one way of getting a 2D matrix of available pixels is as follows:

$gmagick = new Gmagick_Fuzzy("magick:rose");


class Gmagick_Fuzzy extends Gmagick
     * Returns the fuzzy color grid of the instantiated image given a size of 
     * grid in pixels
     * @param int $gridSize
     * @return array
    public function getFuzzyColorGrid($gridSize)
        $colorGrid = array();
        for ($i = 0; $i < $this->getImageWidth(); $i += $gridSize) {
            for ($j = 0; $j < $this->getImageHeight(); $j += $gridSize) {
                $cropped   = clone $this;
                $histogram = $cropped->cropImage($gridSize, $gridSize, $i, $j)
                ->quantizeImage(1, Gmagick::COLORSPACE_RGB, 0, false, false)
                $colorGrid[$i][$j] = $histogram[0]->getColor();
        return $colorGrid;
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 18:01:32 2024 UTC