The PerlMagick doc concerning "direct access to pixels" tantalizingly suggests what I need. But I have no clue how to use it. Any "pointers" (heh heh) would be appreciated; a tiny example would be most welcome.

I tried naively treating the pointer as being to an array, but was unable to read any elements

In any case, using Fx and/or GetPixel/SetPixel is very slow, for obvious reasons,so I'm looking for something more efficient for manipulating large numbers of pixels. (I've perused an earlier post, HERE, which seemed to end uncertainly.)

GetAuthenticPixels() returns a Perl blob and you are right, its not safe as you could overflow the buffer. We could transfer it to a Perl safe buffer but the design was to keep it lightning fast for Perl users that have a need for speed. You are tasked with unpacking the binary blob which requires you to first check to see how many channels are in the image and the storage type of the pixels. For example, a RGB image from an HDRI version of ImageMagick returns red, green, and float values for width * height pixel packets.

Recall that GetVirtualPixels() allows you to grab pixels outside the image canvas.

Its likely writing the SetPixels() method was a challenge we were not prepared to tackle at the time we developed the GetPixels() method. Would you care to volunteer to write the method and contribute it to the PerlMagick user community?

Its likely writing the SetPixels() method was a challenge we were not prepared to tackle at the time we developed the GetPixels() method. Would you care to volunteer to write the method and contribute it to the PerlMagick user community?

I'd love to, were I only equipped to do so. Not even knowing what a Blob is (and I doubt I'll be grokking that mess), I'm probably the wrong person. I'd certainly give it a try, though, since it can perhaps be understood by looking at the existing GetPixels(), GetPixel(), and (especially) SetPixel() methods.

Is everything one should know contained in quantum.xs? That's what I edit for puny debugging and experimenting.

You want to edit quantum.xs.in. quantum.xs is built from quantum.xs.in. However, you could edit quantum.xs so you don't need to reconfigure for each build. Just make sure you save a backup in case its overwritten when you reconfigure the ImageMagick distribution.

Here is a slight modification of SetPixel to make a nicely functioning multi-pixel version: SetPixels. It is working for me and is very, very fast compared with repeating calls to SetPixel (or using Fx).

Like SetPixel, though, it is only designed for the usual channel families (RGB, etc.).

(b) The call accepts the region's x, y, width, and height or an equivalent geom string.

Incidentally, I don't understand why SetPixel has a 'geom' key when the width and height components of that make no sense. Also, SetPixel accepts an undocumented 'normalize' key (normalized values are expected by default), which I left in the SetPixels version.

You can call it like so --- just fill an array with appropriately sequenced quanta.

If you pass too few quanta it will just process those you gave it with no error. Too many quanta will also give no error; only those that fill the region will be used. That behavior could be improved, I guess.

Anyway, here it is.

The comments (marked by faux <RDM></RDM> tags) show where something was added or (in just one line) deleted.