I'm running this from the command line:
magick.exe input.png -shave '1x0' output_%d.png
magick.exe input.png -shave '2x0' output_%d.png
magick.exe input.png -shave '3x0' output_%d.png
magick.exe input.png -shave '4x0' output_%d.png
magick.exe input.png -shave '5x0' output_%d.png
magick.exe input.png -shave '0x1' output_%d.png
magick.exe input.png -shave '0x2' output_%d.png
magick.exe input.png -shave '0x3' output_%d.png
magick.exe input.png -shave '0x4' output_%d.png
magick.exe input.png -shave '0x5' output_%d.png
The first command creates output_0.png but the following commands overwrite the same file. Is there a single command that could generate output_0.png to output_9.png instead?
The ImageMagick documentation says:
Filename References
Optionally, use an embedded formatting character to write a sequential
image list. Suppose our output filename is image-%d.jpg and our image
list includes 3 images. You can expect these images files to be
written:
image-0.jpg
image-1.jpg
image-2.jpg
That's the closest evidence I found it's possible to do what I'm looking for in ImageMagick. It's not clear to me if I need to leverage shell scripting to do this or if ImageMagick provides a command line feature.
With ImageMagick you can run multiple operations on separate instances of the input image in a single command by cloning the input and isolating the operations inside parentheses like this...
magick input.png \
\( -clone 0 -shave '1x0' \) \
\( -clone 0 -shave '2x0' \) \
\( -clone 0 -shave '3x0' \) \
\( -clone 0 -shave '4x0' \) \
\( -clone 0 -shave '5x0' \) \
\( -clone 0 -shave '0x1' \) \
\( -clone 0 -shave '0x2' \) \
\( -clone 0 -shave '0x3' \) \
\( -clone 0 -shave '0x4' \) \
\( -clone 0 -shave '0x5' \) \
-delete 0 output_%02d.png
That will create 10 output images, each with a sequential filename with the number padded to two places, like "output_00.png ... output_10.png".
To convert this to Windows CMD syntax you can remove all the backslashes that escape the parentheses, and replace the continued-line backslashes "\" with carets "^".
EDITED TO ADD: There are many ways to accomplish this task with ImageMagick. Here is another example command that would produce the same results, but it uses FX expressions so it will only work in IMv7. (The above command should work with IMv6 by changing "magick" to "convert".)
magick input.png -duplicate 9 -shave "%[fx:t<5?t+1:0]x%[fx:t>4?t-4:0]" output_%02d.png
This reads the input and duplicates it 9 times, then uses FX expressions as arguments to the -shave operation so it can step through all 10 images, shaving each according to the formula in the FX expression.
As #GeeMack points out, there are many ways of doing this with ImageMagick and I was inspired to try a couple of other methods by his marvellous FX expression - just for fun!
Here's what I was originally proposing:
magick input.png -write MPR:orig \
-shave 1x -write out_1.png \
-shave 1x -write out_2.png \
-shave 1x -write out_3.png \
-shave 1x -write out_4.png \
-shave 1x -write out_5.png \
-delete 0--1 \
MPR:orig \
-shave x1 -write out_6.png \
-shave x1 -write out_7.png \
-shave x1 -write out_8.png \
-shave x1 -write out_9.png \
-shave x1 out_10.png
It loads the input image and saves a copy in an MPR or "Magick Persistent Register" called orig. It then shaves a pixel off left and right sides and writes out_1.png, then shaves a further pixel off left and right sides and saves in out_2.png and continues till left and right are shaved by 5 pixels. It then reloads the original from the MPR and shaves off the top and bottom five times.
With a 1080p image, i.e. 1920x1080, this takes 3.4s and uses 96MB of RAM. By comparison, GeeMack's takes 3.5s on my machine and uses 291MB of RAM.
I then parallelised the creation of the left-right shaving with the top-bottom shaving as follows:
magick input.png \
-shave 1x -write out_1.png \
-shave 1x -write out_2.png \
-shave 1x -write out_3.png \
-shave 1x -write out_4.png \
-shave 1x out_5.png &
magick input.png \
-shave x1 -write out_6.png \
-shave x1 -write out_7.png \
-shave x1 -write out_8.png \
-shave x1 -write out_9.png \
-shave x1 out_10.png &
wait
That takes just 1.97s and peaks at 68MB of RAM.
I think GeeMack's solution is probably simplest and most concise, for most cases, but there may be some mileage in some of the ideas here for some situations, i.e. probably larger images.
In case anyone is interested how to measure the peak RAM usage, I used this:
/usr/bin/time -l ./go
1.97 real 6.01 user 2.48 sys
68354048 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
10343 page reclaims
0 page faults
0 swaps
...
...
Related
I am writing a shell script to output multiple image sizes and formats from a source PNG. The script works great and outputs the correct sizes and formats but I get an error at the end of the script that I am trying to fix. The shell script code is below:
convert $pic -verbose -strip \
\( +clone -quality 75 -write test-output-$today-xl.jpg -write test-output-$today-xl.webp +delete \) \
\( +clone -resize 900 -quality 75 -write test-output-$today-lg.jpg -write test-output-$today-lg.webp +delete \) \
\( +clone -resize 747 -quality 75 -write test-output-$today-md.jpg -write test-output-$today-md.webp +delete \) \
\( +clone -resize 598 -quality 75 -write test-output-$today-sm.jpg -write test-output-$today-sm.webp +delete \) \
+clone -resize 548 -quality 75 -write test-output-$today-xs.jpg -write test-output-$today-xs.webp +delete
Which produces this output:
test-input.png=>test-output-2020-12-16-xl.jpg PNG 1788x1028 1788x1028+0+0 8-bit sRGB 88171B 0.060u 0:00.065
test-input.png=>test-output-2020-12-16-xl.webp PNG 1788x1028 1788x1028+0+0 8-bit sRGB 52228B 0.180u 0:00.179
test-input.png=>test-output-2020-12-16-lg.jpg PNG 1788x1028=>900x517 900x517+0+0 8-bit sRGB 27070B 0.380u 0:00.070
test-input.png=>test-output-2020-12-16-lg.webp PNG 1788x1028=>900x517 900x517+0+0 8-bit sRGB 16648B 0.490u 0:00.070
test-input.png=>test-output-2020-12-16-md.jpg PNG 1788x1028=>747x429 747x429+0+0 8-bit sRGB 19482B 0.310u 0:00.046
test-input.png=>test-output-2020-12-16-md.webp PNG 1788x1028=>747x429 747x429+0+0 8-bit sRGB 11790B 0.350u 0:00.048
test-input.png=>test-output-2020-12-16-sm.jpg PNG 1788x1028=>598x344 598x344+0+0 8-bit sRGB 13190B 0.330u 0:00.044
test-input.png=>test-output-2020-12-16-sm.webp PNG 1788x1028=>598x344 598x344+0+0 8-bit sRGB 8134B 0.230u 0:00.033
test-input.png=>test-output-2020-12-16-xs-0.jpg[0] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 11719B 0.520u 0:00.073
test-input.png=>test-output-2020-12-16-xs-1.jpg[1] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 11719B 0.340u 0:00.047
INFO: Added frame. offset:0,0 dispose:0 blend:1
test-input.png=>test-output-2020-12-16-xs.webp[0] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 13732B 0.520u 0:00.075
convert: `+delete' # error/convert.c/ConvertImageCommand/3303.
any ideas as to why I get an error with the +delete command and also get two versions of the last jpg outputted?
Apologies if this is a simple solution, i find the imagemagick documentation a little hard to parse for specific questions. Thanks in advance!
I would approach it as follows in Imagemagic. All clones must be enclosed in parentheses. Add null: to make no other output.
convert $pic -verbose -strip \
\( +clone -quality 75 -write test-output-$today-xl.jpg -write test-output-$today-xl.webp +delete \) \
\( +clone -resize 900 -quality 75 -write test-output-$today-lg.jpg -write test-output-$today-lg.webp +delete \) \
\( +clone -resize 747 -quality 75 -write test-output-$today-md.jpg -write test-output-$today-md.webp +delete \) \
\( +clone -resize 598 -quality 75 -write test-output-$today-sm.jpg -write test-output-$today-sm.webp +delete \) \
\( +clone -resize 548 -quality 75 -write test-output-$today-xs.jpg -write test-output-$today-xs.webp +delete \) \
null:
The syntax is :
convert <INPUT> <OUTPUT>
so you must output something at the end, you can't just delete the last image.
You could end with null: to discard the last image, but it's better not to create it in the first place. So your best bet is:
remove the last +clone and just use the input image you loaded on the first line, and
remove the final +delete
Also,-quality 75 is a setting, which means it remains set till you change it, so you can just put it once on the first line, rather than repeating it everywhere.
Also, you should double-quote bash variables:
convert "$pic" ...
then they'll still work when, one rainy day, your filenames have spaces in them.
I've trying to use imagemagick to create a simple reflection, however the documentation has fixed sizes. I've tried to read in the height and width and use those variables but this doesn't produce a reflection.
Here's the documentation
http://www.imagemagick.org/Usage/advanced/
Here's the sample code
convert pokemon.gif \( +clone -flip \) -append \
-size 100x100 xc:black +swap \
-gravity North -geometry +0+5 -composite reflect_perfect.png
Here's my bash script, with my widths and heights...
#!/bin/bash
infile="framed.png"
ww=`convert $infile -format "%w" info:`
hh=`convert $infile -format "%h" info:`
convert $infile -alpha on \
\( +clone -flip -channel A -evaluate multiply .35 +channel \) -append \
-size ${ww}x${hh} xc:black +swap \
-gravity North -geometry +0+5 -composite reflect_alpha.png
My resulting image is exactly the same as the source image.
Here's the exact image I'm using
https://www.dropbox.com/s/l8gtieuqi1yoipm/iPhoneXR-4-categories_framed.png?dl=0
The size for the black background must be larger than twice the height of the input and at least as wide as the input. So I would do the following in Imagemagick
Input:
infile="zelda1.jpg"
ww=`convert $infile -format "%[fx:1.5*w]" info:`
hh=`convert $infile -format "%[fx:2.1*h]" info:`
convert $infile -alpha on \
\( +clone -flip -channel A -evaluate multiply .35 +channel \) -append \
-size ${ww}x${hh} xc:black +swap \
-gravity North -geometry +0+5 -composite reflect_alpha.png
But you can try my bash unix Imagemagick shell script, 3Dreflection at http://www.fmwconcepts.com/imagemagick/index.html, if you want more flexibility.
ADDITION:
To answer your question, it does not matter if PNG or JPG. The issue is that you have transparency. If you put a transparent background, then
infile="WPB-wtpC.png"
ww=`convert $infile -format "%[fx:1.5*w]" info:`
hh=`convert $infile -format "%[fx:2.1*h]" info:`
convert $infile \
\( +clone -flip -alpha on -channel A -evaluate multiply .35 +channel +write tmp1.png \) -append +write tmp2.png \
-size ${ww}x${hh} xc:none +swap \
-gravity North -geometry +0+5 -compose over -composite reflect_alpha.png
If you use a black background, then
infile="WPB-wtpC.png"
ww=`convert $infile -format "%[fx:1.5*w]" info:`
hh=`convert $infile -format "%[fx:2.1*h]" info:`
convert $infile \
\( +clone -flip -alpha on -channel A -evaluate multiply .35 +channel +write tmp1.png \) -append +write tmp2.png \
-size ${ww}x${hh} xc:black +swap \
-gravity North -geometry +0+5 -compose over -composite reflect_alpha.png
NOTE: I had a typo in the first zelda image code. I accidentally typed w rather than h in the hh equation, which I have now fixed. That may have messed you up.
I've been using Fiji's FFT bandpass filter with great success, but I'd like to do this in the command line with ImageMagick. I see that ImageMagick has FFT filters and they documentation includes low-pass and high-pass filters, but can I perform a bandpass filter?
The bandpass filter settings from Fiji that seem to work well for me:
(With apologies that my filter and FFT knowledge is... really bad, so maybe this is easily accomplished if I knew what to chain together, etc...)
A band pass filter similar to the low pass one you show in your link would be a white ring on a black background for square images. The inner and outer radii of the ring determine the frequencies that would be passed. In ImageMagick you can do that as follows:
Input:
Create ring image:
convert lena-1.png -fill black -colorize 100 \
-fill white -draw "translate 64,64 circle 0,0 0,50" \
-fill black -draw "translate 64,64 circle 0,0 0,20" \
-alpha off -blur 0x1 \
ring.png
Do FFT processing with stretch to full dynamic range:
convert lena-1.png -fft \
\( -clone 0 ring.png -compose multiply -composite \) \
-swap 0 +delete -ift -auto-level \
lena_bp.png
Alternate processing with gain of 10x:
convert lena-1.png -fft \
\( -clone 0 ring.png -compose multiply -composite \) \
-swap 0 +delete -ift -evaluate multiply 10 \
lena_bp.png
As I do not know what they have coded in ImageJ or Fiji and you showed no output, I can only guess that what might be equivalent would be to have inner and outer radii at 3 and 40 pixels from the center. Also I have added again a gain of 10x in dynamic range to make it more visible:
convert lena-1.png -fill black -colorize 100 \
-fill white -draw "translate 64,64 circle 0,0 0,40" \
-fill black -draw "translate 64,64 circle 0,0 0,3" \
-alpha off -blur 0x1 \
ring.png
convert lena-1.png -fft \
\( -clone 0 ring.png -compose multiply -composite \) \
-swap 0 +delete -ift -evaluate multiply 10 \
lena_bp.png
Note that I blurred the ring slightly to reduce "ringing" artifacts. (See https://en.wikipedia.org/wiki/Ringing_artifacts). Many low pass, high pass and band pass filters have stronger/longer tapering similar to increasing the blur. There are specially designed tapers, such as Butterworth. (see https://en.wikipedia.org/wiki/Butterworth_filter)
I have an expanded version of the FFT documentation from ImageMagick at http://www.fmwconcepts.com/imagemagick/fourier_transforms/fourier.html (Note some of the Jinc filtering is a bit outdated. Since I wrote that, Imagemagick implemented the Jinc function within -fx)
Here is a small set of commands to do it all in Unix syntax. Remove the +write ring.png if you do not want it to be created. This code is limited to square images.
ImageMagick 6:
inner=3
outer=40
infile="lena-1.png"
cent=`convert "$infile" -format "%[fx:floor((w-1)/2)]" info:`
inname=`convert "$infile" -format "%t" info:`
suffix=`convert "$infile" -format "%e" info:`
convert "$infile" \
\( +clone -fill black -colorize 100 \
-fill white -draw "translate $cent,$cent circle 0,0 0,$outer" \
-fill black -draw "translate $cent,$cent circle 0,0 0,$inner" \
-alpha off -blur 0x1 +write ring.png \
-write mpr:bpass +delete \) \
-fft \( -clone 0 mpr:bpass -compose multiply -composite \) \
-swap 0 +delete -ift -evaluate multiply 10 \
${inname}_bandpass_${inner}_${outer}.$suffix
ImageMagick 7 (only one command line):
inner=3
outer=40
infile="lena-1.png" \
magick "$infile" \
-set option:cent "%[fx:floor((w-1)/2)]" \
-set filename:fn "%t_bandpass_${inner}_${outer}.%e" \
\( +clone -fill black -colorize 100 \
-fill white -draw "translate "%[cent],%[cent]" circle 0,0 0,$outer" \
-fill black -draw "translate "%[cent],%[cent]" circle 0,0 0,$inner" \
-alpha off -blur 0x1 +write ring.png \
-write mpr:bpass +delete \) \
-fft \( -clone 0 mpr:bpass -compose multiply -composite \) \
-swap 0 +delete -ift -evaluate multiply 10 \
"%[filename:fn]"
If you mean band enhanced (band boost) and not band pass, then you add the result back with the original (-compose plus -composite). In ImageMagick 6, that would be:
inner=3
outer=40
infile="lena-1.png"
cent=`convert "$infile" -format "%[fx:floor((w-1)/2)]" info:`
inname=`convert "$infile" -format "%t" info:`
suffix=`convert "$infile" -format "%e" info:`
convert "$infile" \
\( +clone -fill black -colorize 100 \
-fill white -draw "translate $cent,$cent circle 0,0 0,$outer" \
-fill black -draw "translate $cent,$cent circle 0,0 0,$inner" \
-alpha off -blur 0x1 +write ring.png \
-write mpr:bpass +delete \) \
-fft \( -clone 0 mpr:bpass -compose multiply -composite \) \
-swap 0 +delete -ift "$infile" -compose plus -composite \
${inname}_bandenhance_${inner}_${outer}.$suffix
These are different results from what I get with those settings in ImageJ. Unfortunately, I do not know what they are doing. The ImageJ results look more like low pass filtering to me than what I know as band enhanced/band pass. See https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=12&cad=rja&uact=8&ved=2ahUKEwjJvoWD6L7eAhXJslQKHf1jArgQFjALegQICBAC&url=https%3A%2F%2Fcanvas.instructure.com%2Ffiles%2F6907524%2Fdownload%3Fdownload_frd%3D1&usg=AOvVaw2ws15jPD6C2-yAkfHmHYMH and https://www.scribd.com/doc/51981950/Frequency-Domain-Bandpass-Filtering-for-Image-Processing
In ImageJ, perhaps they are using a Butterworth filter or larger Gaussian blur. Or perhaps they are only processing the intensity channel from say HSI or HSV or LAB.
I am using ImageMagick and grunt-exec to generate a favicon for a website I am working on using the command found in the ImageMagick documentation.
convert image.png -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -alpha off -colors 256 favicon.ico
However I am getting some issues with line breaks which I think is partially because I do not fully understand what I should do with the line breaks.
In my Gruntfile.js I am currently using no line breaks and it works as expected. Notice that I had to remove all the line breaks and double escape the parentheses because apparently grunt-exec parses the string before it executes it.
exec: {
favicon: 'convert _favicon.svg -bordercolor white -border 0 \\( -clone 0 -resize 16x16 \\) \\( -clone 0 -resize 32x32 \\) \\( -clone 0 -resize 48x48 \\) \\( -clone 0 -resize 64x64 \\) -delete 0 -alpha off -colors 256 favicon.ico'
}
Like I said, I have it working right now but I would like to be able to use line breaks for readability and also because I would like to fully understand what is going on here. So far I have tried adding an extra \ and leaving everything the same, replacing the new lines with \n or \\n and putting everything on the same line but no luck.
The solution I was looking for turned out to be to use \n\ for new lines, like this:
convert image.png -bordercolor white -border 0 \n\
\( -clone 0 -resize 16x16 \) \n\
\( -clone 0 -resize 32x32 \) \n\
\( -clone 0 -resize 48x48 \) \n\
\( -clone 0 -resize 64x64 \) \n\
-delete 0 -alpha off -colors 256 favicon.ico
Try using this:
exec: {
favicon: 'convert _favicon.svg -bordercolor white -border 0 "( -clone 0 -resize 16x16 )" "( -clone 0 -resize 32x32 )" "( -clone 0 -resize 48x48 )" "( -clone 0 -resize 64x64 )" -delete 0 -alpha off -colors 256 favicon.ico'
}
I have an ongoing list of image processing tasks to do, using ImageMagick to composite large individual graphic files (20MB each). These images are currently stored on S3 (approximately 2.5GB in total).
I was thinking to use multiple EC2 instances to process the tasks, composite the images and upload the output file to S3.
The problem with this setup is that ImageMagick needs the file library to be local (on the machine). Currently images are on S3, which means each instance would need to download a copy of the images from S3, slowing down the whole process.
What's the best way to share this image library to all nodes?
Consider also the following points:
You can do any processing of ImageMagick files completely in memory by "saving" any input image in the special format MPR: (Magick Pixel Register). For details see this answer: "ImageMagick multiple operations in single invocation"
ImageMagick can access remote images via http://.
You can put a lot of ImageMagick's operations into one single command line which also can produce multiple output files, and you can segment that command line into sub- or side-processes by using the parentheses syntax: ... \( IM side process \) ... for the sub-/side-processes.
How you can streamline your overall process depends a lot about what exactly you want to do. However,
the MPR: / MPC: technique can be very useful for this and probably avoid or minimize the need to use multiple EC2 instances;
you cannot get around the step to somehow ship the input pixels to that instance of ImageMagick which should process them (so "downloading a copy" will always have to occur);
you can minimize the number of downloads by storing the input under a series of MPR:xy1, MPR:xy2 etc. labels in memory and then access all these multiple times fast from a long and well constructed ImageMagick command line which does any number of compositions you want.
Example
To give an example. Consider having 10 TIFFs, and you want to create 3 different PDF files from these tiffs, each PDF containing a different set of pages made up from the 10 TIFFs. Normally you would run 3 commands:
convert 1.tif 3.tif 4.tif 8.tif 9.tif 10.tif -compress jpeg -quality 70 1out1.pdf
convert 2.tif 3.tif 4.tif 7.tif 8.tif 9.tif -compress jpeg -quality 70 1out2.pdf
convert 3.tif 4.tif 5.tif 7.tif 8.tif 10.tif -compress jpeg -quality 70 1out3.pdf
These 3 commands will have to load 6 TIFF files each (some TIFFs, like 3.tif being used in all 3 commands). That is 18 I/O events.
Now consider this command alternative, which will run faster (I believe):
convert \
1.tif +write mpr:t1 +delete \
2.tif +write mpr:t2 +delete \
3.tif +write mpr:t3 +delete \
4.tif +write mpr:t4 +delete \
5.tif +write mpr:t5 +delete \
6.tif +write mpr:t6 +delete \
7.tif +write mpr:t7 +delete \
8.tif +write mpr:t8 +delete \
9.tif +write mpr:t9 +delete \
10.tif +write mpr:t10 +delete \
\( mpr:t1 mpr:t3 mpr:t4 mpr:t8 mpr:t9 mpr:t10 \
-compress jpeg -quality 70 +write 2out1.pdf \) \
\( mpr:t2 mpr:t3 mpr:t4 mpr:t7 mpr:t8 mpr:t9 \
-compress jpeg -quality 70 +write 2out2.pdf \) \
\( mpr:t3 mpr:t4 mpr:t5 mpr:t7 mpr:t8 mpr:t10 \
-compress jpeg -quality 70 +write 2out3.pdf \) \
null:
This command loads each of the 10 TIFFs only once (10 I/O events in total). It then writes each TIFF into an MPR: file with an appropriate label and then deletes the initial TIFF from the image sequence.
After this initial preparation ImageMagick will run 3 different, parenthese-d side-processing pipelines in sequence loading the required output pages as MPR: images, and create a PDF from each of them.
Above example is probably too limited in order to demonstrate a measurable advantage by using MPR:. Because the same results can also be achieved by this command:
convert \
1.tif \
2.tif \
3.tif \
4.tif \
5.tif \
6.tif \
7.tif \
8.tif \
9.tif \
10.tif \
\( -clone 0,2-3,7-9 -compress jpeg -quality 70 +write 3out1.pdf \) \
\( -clone 1-3,6-8 -compress jpeg -quality 70 +write 3out2.pdf \) \
\( -clone 2-4,6-7,9 -compress jpeg -quality 70 +write 3out3.pdf \) \
null:
However, there is one more hook where some performance win may be acquired: the -compress jpeg -quality 70 is applied 3 times to 6 (cloned, original) images each.
There may be some CPU cycles to be saved if we apply this operation to the TIFFs before they are written into the MPR registers. This way we apply that operation only to 10 TIFFs. Later we do not need to apply it any more when we write out the PDFs:
convert \
-respect-parentheses \
1.tif -compress jpeg -quality 70 +write mpr:t1 +delete \
2.tif -compress jpeg -quality 70 +write mpr:t2 +delete \
3.tif -compress jpeg -quality 70 +write mpr:t3 +delete \
4.tif -compress jpeg -quality 70 +write mpr:t4 +delete \
5.tif -compress jpeg -quality 70 +write mpr:t5 +delete \
6.tif -compress jpeg -quality 70 +write mpr:t6 +delete \
7.tif -compress jpeg -quality 70 +write mpr:t7 +delete \
8.tif -compress jpeg -quality 70 +write mpr:t8 +delete \
9.tif -compress jpeg -quality 70 +write mpr:t9 +delete \
10.tif -compress jpeg -quality 70 +write mpr:t10 +delete \
\( mpr:t1 mpr:t3 mpr:t4 mpr:t8 mpr:t9 mpr:t10 4out1.pdf \) \
\( mpr:t2 mpr:t3 mpr:t4 mpr:t7 mpr:t8 mpr:t9 4out2.pdf \) \
\( mpr:t3 mpr:t4 mpr:t5 mpr:t7 mpr:t8 mpr:t10 4out3.pdf \) \
null:
Update
Mark Setchell's comment was spot on. I had overlooked that before he mentioned it. It is probably faster (and certainly much less to type) to run the command like this:
convert \
-respect-parentheses \
-compress jpeg -quality 70 \
1.tif +write mpr:t1 +delete \
2.tif +write mpr:t2 +delete \
3.tif +write mpr:t3 +delete \
4.tif +write mpr:t4 +delete \
5.tif +write mpr:t5 +delete \
6.tif +write mpr:t6 +delete \
7.tif +write mpr:t7 +delete \
8.tif +write mpr:t8 +delete \
9.tif +write mpr:t9 +delete \
10.tif +write mpr:t10 +delete \
\( mpr:t1 mpr:t3 mpr:t4 mpr:t8 mpr:t9 mpr:t10 5out1.pdf \) \
\( mpr:t2 mpr:t3 mpr:t4 mpr:t7 mpr:t8 mpr:t9 5out2.pdf \) \
\( mpr:t3 mpr:t4 mpr:t5 mpr:t7 mpr:t8 mpr:t10 5out3.pdf \) \
null:
You'll have to run your own benchmarks, with your own images, in your own environment, though, if you want to decide for whichever of the proposed commands you should prefer.