Get all pixel RGB values

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
ClumsyNinja
Posts: 7
Joined: 2013-09-21T18:38:31-07:00
Authentication code: 6789

Get all pixel RGB values

Post by ClumsyNinja »

CLI / ImageMagick-7.0.9-Q16

I'm working on an automation project and wish to get the rgb value of every pixel in an image.

By taking samples from this forum I have figured out how to get the value of one pixel and output it to a file. This gets the RGB value of pixel 30,40.

Code: Select all

convert "d:\MJT\files\IMtests\Image1.bmp" -format '%[pixel:p{40,30}]'  info:-  > "d:\MJT\files\IMtests\Image1RGB.txt"
I can automate getting every pixel in a loop and increment x/y by 1 each time, but even on a small 250x250 image this means a time consuming loop of 62,500 pixels.

I'm not entirely sure what the extra info is in the output, but I can parse out the extra info and have figured out that 'srgba(30,40,50,1)' means the rgb is 30,40,50. I'm guessing i need to edit something in '%[pixel:p{40,30}]'

Is there a way to output all pixels at once?

Apologies for being so uninformed. I have only dabbled with ImageMagick a little in the past and found it invaluable alongside my automation projects.
CLI / ImageMagick-7.0.9-Q16 automated with MJTnet Macro Scheduler v15.
Windows 10 64 bit.
New to ImageMagick, but an old hat at Windows automation.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Get all pixel RGB values

Post by snibgo »

For v7, I suggest you use "magick", not "convert" (and not "magick convert").

The txt: format gives you all the pixels:

Code: Select all

magick in.bmp txt:out.txt
snibgo's IM pages: im.snibgo.com

ClumsyNinja
Posts: 7
Joined: 2013-09-21T18:38:31-07:00
Authentication code: 6789

Re: Get all pixel RGB values

Post by ClumsyNinja »

Oh my goodness!! That's incredible, and simple. Thank you.
CLI / ImageMagick-7.0.9-Q16 automated with MJTnet Macro Scheduler v15.
Windows 10 64 bit.
New to ImageMagick, but an old hat at Windows automation.

Locked