Go Back   TechArena Community > Software > Operating Systems
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-03-2009
Member
 
Join Date: Feb 2009
Posts: 32
How to rename/resize images in Linux ?

hello everyone....

I wanted to perform some image-related functions in my Linux operating system. I tried to find about it but didn't work out. Can anyone of you help me in image renaming and resizing in Linux ?
thanks
Reply With Quote
  #2  
Old 17-03-2009
Member
 
Join Date: Apr 2008
Posts: 3,260
Re: How to rename/resize images in Linux ?

In Linux, you can rename and resize images with bash script from console
Linux have simple solution, a simple bash script can do the job.

Here is the bash script:

#!/bin/sh
counter=1
root=mypict
resolution=400x300
for i in `ls -1 $1/*.jpg`; do
echo "Now working on $i"
convert -resize $resolution $i ${root}_${counter}.jpg
counter=`expr $counter + 1`


Save the script in a file called picturework.sh and make it executable with
chmod u+x picturework.sh

and store it somewhere in your path. Now, if you have a bunch of .jpg files in the directory /path/to/dirpic, all you have to do is to execute
picturework.sh /path/to/dirpic

and in the current directory you'll find mypict_1.jpg, mypict_2.jpg etc, which are the resized versions of your original ones.
You can change the script according to your needs.
Reply With Quote
  #3  
Old 17-03-2009
Member
 
Join Date: Jan 2008
Posts: 3,384
Re: How to rename/resize images in Linux ?

If you want to do a batch rename and resize of a number of pictures in a directory, use this script below. This script requires ImageMagick to be installed.

Change the root=picture to whatever you would like the beginning of the filename to be (ie: root=wedding, etc.) and what this script will do is create wedding_1.jpg, wedding_2.jpg, etc.. all at 640?480.

#!/bin/sh
counter=1
root=picture
resolution=640?480
for i in `ls -1 $1/*.jpg`; do
echo “Now working on $i”
convert -resize $resolution $i ${root}_${counter}.jpg
counter=`expr $counter + 1

Change the resolution to suit your needs. Enjoy!
Reply With Quote
  #4  
Old 17-03-2009
Dr. V
 
Posts: n/a
Re: How to rename/resize images in Linux ?

You could use the convert utility that comes with imagemagick.

If you want to set the image size say...640x480

convert -geometry 640x480 file file_with_new_size

(you replace 640x480 with whatever you want the new size to be)

If you want to script this, go for something like

for x in $(ls)
do
convert -geometry 320x240 $x new-$x
Reply With Quote
Reply

  TechArena Community > Software > Operating Systems
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to rename/resize images in Linux ?"
Thread Thread Starter Forum Replies Last Post
Auto resize images while importing in Microsoft Excel SirName Windows Software 3 21-01-2012 01:01 PM
Automatically resize images from an XML AZUL Software Development 4 22-01-2010 10:03 PM
resize images with outlook express Abshir Windows Software 3 15-06-2009 11:08 PM
Quickly Resize Multiple Images With A Single Click In Vista jhon Customize Desktop 3 07-04-2009 11:39 AM
Resize images using Powertoy in Windows XP AmdUser Windows Software 3 07-02-2009 07:09 PM


All times are GMT +5.5. The time now is 01:17 PM.