[imageMagick] easy resize of images with ratio keeping
ImageMagick is a real swiss knife for people that want to manipulate pictures.
In this post, I’ll only give an easy way to resize an image and keep its proportions.
Suppose you have an nice wallpaper (eg, downloaded from Vlad Studio site) on your “full HD” (ok, now i’m supposed to say “hd 1080p”…), and your girlfriend wants it on her laptop which resolution is 1440x900.
Consider these assertions :
1980x1080 is the TV/cinema (16/9) format (now imported to most computer monitors)
1440x900 is an computer format (16/10)
Their ratios are :
16/9 (or 1920/1080) : 1.77777777777777777777
16/10 (or 1440/900, 1280/800, 1920/1200) : 1.6
In this example, i’ll only use 2 ImageMagick commands (see documentation for more) :
syntax : convert image_src -resize geometry image_dst
example : [survietamine@desktop Downloads]$ identify vladstudio_atlantis_docking_1920x1080.jpg
vladstudio_atlantis_docking_1920x1080.jpg JPEG 1920x1080 1920x1080+0+0 8-bit DirectClass 529KB 0.000u 0:00.000
[survietamine@desktop Downloads]$ echo '1920/1080' | bc -l
1.77777777777777777777
[survietamine@desktop Downloads]$ convert vladstudio_atlantis_docking_1920x1080.jpg -resize 1440 vladstudio_atlantis_docking_1440.jpg
[survietamine@desktop Downloads]$ identify vladstudio_atlantis_docking_1440.jpg
vladstudio_atlantis_docking_1440.jpg JPEG 1440x810 1440x810+0+0 8-bit DirectClass 351KB 0.000u 0:00.000
[survietamine@desktop Downloads]$ echo '1440/810' | bc -l
1.77777777777777777777
For more information about the ‘geometry’ section of ImageMagick :
http://www.imagemagick.org/script/command-line-processing.php?#geometry