Imagemagick Resize Rule

These are some pattern codes for resize using Imagemagick

Pattern 1 (resize to 960×550 px)
( Original size width > Target size width ) and (Original size height > Target size height) and ( (Original size width / Original size height) > (Target size width / Target size height)

pattern1

convert [original.jpg]  -resize x550 -gravity center -crop 960×550+0+0 +repage [result.jpg]
or
convert [original.jpg] -resize x550^ -gravity center -extent 960×550 [result.jpg]

Pattern 2 (resize to 960×550 px)
( Original size width > Target size width ) and (Original size height > Target size height) and ( (Original size width / Original size height) < (Target size width / Target size height)

pattern2

convert [original.jpg]  -resize 960x^ -gravity center -crop 960×550+0+0 +repage [result.jpg]
or
convert [original.jpg] -resize 960x^ -gravity center -extent 960×550 [result.jpg]

Pattern 3 (resize to 900×900 px)
( Original size width > Target size width ) and (Original size height < Target size height)

pattern3

convert [original.jpg] -size 900×900 xc:#141414 +swap -gravity center -composite [result.jpg]

Pattern 4 (resize to 1200×900 px)
( Original size width < Target size width ) and (Original size height > Target size height)

pattern4

convert [original.jpg] -size 1200×900 xc:#141414 +swap -gravity center -composite [result.jpg]

Pattern 5 (resize to 300×300 px)
( Original size width < Target size width ) and (Original size height < Target size height)

pattern5

convert [original.jpg] -size 300×300 xc:#141414 +swap -gravity center -composite [result.jpg]

Yes, 5 patterns😀
I hope you enjoy this example of using imagemagick resize rule😀

Imagemagick Resize Rule

2 thoughts on “Imagemagick Resize Rule

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s