Page 1 of 1
How to cut a stream of pixels into a normal sized picture?
Posted: 2016-04-15T15:16:54-07:00
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
Re: How to cut a stream of pixels into a normal sized picture?
Posted: 2016-04-15T15:29:22-07:00
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
Re: How to cut a stream of pixels into a normal sized picture?
Posted: 2016-04-15T16:50:54-07:00
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
Re: How to cut a stream of pixels into a normal sized picture?
Posted: 2016-04-15T17:44:30-07:00
by opti
Thanks a lot to both of you.
I was exactly looking for the solution snibgo provided - works great!
Re: How to cut a stream of pixels into a normal sized picture?
Posted: 2016-04-16T07:39:35-07:00
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