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?
Can't even crop
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Can't even crop
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
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
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Can't even crop
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.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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Can't even crop
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
Re: Can't even crop
I think they want vertical strips that can be made using:
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?
Code: Select all
convert input.jpg -crop 10 output.jpg
Re: Can't even crop
What about something like
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.
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