Page 1 of 1

Exporting pixel information in a certain format

Posted: 2016-03-18T14:52:37-07:00
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?

Re: Exporting pixel information in a certain format

Posted: 2016-03-18T15:30:01-07:00
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.

Re: Exporting pixel information in a certain format

Posted: 2016-03-18T15:38:41-07:00
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.