Page 1 of 1
[SOLVED] Multiple operations on an image
Posted: 2015-09-29T03:17:47-07:00
by mike271828
I'd like to take a picture, then save the picture twice into memory after applying grayscale and 2colorthresh. Then I'd rotate the pics and save them. The 2colorthresh isn't a part of standard Imagemagick libs, therefor something like
Code: Select all
convert i.jpg -write mpr:i +delete \( mpr:i -colorspace Gray -write mpr:g \) \( mpr:i -2colorthresh +write mpr:2 \) \( mpr:g -rotate 10 -write x.jpg \) \( mpr:2 -rotate 10 -write y.jpg \)
can't be used? I'll need to split that into 2 statements, one for gray, one for 2color?
Re: Multiple operations on an image
Posted: 2015-09-29T03:37:05-07:00
by snibgo
Is "2colorthresh" something you wrote yourself? Is it compiled into IM as an ordinary operation?
IM can do two or more operations in sequence. As many as you want. You don't need to write after every operation. I've split this into lines for readability. Use whatever line-continuation escapes you need.
Code: Select all
convert
i.jpg
( +clone
-colorspace Gray
-rotate 10
-write x.jpg
+delete
)
-2colorthresh
-rotate 10
y.jpg
Re: Multiple operations on an image
Posted: 2015-09-29T04:02:48-07:00
by mike271828
Re: Multiple operations on an image
Posted: 2015-09-29T04:16:24-07:00
by snibgo
Ah, well, that's a bash script. You can't run bash scripts within a convert command. You would run the script with i.jpg as the input file, then take the output and rotate it.
But that script is very simple. The processing is just "+dither -colors 2 -colorspace gray -contrast-stretch 0", so I expect you could put that in the command instead of "-colorthresh".
Re: Multiple operations on an image
Posted: 2015-09-29T04:34:17-07:00
by mike271828
That's right, thanks a lot.
Re: Multiple operations on an image
Posted: 2015-09-29T08:01:22-07:00
by fmw42
In this case my script is simple enough to decompose the commands. In general, for unix, you can pipe into and out of the script, thought that is still multiple converts. It only saves you writing intermediate output images to disk.