Quite often i find myself wanting to resize a whole directory of images. Rather than opening them all in the gimp, i do it through the command line. I seem to do this often enough that it’s worth recording here, for my own reference as well as for anybody else who would find it useful.
First of all, you need imagemagick.
sudo apt-get install imagemagick
Change directory to where the images are and create a subdirectory for the resized versions.
cd ~/Photos/2010/04/05 mkdir resized
My phone likes to put spaces in file names which really confuses things, so i convert them to underscores. You can skip this step if your filenames contain no spaces.
for image in *.jpg; do mv "$image" `echo $image | tr ' ' '_'`; done
Now for the clever bit: i run convert command on the image files, resizing them to 1024px and saving with a quality of 80%.
for image in *.jpg; do convert $image -resize 1024 -quality 80 resized/$image; done
Lovely wonderful linux! :D
One thing to note: it always resizes along the top edge, which may not be the longest edge. If you have a portrait file which is 1536×2048 it comes out at 1024×1365 (not 768×1024 as you might have expected).
The resize option can take a percentage, so if you know all your images are the same size then you could just send a 50% to reduce to half size.
for image in *.jpg; do convert $image -resize 50% -quality 80 resized/$image; done
Imagemagick is super-incredible-awesome so there probably is a way to deal with differently sized images at different orientations. If anybody knows, please add it in the comments! :)
I find that sometimes Imagemagick doesn't always work the best for resizing, some images show up as blank.
Great tip… i usually go over to my windows PC and do this as a batch in Photoshop… doing things on the command line is always much faster though!
ah, perhaps that happens when the image contains transparency or an alpha channel. thanks for the warning. resizing images from my phone or camera always works, however.
now if only the gimp had batch jobs …! ;) that would be so neat!
resizing the images in the commands is always faster than in designing. usually i used to do it one by one as the sizes for different images are different. But from the code snippet you have provided helps me alot in my task.
thank you…porno izleKızlık Bozma Pornosuporno izleporno izleonline flim izleemekli sandığı sorgulamaligtv maç izle
This article is very interesting. I share on facebook.
thanks for this post
Nice tips.I found it helpful.Thanks for sharing.
Thank you for sharing a good tutorial on how to re-size images on Linux. I just new to this OS and I really find it complicated. And by the way, I am using Ubuntu.
The article is informative to us & the indicating point also helpful.
Thanks for this great information.
Thats a great idea. no waste of time. Otherwise we have to to download the image then take in the photoshop and resize then again upload simply waste of time..
http://www.expertsfromindia.comThe post is all about quick way to resize images in Linux. The post is informative & is more time saving.I like the post & hope to see more of such.
I'm not so good with Linux, so I use Gimp
kale kasakale kasakale kasakale kasa