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
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
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.
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!
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
Bookmarks