How can I fix the corners of the image and remove white space
Posted: 2016-07-14T04:47:18-07:00
How can I fix (stretch outside) the corners of the image and remove white space.
Here is my demo image.
Here is my demo image.
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://imagemagick.com/discourse-server/
https://imagemagick.com/discourse-server/viewtopic.php?t=30073
Code: Select all
code in.jpg -fuzz 5% -trim +repage out.png
Code: Select all
set SRC=itWGqb5.jpg
%IM%convert %SRC% -fuzz 5%% -trim +repage s0.png
set UNUSED_COL=Blue
%IM%convert ^
s0.png ^
-bordercolor White -border 1 ^
-fuzz 5%% ^
-fill %UNUSED_COL% ^
-draw "color 0,0 floodfill" ^
-shave 1 ^
+write s1.png ^
-fill White +opaque %UNUSED_COL% ^
-fill Black -opaque %UNUSED_COL% ^
mask.png
rem (Uses s0.png and mask.png from first method).
for /F "usebackq" %%L in (`%IM%identify ^
-format "WW=%%w\nHH=%%h\nWm1=%%[fx:w-1]\nHm1=%%[fx:h-1]" ^
s0.png`) do set %%L
set EDGE_COL=blue
%IM%convert ^
mask.png ^
( -clone 0 ^
-sparse-color bilinear ^
0,0,#000,^
%%[fx:w-1],0,#f00,^
0,%%[fx:h-1],#0f0,^
%%[fx:w-1],%%[fx:h-1],#ff0 ^
) ^
( -clone 0 ^
-fill %EDGE_COL% -colorize 100 ^
) ^
-swap 0,2 ^
-compose Over -composite ^
+write idAbsMap.png ^
-crop x1 +repage ^
-bordercolor %EDGE_COL% -border 1 ^
-trim +repage ^
-resize "%WW%x1^!" ^
-append ^
stretchMap.png
rem Apply the stretched absolute displacement map.
%IM%convert ^
s0.png ^
s2s_cent_relmapinv.png ^
-compose Displace ^
-set option:compose:args %Wm1%x0 -composite ^
stretched2.png
rem Make a version for the web.
%IM%convert ^
stretched2.png ^
-resize 600x600 ^
stretched2.jpg