Solved

Resize photos in a directory

Posted on 2009-06-28
2
366 Views
Last Modified: 2013-12-16
I have a Virtual Private server that, through a script, gets a number of photos placed on it.  The script pulls the photos from an email attachment.

Recently, the size of the photos has increased dramatically, from 250k each to over 800K each.  

I would like to know if there is a linux command line that I could use (via cron pref.) to look in the directory and resize all photos over 450k to a lesser quality (10 to 8) or even a smaller size (1050x1500 to 400x1000)??

Thank you.
0
Comment
Question by:TIgerV
  • 2
2 Comments
 
LVL 7

Expert Comment

by:Morne Lategan
ID: 24733791
You can install imagemagick. It has several tools for the job, ranging from resizing to converting between formats. The one you are looking is a tool called mogrify.

http://www.imagemagick.org/script/mogrify.php

0
 
LVL 7

Accepted Solution

by:
Morne Lategan earned 500 total points
ID: 24733824
You'll have to play with the options to find what works best, but in order to get a list of files larger than a specific size, you can use:

find /path/to/images --size 400k --iname \*.jpg

And to run the script agains those:

for imgfile in `find /path/to/images --size 400k --iname \*.jpg`
do
  mogrify --resize 400x1000 $imgfile
done

Sor something like that.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to install java on RHEL image on EC2 4 27
awk sed variable in file 3 38
winscp where are logs stored 3 36
CENTOS DHCP Server / PXE/TFTP 14 79
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question