How to convert color dump to image?

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
coloring
Posts: 82
Joined: 2015-08-27T10:17:36-07:00
Authentication code: 1151

How to convert color dump to image?

Post by coloring »

Given:

Code: Select all

convert rose: txt: > color_dump.txt
How can I convert color_dump.txt or any other text-editable list of colors and coordinates back to an image file?

The goal is to be able to manually correct a few pixels from images with millions of colors, in vim without opening an image editor, so XBM, XPM, and PBM will probably not cut it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert color dump to image?

Post by snibgo »

The text file is an image file, readable by IM. Writing it directly is probably faster than using the ">" redirection.

Code: Select all

convert rose: r.txt

convert r.txt r.png
snibgo's IM pages: im.snibgo.com
coloring
Posts: 82
Joined: 2015-08-27T10:17:36-07:00
Authentication code: 1151

Re: How to convert color dump to image?

Post by coloring »

Thanks. Can IM accept other text input formats such as csv, or must the text file's formatting match the dump format exactly?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to convert color dump to image?

Post by snibgo »

When reading "txt:" format, the hash # character starts a comment to the end of the line. Except for that, the format isn't flexible.

Other text formats are available, eg

Code: Select all

magick rose: -compress None x.pnm
IM has no facility to read generic CSV files. It doesn't know what columns have what meanings. But if you create a CSV file, a script to convert that to a format IM can read should be easy.
snibgo's IM pages: im.snibgo.com
Post Reply