Imagemagick images next to each other with proper margin - image

I am trying to create a png file with a transparent background, in which I put images next to each other.
My command so far is this:
convert --% -bordercolor none -background none -gravity center logo.png -border 5x5 ( img1.jpg img2.jpg img3.jpg -border 5x5 +append ) ( img4.jpg img5.jpg img6.jpg -border 5x5 +append ) -append -border 5x5 -resize 720x480 output.png
it creates me this image
how do I have to change my command to make the image appear as following?
(I made the background grey so one can see the white text, the background shall be transparent later on)
I tried Mark Setchells suggestion the command so far looks like this:
convert -background none -bordercolor none -gravity west \
C:\xampp\htdocs\app\storage\images\Img_1.jpg label:"1" +swap -append label:"text 1" -append -write miff:- +delete \
C:\xampp\htdocs\app\storage\images\Img_2.jpg label:"2" +swap -append label:"text 2" -append -write miff:- +delete \
C:\xampp\htdocs\app\storage\images\Img_3.jpg label:"3" +swap -append label:"text 3" -append -write miff:- +delete \
C:\xampp\htdocs\app\storage\images\Img_4.jpg label:"4" +swap -append label:"text 4" -append -write miff:- +delete \
C:\xampp\htdocs\app\storage\images\Img_5.jpg label:"5" +swap -append label:"text 5" -append -write miff:- +delete \
C:\xampp\htdocs\app\storage\images\Img_6.jpg label:"6" +swap -append label:"text 6" -append miff:- |
montage -set label '' miff:- -background pink -tile 3x2 -geometry +15+5 miff:- |
convert -size 800x500 xc:gray80 -gravity center miff:- -composite -gravity north C:\xampp\htdocs\app\storage\images\logo.png -geometry +0+30 -composite C:\xampp\htdocs\app\storage\images\result.png

You can do it many ways. Here is one:
Method 1
#!/bin/bash
convert -background none -bordercolor none -gravity west \
\( 1.png label:"1" +swap -append label:"text 1" -append -border 5x5 \) \
\( 2.png label:"2" +swap -append label:"text 2" -append -border 5x5 \) +append \
\( 3.png label:"3" +swap -append label:"text 3" -append -border 5x5 \) +append \
\( \
\( 4.png label:"4" +swap -append label:"text 4" -append -border 5x5 \) \
\( 5.png label:"5" +swap -append label:"text 5" -append -border 5x5 \) +append \
\( 6.png label:"6" +swap -append label:"text 6" -append -border 5x5 \) +append \
\) -append \
-gravity center -extent 800x550 \
-gravity north logo.png -geometry +0+30 -composite result.png
Method 2
This way you can use the first convert command to put the labels above and below each image and then stream all 6 labelled images into montage to do the grid layout (on pink) for you and from there back into another convert to create the gray background canvas and write the logo on at the top.
#!/bin/bash
convert -background none -bordercolor none -gravity west \
1.png label:"1" +swap -append label:"text 1" -append -write miff:- +delete \
2.png label:"2" +swap -append label:"text 2" -append -write miff:- +delete \
3.png label:"3" +swap -append label:"text 3" -append -write miff:- +delete \
4.png label:"4" +swap -append label:"text 4" -append -write miff:- +delete \
5.png label:"5" +swap -append label:"text 5" -append -write miff:- +delete \
6.png label:"6" +swap -append label:"text 6" -append miff:- |
montage -set label '' miff:- -background pink -tile 3x2 -geometry +15+5 miff:- |
convert -size 800x500 xc:gray80 -gravity center miff:- -composite -gravity north logo.png -geometry +0+30 -composite result.png
Sorry, I have no idea or understanding why Windows is so poor at parsing the command, but after much fiddling around, the following seems to work - I have no idea why!
convert -background none -bordercolor none -gravity west ^
1.png label:"1" +swap -append label:"text 1" -append -write miff:- +delete ^
2.png label:"2" +swap -append label:"text 2" -append -write miff:- +delete ^
3.png label:"3" +swap -append label:"text 3" -append -write miff:- +delete ^
4.png label:"4" +swap -append label:"text 4" -append -write miff:- +delete ^
5.png label:"5" +swap -append label:"text 5" -append -write miff:- +delete ^
6.png label:"6" +swap -append label:"text 6" -append miff:- | montage -set label "" miff:- ^
-background pink -tile 3x2 -geometry +15+5 miff:- | convert -size 800x500 ^
xc:gray80 -gravity center miff: -composite -gravity north logo.png -geometry +0+30 -composite result.png

Related

imagemagic: stacking of the images using convert and montage

My bash script uses convert of the image magic to stack horizontally two types of the images producing 2xN multi-image chart:
convert \( "${output}/type1*.png" -append \) \( "${output}/type2*.png" -append \) +append -background white -alpha deactivate ${output}/summary.png
how would it be possible to add border of the selected dimensions between stacked images in the manner as I may do via montage -mattecolor $color_id ?
montage \( "${output}/type1*.png" \) \( "${output}/type2*.png" \) -geometry 800x600+1+1 -tile x2 -frame 4 -background white -mattecolor lightgoldenrod2 -mode Frame -bordercolor white ${output}/summary.png
vertical borders between each separate sections of the type1/ type2 and a horizontal border between the both parts joined in the summary:
convert \( "${output}/type1*.png" -bordercolor lightgoldenrod2 -border 0x2 -append \) \( "${output}/type2*.png" -bordercolor lightgoldenrod2 -border 0x2 -append \) -bordercolor lightgoldenrod2 -border 2x0 +append -background white -alpha deactivate ${output}/summary.png

faster imagemagick caption drawing

My project involve finding boxes in image and checking what inside them.
For debug and proof purpose, I have to plot captions on the pages.
The resulting imagemagick command looks like :
magick Q_College-001.dist.png -colorspace sRGB -stroke none -strokewidth 1 -background "rgba(0,255,0,0.3)" -size 37.8x29.4 caption:'84-1' -geometry +200.6+125.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 40.6x29.4 caption:'87-2' -geometry +519.2+125.8 -compose over -composite \
-background "rgba(0,255,0,0.3)" -size 53.2x30.8 caption:'317-3' -geometry +538.4+287.6 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x29.4 caption:'322-4' -geometry +639.2+287.8 -compose over -composite \
-background "rgba(0,255,0,0.3)" -size 54.6x29.4 caption:'463-5' -geometry +535.2+334.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x29.4 caption:'479-6' -geometry +638.2+337.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 53.2x29.4 caption:'605-7' -geometry +535.4+371.8 -compose over -composite -background "rgba(0,255,0,0.3)" -size 53.2x29.4 caption:'601-8' -geometry +637.4+370.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x28 caption:'728-9' -geometry +536.2+437 -compose over -composite -background "rgba(255,0,0,0.3)" -size 53.2x29.4 caption:'744-10' -geometry +636.4+438.8 -compose over -composite \
-background "rgba(0,255,0,0.3)" -size 54.6x30.8 caption:'999-11' -geometry +537.2+531.6 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x30.8 caption:'1005-12' -geometry +636.2+531.6 -compose over -composite -background "rgba(0,255,0,0.3)" -size 54.6x29.4 caption:'1483-13' -geometry +534.2+748.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x29.4 caption:'1489-14' -geometry +631.2+748.8 -compose over -composite \
-background "rgba(0,255,0,0.3)" -size 56x32.2 caption:'1595-15' -geometry +534+782.4 -compose over -composite -background "rgba(255,0,0,0.3)" -size 53.2x29.4 caption:'1589-16' -geometry +630.4+782.8 -compose over -composite \
-background "rgba(0,255,0,0.5)" -size 53.2x29.4 caption:'1762-17' -geometry +534.4+877.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x30.8 caption:'1767-18' -geometry +631.2+877.6 -compose over -composite -background "rgba(0,255,0,0.3)" -size 53.2x29.4 caption:'1837-19' -geometry +535.4+928.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 53.2x29.4 caption:'1827-20' -geometry +630.4+926.8 -compose over -composite -background "rgba(255,0,0,0.3)" -size 54.6x29.4 caption:'1890-21' -geometry +536.2+977.8 -compose over -composite \
-background "rgba(0,255,0,0.3)" -size 51.8x30.8 caption:'1886-22' -geometry +628.6+976.6 -compose over -composite -background "rgba(0,255,0,0.5)" -size 80.8x32 caption:'194-23' -geometry +878.1+221 -compose over -composite \
-background "rgba(0,255,0,0.5)" -size 72x32 caption:'198-24' -geometry +1091+221 -compose over -composite -background "rgba(0,255,0,0.5)" -size 80x32.8 caption:'189-25' -geometry +1291+220.1 -compose over -composite \
-background "rgba(0,255,0,0.5)" -size 80.8x44.8 caption:'276-26' -geometry +878.1+262.6 -compose over -composite -background "rgba(0,255,0,0.5)" -size 72x44.8 caption:'280-27' -geometry +1091+262.6 -compose over -composite \
-background "rgba(0,255,0,0.5)" -size 80x44 caption:'286-28' -geometry +1291+262.5 -compose over -composite -background "rgba(255,0,0,0.5)" -size 81.6x44 caption:'418-29' -geometry +878.2+318.5 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 72x44.8 caption:'404-30' -geometry +1091+317.6 -compose over -composite -background "rgba(255,0,0,0.5)" -size 79.2x44.8 caption:'411-31' -geometry +1291.9+317.6 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 81.6x45.6 caption:'558-32' -geometry +878.2+373.7 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 72x45.6 caption:'563-33' -geometry +1091+373.7 -compose over -composite -background "rgba(255,0,0,0.5)" -size 79.2x44.8 caption:'570-34' -geometry +1291.9+373.6 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 81.6x32.8 caption:'695-35' -geometry +878.2+429.1 -compose over -composite -background "rgba(0,255,0,0.5)" -size 72x31.2 caption:'701-36' -geometry +1091+428.9 -compose over -composite \
-background "rgba(0,255,0,0.5)" -size 80x32.8 caption:'691-37' -geometry +1291+428.1 -compose over -composite -background "rgba(255,0,0,0.5)" -size 80.8x31.2 caption:'869-38' -geometry +878.1+468.9 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 72x32 caption:'859-39' -geometry +1091+468 -compose over -composite -background "rgba(0,255,0,0.5)" -size 80x32 caption:'865-40' -geometry +1291+468 -compose over -composite -background "rgba(255,0,0,0.5)" -size 80.8x32 caption:'952-41' -geometry +878.1+508 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 72x32 caption:'957-42' -geometry +1091+508 -compose over -composite -background "rgba(255,0,0,0.5)" -size 80x32 caption:'948-43' -geometry +1291+507 -compose over -composite -background "rgba(255,0,0,0.5)" -size 80.8x57.6 caption:'1069-44' -geometry +878.1+551.2 -compose over -composite -background "rgba(255,0,0,0.5)" -size 72x57.6 caption:'1072-45' -geometry +1091+551.2 -compose over -composite -background "rgba(255,0,0,0.5)" -size 80x58.4 caption:'1063-46' -geometry +1291+550.3 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 80.8x44.8 caption:'1193-47' -geometry +878.1+621.6 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 72x44.8 caption:'1198-48' -geometry +1091+621.6 -compose over -composite \
-background "rgba(255,0,0,0.5)" -size 80x44.8 caption:'1203-49' -geometry +1291+621.6 -compose over -composite -background "rgba(0,255,0,0.3)" -size 53.2x29.4 caption:'1331-50' -geometry +1202.4+688.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 53.2x29.4 caption:'1326-51' -geometry +1304.4+687.8 -compose over -composite -background "rgba(0,255,0,0.3)" -size 54.6x29.4 caption:'1403-52' -geometry +1201.2+722.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 54.6x29.4 caption:'1397-53' -geometry +1306.2+721.8 -compose over -composite -background "rgba(0,255,0,0.3)" -size 53.2x29.4 caption:'1685-54' -geometry +1204.4+835.8 -compose over -composite \
-background "rgba(255,0,0,0.3)" -size 51.8x28 caption:'1691-55' -geometry +1301.6+836 -compose over -composite Q_College-001.dist.ans.png
It takes more than 30 sec to write the resulting image (PNG is 1500x , can't be smaller for box computing...).
Is there a way to obtain the result faster ?
I try to remove -compose over -composite but the concerned caption don't print.....
Thanks for your help
Michel
If I were writing this command, simply for clarity, I'd probably individually build each caption and set its paging geometry inside a set of parentheses, then composite all of them onto the input image all at once at the end with "-flatten".
magick Q_College-001.dist.png -colorspace sRGB -stroke none -strokewidth 1 \
\( -background "rgba(0,255,0,0.3)" -size 37.8x29.4 caption:'84-1' -set page +200.6+125.8 \) \
\( -background "rgba(255,0,0,0.3)" -size 40.6x29.4 caption:'87-2' -set page +519.2+125.8 \) \
...
\( -background "rgba(0,255,0,0.3)" -size 53.2x29.4 caption:'1685-54' -set page +1204.4+835.8 \) \
\( -background "rgba(255,0,0,0.3)" -size 51.8x28 caption:'1691-55' -set page +1301.6+836 \) \
-flatten Q_College-001.dist.ans.png
On my moderate speed Windows 10 machine the full command runs in about 7 seconds with or without those modifications.
thanks again for help. I share a totally different (and ways faster) approach. The only drawback I found is not using -caption, which means I have to fix a standard font-size for text. In my case, this is not a big issue. If somebody knows how to emulate -caption in SVG/MVG...
magick source.png -colorspace sRGB -draw " fill rgba(255,0,0,0.3) rectangle 200.6,125.8 238.4,155.2 rectangle 639.2,287.8 693.8,317.2 rectangle 638.2,337.8 692.8,367.2 rectangle 535.4,371.8 588.6,401.2 rectangle 636.4,438.8 689.6,468.2 rectangle 636.2,531.6 690.8,562.4 rectangle 631.2,748.8 685.8,778.2 rectangle 630.4,782.8 683.6,812.2 rectangle 631.2,877.6 685.8,908.4 rectangle 630.4,926.8 683.6,956.2 rectangle 536.2,977.8 590.8,1007.2 rectangle 1202.4,688.8 1255.6,718.2 rectangle 1201.2,722.8 1255.8,752.2 rectangle 1204.4,835.8 1257.6,865.2
fill rgba(0,255,0,0.3) rectangle 519.2,125.8 559.8,155.2 rectangle 535.2,334.8 589.8,364.2 rectangle 637.4,370.8 690.6,400.2 rectangle 537.2,531.6 591.8,562.4 rectangle 534.2,748.8 588.8,778.2 rectangle 535.4,928.8 588.6,958.2 rectangle 628.6,976.6 680.4,1007.4 rectangle 1304.4,687.8 1357.6,717.2 rectangle 1306.2,721.8 1360.8,751.2 rectangle 1301.6,836 1353.4,864
fill rgba(0,255,0,0.5) rectangle 538.4,287.6 591.6,318.4 rectangle 536.2,437 590.8,465 rectangle 534,782.4 590,814.6 rectangle 534.4,877.8 587.6,907.2 rectangle 878.1,221 958.9,253 rectangle 1091,221 1163,253 rectangle 878.1,262.6 958.9,307.4 rectangle 1091,262.6 1163,307.4 rectangle 1291,428.1 1371,460.9
fill rgba(255,0,0,0.5) rectangle 1291,220.1 1371,252.9 rectangle 1291,262.5 1371,306.5 rectangle 878.2,318.5 959.8,362.5 rectangle 1091,317.6 1163,362.4 rectangle 1291.9,317.6 1371.1,362.4 rectangle 878.2,373.7 959.8,419.3 rectangle 1091,373.7 1163,419.3 rectangle 1291.9,373.6 1371.1,418.4 rectangle 878.2,429.1 959.8,461.9 rectangle 1091,428.9 1163,460.1 rectangle 878.1,468.9 958.9,500.1 rectangle 1091,468 1163,500 rectangle 1291,468 1371,500 rectangle 878.1,508 958.9,540 rectangle 1091,508 1163,540 rectangle 1291,507 1371,539 rectangle 878.1,551.2 958.9,608.8 rectangle 1091,551.2 1163,608.8 rectangle 1291,550.3 1371,608.7 rectangle 878.1,621.6 958.9,666.4 rectangle 1091,621.6 1163,666.4 rectangle 1291,621.6 1371,666.4
fill darkblue font-size 13 text 200.6,135.8'84-1' text 519.2,135.8'87-2' text 538.4,297.6'317-3' text 639.2,297.8'322-4' text 535.2,344.8'463-5' text 638.2,347.8'479-6' text 535.4,381.8'605-7' text 637.4,380.8'601-8' text 536.2,447'728-9' text 636.4,448.8'744-10' text 537.2,541.6'999-11' text 636.2,541.6'1005-12' text 534.2,758.8'1483-13' text 631.2,758.8'1489-14' text 534,792.4'1595-15' text 630.4,792.8'1589-16' text 534.4,887.8'1762-17' text 631.2,887.6'1767-18' text 535.4,938.8'1837-19' text 630.4,936.8'1827-20' text 536.2,987.8'1890-21' text 628.6,986.6'1886-22' text 878.1,231'194-23' text 1091,231'198-24' text 1291,230.1'189-25' text 878.1,272.6'276-26' text 1091,272.6'280-27' text 1291,272.5'286-28' text 878.2,328.5'418-29' text 1091,327.6'404-30' text 1291.9,327.6'411-31' text 878.2,383.7'558-32' text 1091,383.7'563-33' text 1291.9,383.6'570-34' text 878.2,439.1'695-35' text 1091,438.9'701-36' text 1291,438.1'691-37' text 878.1,478.9'869-38' text 1091,478'859-39' text 1291,478'865-40' text 878.1,518'952-41' text 1091,518'957-42' text 1291,517'948-43' text 878.1,561.2'1069-44' text 1091,561.2'1072-45' text 1291,560.3'1063-46' text 878.1,631.6'1193-47' text 1091,631.6'1198-48' text 1291,631.6'1203-49' text 1202.4,698.8'1331-50' text 1304.4,697.8'1326-51' text 1201.2,732.8'1403-52' text 1306.2,731.8'1397-53' text 1204.4,845.8'1685-54' text 1301.6,846'1691-55' " result.jpg

How to create a simple reflection using imagemagick with dynamic image sizing?

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.

Bandpass filter with ImageMagick

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.

Imagemagick change label font and squash

Is it possible to change the font of a label?
I have following command:
> convert -background none -bordercolor none -gravity west -fill white
> img1.png label:"1" -border 0x5 +swap -append -font "Helvetica-LT-55-Roman" label:"Chapter 1" -border
> 0x5 -append -write miff:- +delete img2.png label:"2" -border 0x5 +swap
> -append label:"Chapter 2" -border 0x5 -append -write miff:- +delete img3.png label:"3" -border 0x5 +swap -append label:"Chapter 3" -border
> 0x5 -append -write miff:- +delete img4.png label:"4" -border 0x5 +swap
> -append label:"Chapter 4" -border 0x5 -append -write miff:- +delete img5.png label:"5" -border 0x5 +swap -append label:"Chapter 5" -border
> 0x5 -append miff:- | montage -set label "" miff:- -tile 3x2 -geometry
> +15-10 -background none result.png
which creates me an image with 5 image, each image has a text above and under.
If I:
convert -list font
it does show me the font I want to use.
Thus is there a way to squash the label(text) width?
Please try to make your examples simpler!
Do you want to know how to change the font of a label? Or do you want to know how to crop a label's width?
If you list your fonts like this:
identify -list font
Output
Font: Palatino-Bold
family: Palatino
style: Normal
stretch: Normal
weight: 700
glyphs: /usr/local/share/ghostscript/fonts/p052004l.pfb
Font: Palatino-BoldItalic
family: Palatino
style: Italic
stretch: Normal
weight: 700
glyphs: /usr/local/share/ghostscript/fonts/p052024l.pfb
Font: Palatino-Italic
family: Palatino
style: Italic
stretch: Normal
weight: 400
glyphs: /usr/local/share/ghostscript/fonts/p052023l.pfb
Font: Palatino-Roman
family: Palatino
style: Normal
stretch: Normal
weight: 400
glyphs: /usr/local/share/ghostscript/fonts/p052003l.pfb
You can then create a label with a Palatino-Italic font and trim it like this:
convert -undercolor yellow -pointsize 36 -font Palatino-Italic label:"Palatino-Italic" -trim result.png
What does "squash" mean? Please define or provide an example of such a process.
If you mean distort the image to have a smaller width, then you can use -resize to do so. For example to reduce the width by half and keep the height the same, use -resize 50x100%

Resources