Page 1 of 1

help me to crop image with command line

Posted: 2016-04-08T14:48:10-07:00
by kodok_buncit
hi can anyone help me to crop underline border in this image :
https://s3-ap-southeast-1.amazonaws.com ... dnkbfj.jpg

im try to extract the phone number using tesseract and gocr, but none work without removing the border.

any help/hint really appreciated.

thanks :D

Re: help me to crop image with command line

Posted: 2016-04-08T14:51:14-07:00
by fmw42
Please, always provide your IM version and platform when asking questions on this forum, since syntax may differ.

Re: help me to crop image with command line

Posted: 2016-04-08T15:01:06-07:00
by kodok_buncit
sorry sir,
Version: ImageMagick 6.9.2-10 Q16 i686 2015-12-28
platform : Linux 3.12.52-1-MANJARO 32 bit

Re: help me to crop image with command line

Posted: 2016-04-08T19:52:09-07:00
by fmw42
Scale the image down to one column. Then convert to txt format and find the darkest y coordinate, then crop your original image up to the pixel right above that value in y. So in this case as below crop the top 20 vertical rows of your original image.

Code: Select all

convert phone_number20160310-17367-1dnkbfj.jpg -scale 1x! txt:
# ImageMagick pixel enumeration: 1,25,65535,srgb
0,0: (65288,65288,65288) #FEFEFE srgb(254,254,254)
0,1: (65223,65223,65223) #FEFEFE srgb(254,254,254)
0,2: (65203,65203,65203) #FEFEFE srgb(254,254,254)
0,3: (65201,65201,65201) #FEFEFE srgb(254,254,254)
0,4: (40153,40153,40153) #9C9C9C srgb(156,156,156)
0,5: (30797,30797,30797) #787878 srgb(120,120,120)
0,6: (29881,29881,29881) #747474 srgb(116,116,116)
0,7: (39217,39217,39217) #999999 srgb(153,153,153)
0,8: (42193,42193,42193) #A4A4A4 srgb(164,164,164)
0,9: (45263,45263,45263) #B0B0B0 srgb(176,176,176)
0,10: (38786,38786,38786) #979797 srgb(151,151,151)
0,11: (34578,34578,34578) #878787 srgb(135,135,135)
0,12: (35630,35630,35630) #8B8B8B srgb(139,139,139)
0,13: (41289,41289,41289) #A1A1A1 srgb(161,161,161)
0,14: (43025,43025,43025) #A7A7A7 srgb(167,167,167)
0,15: (42405,42405,42405) #A5A5A5 srgb(165,165,165)
0,16: (39133,39133,39133) #989898 srgb(152,152,152)
0,17: (34318,34318,34318) #868686 srgb(134,134,134)
0,18: (30975,30975,30975) #797979 srgb(121,121,121)
0,19: (38511,38511,38511) #969696 srgb(150,150,150)
0,20: (315,315,315) #010101 srgb(1,1,1)
0,21: (65203,65203,65203) #FEFEFE srgb(254,254,254)
0,22: (65259,65259,65259) #FEFEFE srgb(254,254,254)
0,23: (65321,65321,65321) #FEFEFE srgb(254,254,254)
0,24: (65535,65535,65535) #FFFFFF white

Re: help me to crop image with command line

Posted: 2016-04-09T05:57:22-07:00
by glennrp

Code: Select all

convert in.jpg -fuzz 25%  -trim temp.jpg
convert temp.jpg -fuzz 25%  -trim trimmed.jpg
First trims the white excess, second trims the black line.

Re: help me to crop image with command line

Posted: 2016-04-10T05:23:01-07:00
by kodok_buncit
thank sir it works !
btw, i found my own solution

Code: Select all

mogrify -crop 155x19+0x0 jp1.jpg
love this forum friendly community :-)