Rahul Dagli
Rahul Dagli

Reputation: 4502

How to chop selective images using ImageMagick

I would like to chop screenshot images that are specifically of mobile. And bundle them into pdf in sequence.

#!/bin/sh

desktop_path=./screenshots/desktop/
mobile_path=./screenshots/mobile/
pdf_path=./pdf/

convert ${desktop_path}screenshot-1.png ${desktop_path}screenshot-2.png ${desktop_path}screenshot-3.png ${desktop_path}screenshot-4.png ${desktop_path}screenshot-5.png ${desktop_path}screenshot-6.png ${desktop_path}screenshot-7.png ${desktop_path}screenshot-8.png ${desktop_path}screenshot-9.png ${desktop_path}screenshot-10.png ${desktop_path}screenshot-11.png ${desktop_path}screenshot-12.png ${desktop_path}screenshot-13.png -chop 0x0 ${mobile_path}screenshot-1.png ${mobile_path}screenshot-2.png ${mobile_path}screenshot-3.png ${mobile_path}screenshot-4.png ${mobile_path}screenshot-5.png ${mobile_path}screenshot-6.png ${mobile_path}screenshot-7.png ${mobile_path}screenshot-8.png ${mobile_path}screenshot-9.png ${mobile_path}screenshot-10.png ${mobile_path}screenshot-11.png ${mobile_path}screenshot-12.png ${mobile_path}screenshot-13.png ${mobile_path}screenshot-14.png -chop 0x43 ${pdf_path}packets-temp.pdf

The issue I'm facing here is that even though I've defined -chop 0x0 for desktop its not skipping the chop for desktop instead it's chopping 43px for desktop just like on the mobile.

Upvotes: 0

Views: 141

Answers (2)

Rahul Dagli
Rahul Dagli

Reputation: 4502

#!/bin/sh

desktop_path=./screenshots/desktop/
mobile_path=./screenshots/mobile/
mobile_cropped_path=./screenshots/mobile/cropped/
pdf_path=./pdf/

mogrify -path ${mobile_cropped_path} -chop 0x43 ${mobile_path}*.png 

convert ${desktop_path}*.png ${mobile_cropped_path}*.png ${pdf_path}packets-temp.pdf

Upvotes: 0

Mark Setchell
Mark Setchell

Reputation: 207345

If you don't want the chop applied to some images, put the ones you do want chopped in parentheses and just chop them:

convert NoChop.png \( ChopMe.png ChopMeToo.png -chop 10x10 \) ... 

Or, load the ones you want chopped first, chop them, then add the ones you don't want chopped:

convert ChopMe.png ChopMeToo.png -chop 10x10 NoChop.png ...

Upvotes: 1

Related Questions