The original
The result I want.
The result with command
Code: Select all
convert original.png -trim +repage out.png
Code: Select all
convert original.png -trim +repage out.png
I can get your described result by using IM 6.8.9-9 in the ubuntu bash shell in Windows 10, running this command...
Code: Select all
convert test.png -write mpr:input -duplicate 3 \
-distort SRT %[fx:t*90] -background none -layers merge -trim \
-set option:pagewide %[w] -set option:pagehigh %[h] -set option:pageoffset %[fx:page.x] \
-delete 0 mpr:input -set page %[pagewide]x%[pagehigh]-%[pageoffset]-%[pageoffset] \
-coalesce result.png
Code: Select all
convert test.png -write mpr:input -background none \
-rotate 180 mpr:input -composite -set page %[@] \
-set option:bounds %[fx:u.page.width]x%[fx:u.page.height]-%[fx:u.page.x]-%[fx:u.page.y] \
-delete 0 mpr:input -set page %[bounds] -coalesce result.png
Code: Select all
magick lBW9I.png ( +clone -trim -set option:NTRIM %[fx:min(min(page.x,page.width-w-page.x),min(page.y,page.height-h-page.y)*page.width/page.height)]x%[fx:min(min(page.y,page.height-h-page.y),min(page.x,page.width-w-page.x)*page.height/page.width)] +delete ) -shave %[NTRIM] x.png