Page 1 of 1

Can't even crop

Posted: 2013-07-01T22:09:02-07:00
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?

Re: Can't even crop

Posted: 2013-07-01T22:29:18-07:00
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

Re: Can't even crop

Posted: 2013-07-02T00:01:20-07:00
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.

Re: Can't even crop

Posted: 2013-07-02T09:56:23-07:00
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.

Re: Can't even crop

Posted: 2013-07-02T11:34:05-07:00
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

Re: Can't even crop

Posted: 2013-07-02T11:45:55-07:00
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?

Re: Can't even crop

Posted: 2013-07-03T05:36:36-07:00
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.