Page 1 of 1

How to crop this image so only the middle part remains ?

Posted: 2013-08-18T03:20:38-07:00
by Rye
Example:

Image

Would be nice to also get an explanation.


Thanks in advance

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T03:31:32-07:00
by Bonzo
How much do you want to crop?

If you just want to remove the black lines on the sides you could add a black border to the whole image and then use -trim.

If you just wanted the star You could do as above and then add another -trim which should crop to the edges of the star.

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T03:46:46-07:00
by Rye
I want to crop the picture so only the white area remains.

As simple as possible.

Would be best if the command could be used on all png's in one folder (batch).

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T04:31:46-07:00
by Bonzo
So you are not even going to try it yourself after I gave you the explanation above?

Code: Select all

convert crop.png -bordercolor black -border 1x1 -trim output.jpg
I will let you work out how to work on multiple images as the question has been asked multiple times on the forum.

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T04:55:50-07:00
by Rye
Ok, trim actually "is" simple enough. Always dazzles me how ImageMagick simplyfies thes processes

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T08:17:30-07:00
by Rye
These didn't come out like I wanted (a small border remains):
[spoiler]
Image
Image
[/spoiler]

Ideas ?

Re: How to crop this image so only the middle part remains ?

Posted: 2013-08-18T09:00:13-07:00
by Bonzo
Your background is not exactly black; you need to add a -fuzz:

Code: Select all

convert crop.png -bordercolor black -border 1x1 -fuzz 10% -trim output.jpg