How to cut a stream of pixels into a normal sized picture?

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
opti
Posts: 2
Joined: 2016-04-05T17:16:36-07:00
Authentication code: 1151

How to cut a stream of pixels into a normal sized picture?

Post by opti »

Hi - I'm pretty new to ImageMagick and want to do some weird stuff:

I have a huge stream of pixels (100000x1) and wanna cut after x pixels to create a "normal" sized picture - I could do it kinda manually with a lot of scripting - is there a faster way to achieve this goal?

Just a small input sample:

Code: Select all

convert -size 56x1 xc: -sparse-color Barycentric '0,0 rgba(200,0,0, 1.0)  56,0 rgba(255,0,0, 1.0)' test1.bmp
Is this possible? Save it as a raw bitmap, and reload that with different width/height parameters?

Any help appreciated!
Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to cut a stream of pixels into a normal sized picture?

Post by fmw42 »

I do not know much about streams, but see raw RGB or RGBA formats at http://www.imagemagick.org/script/formats.php. They are both read and writable. So I think you could output as RGB:- and pipe back in with different size and depth arguments

Code: Select all

convert -size 56x1 xc: \
-sparse-color Barycentric '0,0 rgba(200,0,0, 1.0)  56,0 rgba(255,0,0, 1.0)' RGBA:- |\
 convert -size WxH - Other_Processing \
 result.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to cut a stream of pixels into a normal sized picture?

Post by snibgo »

I'm not sure about the "stream" part of your question. If you have an image sized Nx1, you can crop it into lines and append the results. For example, if N=100000 you can get 1000 lines of 100 columns each:

Code: Select all

convert in.png -crop 100x1 -append out.png
snibgo's IM pages: im.snibgo.com
opti
Posts: 2
Joined: 2016-04-05T17:16:36-07:00
Authentication code: 1151

Re: How to cut a stream of pixels into a normal sized picture?

Post by opti »

Thanks a lot to both of you. :D
I was exactly looking for the solution snibgo provided - works great!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to cut a stream of pixels into a normal sized picture?

Post by snibgo »

Correction: I should have put a "+repage" in there, so:

Code: Select all

convert in.png -crop 100x1 +repage -append out.png
Incidentally, the inverse is just as easy. If we have in an image of WxH pixels, we can crop it into lines and append them horizontally to make an image Nx1, where N=W*H.

Code: Select all

convert out.png -crop x1 +repage +append out2.png
snibgo's IM pages: im.snibgo.com
Post Reply