Can't even crop

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
CyberMew
Posts: 2
Joined: 2013-07-01T22:03:16-07:00
Authentication code: 6789

Can't even crop

Post by CyberMew »

I am using ImageMagick 6.8.6-3-Q16.

I am cropping parts of a png image with transparency, i.e. the width and height must retain. What it does for me is it indeed crops out part of the image, but removes the rest of the canvas as well. This is different from what the documentation stated, i.e. the size of the displayed image (its 'virtual canvas' or page size) has not been effected by the "-crop" operation. I tried to add -repage, but it still repaged I think.

It is making very hard for me to crop out X amount of equal columns. Any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't even crop

Post by fmw42 »

Works fine for me with IM 6.8.6.3 Q16 Mac OSX either way.

Do you want to remove the virtual canvas or keep it?

To remove it, use +repage

convert image.png -crop WxH+X+Y +repage croppedimage.png

To keep it, leave off the +repage

convert image.png -crop WxH+X+Y croppedimage.png


See
http://www.imagemagick.org/Usage/crop/#crop_repage
http://www.imagemagick.org/Usage/crop/#crop
CyberMew
Posts: 2
Joined: 2013-07-01T22:03:16-07:00
Authentication code: 6789

Re: Can't even crop

Post by CyberMew »

I want the width and height to remain the same. I did just that: convert image.png -crop WxH+X+Y croppedimage.png

and it really fully crop the portion like what paint/ps do. I am using this because I want it to equally split the image into 10x1 but still using the same width/height, so I can use them as layers in photoshop.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't even crop

Post by fmw42 »

CyberMew wrote:I want the width and height to remain the same. I did just that: convert image.png -crop WxH+X+Y croppedimage.png

and it really fully crop the portion like what paint/ps do. I am using this because I want it to equally split the image into 10x1 but still using the same width/height, so I can use them as layers in photoshop.
I am not sure I really understand. Can you clarify further? There is no point in cropping an image to its very same size. It will not split the image into multiple parts. You may need some other operator. But I am not sure what you are trying to do.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't even crop

Post by snibgo »

Perhaps the OP doesn't want to crop at all, but to (a) define a rectangle within the image amd (b) make everything outside that rectangle transparent. For example, Windows script:

Code: Select all

D:\web\im>convert ^
  in.png ^
  ( +clone ^
    -fill Black -colorize 100 ^
    -fill White -draw "rectangle 100,200 199,249" ^
  ) ^
  -alpha off -compose CopyOpacity -composite ^
  out.png
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Can't even crop

Post by Bonzo »

I think they want vertical strips that can be made using:

Code: Select all

convert input.jpg -crop 10 output.jpg
This should give vertical strips of image in the virtual canvas which when placed over each other will give the complete original image. BUT for some reason the virtual canvas is being removed; it seems to work with png. Does jpg not support a virtual canvas?
holden
Posts: 79
Joined: 2013-02-07T08:22:57-07:00
Authentication code: 6789

Re: Can't even crop

Post by holden »

What about something like

Code: Select all

convert -size WxH (W and H being the finished canvas size) xc:(whatever alpha is) ( originalimage.jpg -crop wxh+0+0 ) -composite imageout.jpg
Sorry for the unknowns, I'm still pretty new and am not sure of the proper way to use alpha in IM. You would also need a command to place the image on the canvas, like -gravity or -page.
Post Reply