Thursday, January 20, 2011

Facebook Image slicer

Something entirely new to my blog. This is a linux shell script which will generate sliced images from a bigger image. (nothing great as such). But if you upload the pictures in facebook in the order of their filenames, your album will look a little interesting!! Below is a sample which i made for myself :)

Below is the script. Its a linux shell script (sorry to those folks who use a windows m/c. I hope to come up with something for you guys soon) Copy and paste it into a text editor and save it with a .sh extension.

# facebook sliced image album creator
# (c) najeem muhammed ; www.idling-mind.blogspot.com
clear
echo "Enter the name of the image file you wish to slice"
read mf
rm facebook_slicer
convert -resize 704 "$mf" "$mf"_resized.jpg
mkdir facebook_slicer
mv "$mf"_resized.jpg facebook_slicer
cd facebook_slicer
myvar=`identify "$mf"_resized.jpg | awk '{print $3}' | sed 's/.*x//g'`
htcount=$((myvar/138))
for h in `seq $htcount`
do
croptop=$(((h-1)*138))
for w in `seq 4`
do
cropwd=$(((w-1)*181))
convert "$mf"_resized.jpg -crop 161x120+$cropwd+$croptop "$(((h-1)*4+w))".jpg
done
done
rm "$mf"_resized.jpg
echo "Slicing Done! Check the folder facebook_slicer. Upload the image in the order of the filenames."
exit 0


Copy your image into the same folder as the script. Open a terminal window in the above folder and enter the following command. 

sh your_script_filename.sh

You'll be prompted to enter the filename that you want to slice. Give the image name (with extension) that you want to use for your album. If the script worked fine, you'll get a message telling

Slicing Done! Check the folder facebook_slicer. Upload the image in the order of the filenames.

Do let me know if it worked for you. Post a comment with a link to your album! :)
Enjoy!!

PS: If its not working, check whether you have imagemagik installed in your linux system. 

I've been idle!

I've been idle for a lil while now! Have taken a late new year resolution that i'll make one post every week from now on!!