Rounded corner: cutroundcorner
Parameter: $1: edgesize $2: width (I. e. Height) $3: radius $4: srcfilename $5: destfilename
Note: $1 indicates the length of the removed advertising area, $2 indicates the edge length of the final square rounded corner image, and $3 indicates the radius of the rounded corner.
Example: cutroundcorner 20 100 20 1.jpg 1.png
Source codeAs follows:
#! /Bin/bash
# --- $1: edgesize $2: width (I. e. Height) $3: radius $4: srcfilename $5: destfilename ---
Echo "start cutting image $1 ...."
Info = 'identify-format "% wx % H" $4'
Idx = 'expr Index "$ Info" 'X''
Idx_w = $(idx-1 ))
Idx_h = $ (idx + 1 ))
Width = 'expr substr "$ Info" 1 $ idx_w'
Height = 'expr substr "$ Info" $ idx_h 20'
Echo "width: $ width"
Echo "height: $ height"
If ($ width> $ height ))
Then
Echo "width longer"
Cropx = $ ($ width-height)/2 + $1 ))
Cropy = $1
Nsize = $ ($ height-$1*2 ))
Else
Echo "height longer"
Cropx = $1
Cropy = $ ($ height-$ width)/2 + $1 ))
Nsize = $ ($ width-$1*2 ))
Fi
Convert-crop "$ nsize x $ nsize + $ cropx + $ cropy"-resize $ 2x $2! -Roundcorner $3 $4 $5
The effect of the cropped transparent rounded corner is as follows: