Crop borders

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
CSharpCoder
Posts: 2
Joined: 2017-02-28T13:34:31-07:00
Authentication code: 1151

Crop borders

Post by CSharpCoder »

How do I crop an image at its center, so that it gives the image a certain size while only cutting the borders away (no scaling)? OR how do I give it borders that gives the image a certain total size?

The best I got right now is

Code: Select all

-crop 180x152
but it crops at the upper left corner, which is not what I want.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Crop borders

Post by snibgo »

"-crop" should usually have offsets for the top-left (or center etc) of the crop, eg:

Code: Select all

-crop 180x152+0+0
-crop 180x152+23+34
See http://www.imagemagick.org/script/comma ... s.php#crop

What version IM do you use? On what platform?
snibgo's IM pages: im.snibgo.com
CSharpCoder
Posts: 2
Joined: 2017-02-28T13:34:31-07:00
Authentication code: 1151

Re: Crop borders

Post by CSharpCoder »

Solved it. Don't use crop.
extent was what I was looking for. Although you have to apply it to the center (-gravity center) and set the background as transparent (-background none)

Code: Select all

-background none -gravity center -extent 180x152
Post Reply