Solved

Resize photos in a directory

Posted on 2009-06-28
2
358 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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now