HI
I have the following image with a thick black shadow line running through the image near the top. I would like to trim the top part of the image off including the dark shadow line. I need to be able to do this automatically.
https://www.dropbox.com/s/ow0ntk3is4vwf ... 2.JPG?dl=0
Trim image based on thick line
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Trim image based on thick line
I would do it like this. Windows BAT syntax:
The output from "-process onewhite" is "onewhite: 0,393". A script would grab the second number (393), and use that in the crop.
(If you don't have onewhite, a sub-image search would be fast, as the image is only 1 pixel wide.)
Code: Select all
set SRC=IMG_0102.JPG
convert ^
%SRC% ^
-threshold 7%% ^
-scale "1x^!" ^
-auto-level ^
-fuzz 90%% ^
-fill Black ^
-draw "color 0,0 floodfill" ^
-fuzz 0 ^
-process onewhite ^
NULL:
convert ^
%SRC% ^
-crop +0+393 +repage ^
r.png
(If you don't have onewhite, a sub-image search would be fast, as the image is only 1 pixel wide.)
snibgo's IM pages: im.snibgo.com