Kevin Old
Kevin Old

Reputation: 1029

Crop 40/60 with ImageMagick

I know how to use -crop 50%x100% to split an image in half (50/50) but is there a way to crop into 40/60?

If I use

convert -crop 40%x100% in.jpg out.jpg

I end up getting:

out-0.jpg // 40%
out-1.jpg // 40%
out-2.jpg // remaining %

Upvotes: 2

Views: 650

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207465

You can do it in a single command like this:

convert in.jpg                                                               \
  \( +clone -gravity east -crop 60x100% +repage +write east.jpg +delete \)   \
  -gravity west -crop 40x100% +repage west.jpg

Upvotes: 1

Iamiuru
Iamiuru

Reputation: 479

convert in.jpg -gravity west -crop 40%x100% +repage out1.jpg
convert in.jpg -gravity east -crop 60%x100% +repage out2.jpg

I'm sure there is a more complex way, but I would just do it in two commands.

Upvotes: 2

Related Questions