PGM in ascii text format is very flexible. IM actually does not output rows, just outputs its buffer when full.
pnmnoraw will output each row of image data on a single line.
See IM Examples. Common File Formats, PbmPlus and NetPBM, for examples..
http://www.imagemagick.org/Usage/formats/#pbmplus
However you asked all on one line. so simple replace returns and newlines with spaces using "tr" text utility (linux and unix), The "tr" command can even compress (suppress) multiple spaces to a single space, to make it easier to parse.
Code: Select all
convert infile.jp2 -compress none pgm:- | tr -s '\012\015' ' ' > outfile.pgm
There all one line (without even a final return/newline).
Remember the first few 'words' are not image data but image attributes (magic, size, depth)