Exporting pixel information in a certain format

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?".
Post Reply
jonny
Posts: 1
Joined: 2016-03-18T14:38:35-07:00
Authentication code: 1151

Exporting pixel information in a certain format

Post by jonny »

Hi everyone, is there any possiblity to export the infos about each pixel in user format?

now if we use

Code: Select all

convert file1.jpg file2.txt

we get a file with strings like

Code: Select all

0,0: (29,54,42)  #1D362A  srgb(29,54,42)
I would basically need something like that:

Code: Select all

convert file1.jpg <here smth where format can be specified> file2.txt
and that the output would be (for example)

Code: Select all

pixel 0-0 color is #1D362A, pixel 0-1 color is #1D362A, pixel 0-2 color is ...
or whatever else specified in the format

In the documentation there is an example which involves parsing the string with a shell script, but is there an option to output from the very beginning in the format needed?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Exporting pixel information in a certain format

Post by snibgo »

I don't think you can change the format of "txt:" output.

I don't think there is a way, in v6, of outputting multiple pixels in arbitrary text format. You can for single pixels, so you could put a "convert" inside a shell loop, but that is horribly inefficient. The usual technique is to parse the output in shell script.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Exporting pixel information in a certain format

Post by fmw42 »

I would pipe the output from the convert as txt: to shell tools such as sed that would change the format

Code: Select all

convert image txt:- | sed .... > textfile.txt
If you provide the desired format, I can specify the sed command needed.
Post Reply