Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

Resize photos in a directory

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
TIgerV
Asked:
TIgerV
  • 2
1 Solution
 
Morne LateganCommented:
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
 
Morne LateganCommented:
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now