Re-size and Copy part 2

I made a few updates to my image_resize.sh script. This one just plows through the directories, converts them and copies them all to one mega folder. I think I will keep a flat image structure for the ones being shown on Magento. This way its all in one place. I’ll make some edits, such as ammending the timestamp on the end of the file. Check it out:

#!/bin/bash
#Filename: resize_images.sh
#Description: A script for image resizing for my e-commerce site
#Creator: Mitan Chandihok
#Date: July 6th, 2013

source_dir="$1"
#images_dir="$2"
images_dir="/home/sysadmin/tmp/IMAGES"

# For each image file run loop
#for img in $(find "$source_dir" -type f -name "*.jpg")
find "$source_dir" -type f -name "*.jpg" | while read img;
do

# Seperate the filename
source_file=$img
file_name=$(basename "$source_file")

# Do the conversion and save to specified folder
echo "Processing file : $file_name"
convert "$source_file" -resize 150 "$images_dir"/thumb_"$file_name"
convert "$source_file" -resize 400 "$images_dir"/small_"$file_name"
convert "$source_file" -resize 1000 "$images_dir"/large_"$file_name"

done

Script to resize images for my e-commerce website

Since I am going to be getting my e-commerce website up and running, image management for my products are VERY important.  On top of taking clear photographs of my items, I also need to resize them depending on their use.

For magento, the three sizes used are thumbnail, small, and large.  What I do is I leave a very high res photo as my original in a directory.  Then I made a bash script which will resize those images into those three sizes and stick them in an appropriate subdirectory of the main image directory.  Here’s the script:

#!/bin/bash
#Filename: resize_images.sh
#Description: A script for image resizing for my e-commerce site
#Creator: Mitan Chandihok
#Date: July 6th, 2013

source_dir=$1

# For each image file run loop
for img in $(find "$source_dir" -type f -name "*.jpg")
do

# Set variables and make sure directories exist
source_file=$img
dir_path=$(readlink -f "$source_dir")
file_name=$(basename "$source_file")
thumb_dir="$dir_path/thumb/"
small_dir="$dir_path/small/"
large_dir="$dir_path/large/"
mkdir -p "$thumb_dir"
mkdir -p "$small_dir"
mkdir -p "$large_dir"

thumb_dir="$thumb_dir/$file_name"
small_dir="$small_dir/$file_name"
large_dir="$large_dir/$file_name"

# Do the conversion
echo Processing file : $file_name
convert $source_file -resize 150 $thumb_dir
convert $source_file -resize 400 $small_dir
convert $source_file -resize 1000 $large_dir
done

Feel free to use this script for your own purposes.

Magento Install on Ubuntu

I have been familiar with Magento for a few years now.  I had it on my web host, but accessing it was so slow that it was barely unusable.

To get more familiar with it, I followed this tutorial on how I can install it locally on my own linux server.

I must say, having it installed locally make it run a lot faster than when accessing it over the web remotely.  I hope I can get a better understanding of the backend so I can become a master at it slowly