image ordering by Original Date Time using bash script

Here is the script:

#!/bin/bash -
#===============================================================================
#
#          FILE: imgOrg.sh
#
#         USAGE: ./imgOrg.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#      REVISION:  ---
#===============================================================================

for i in *
do
    if [[ $(file $i) == *image* ]] 
    then
        echo "Image file is :: $i"
        dir=$( exiftool -s -DateTimeOriginal $i | awk -F':' '{print $2"/"$3}')
        mkdir -p $dir
        cp $i $dir/
    else
        echo "Excluding $i"
    fi
done

 

Script looks at the DateTimeOriginal parameter in output of exiftools ( which is basically the date and time image was taken) and then puts the images in the folder in format YYYY/MM.

PHP Image gallery with fancybox.

So, I was looking for some quick to setup PHP Image gallery file. I found couple but none of them suited my needs too well. So I had to write my own.

Very simple PHP script to show all the images under ‘images’ folder.

Shows some details in the images.

 

That is all that I wanted and that is all that this script does. So pretty simple single php file. Dependency is on fancybox so you will need the jquery and all but nothing else is required.

https://github.com/raj77in/PHP-ImagaeGallery.git

Resize all the images in directory.

Geotagger "Solmeta N2 Kompass" for N...
Image via Wikipedia

When I take a photo with my DSLR Nikon D5000, the size of the image comes to around 5MB and I know that with my point and shoot camera also it does not come to any lesser than 3MB. Definitely this is quite good to keep the images in the same size for use but when it comes to on-line sharing I don’t think this is the size that is required. I guess mosr of the time 1024×768 is sufficient. Even if you are sending the images in email, you cannot afford to send a lot of images of this size even with a gmail account.

So, what do you do? Again you cannot open gimp or any such program to modify couple of photos and spend couple of hours in modifying the files before sharing or sending it in email. So, if you are on linux (which you are, if you are reading this blog entry), then here’s a simple bash script that you can use to resize all your images.

1
2
3
4
5
6
7
8
9
10
11
12
13
size="<a class="zem_slink" title="Display resolution" rel="wikipedia" href="http://en.wikipedia.org/wiki/Display_resolution">640x480</a>"

prefix="img-"

for i in *;
do
t=`file $i`
if [[ "$t" =~ 'image' ]]
then
convert -resize $size $i $prefix$i
echo "$i resized";
fi
done

Note: You will not get the exact size of image as specified in the size option. For example if you specify 640×640 still you would get 640×480 depending on your photos aspect ratio. Also, you can specify the size in percentage like “50%” 🙂

Enhanced by Zemanta