# # Author: Heir!1APPARENTs (aka TeaL) # # This script is expecting to run in GNU BASH version 3.2 or later, and is also # dependent on the 'convert' program from the Imagemagick package. # # You must make sure 'convert' is in $PATH, and that you run this script in the # same directory as the image you plan to use. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # reSizeAll() { xres=$1 yres=$2 renmask=$3 #Making the variable names friendly. echo "Re-sizing ... This could take a long time.." convert $renmask* -resize $(($xres))x$(($yres))! "final_"$renmask #Re-sizing all images in $PWD that begin with $renmask to the dimensions of the original image. echo "Done re-sizing, removing all old images.. last chance to pull the plug on it ctrl c .." sleep 5 rm $renmask* #Removing the old images. } reSize() { i=0 o=0 count=0 #Integers to be incremented, helps to get around nesting while loops, which BASH doesn't like. max=$1 xres=$2 yres=$3 picname=$4 renmask=$5 count2=$(( ($max*$max) + 1)) #Re-writing the passed variables to more friendly names, making a separate counter for opposite operation images. while [ $count -le $(($max*$max)) ] do ?if [ $i = $max ]; then ??o=$(($o+1)) ??i=0; ?fi; ? ?convert $picname -resize $(($xres - $i))x$(($yres - $o))! $renmask$count ?convert $picname -resize $(($xres + $i))x$(($yres + $o))! $renmask$count2 ? ?i=$(($i+1)) ?count=$(($count+1)); ?count2=$(($count2+1)); done #Creates new images that are different by up to $max in the x and y, naming them with their iteration number and mask. } echo "This script will make very similar images, it will do so by re-sizing the original by pixels at a time, then re-sizing them back to the original dimensions. This relies on the data lost / created in the initial re-sizes. This will create MANY new images, so you may want to run it in a new directory (folder)." echo "" echo "Name of the picture, extension included" read picname echo "Alright, now the max number of pixels to shrink / expand by" read max echo "Now the X resolution" read xres echo "Now the Y resolution" read yres echo "Now the renaming mask, so I don't overwrite other pictures you may have etc.. make sure it's unique in this directory." read renmask echo "This could take some time to finish..." reSize $max $xres $yres $picname $renmask echo "" echo "Should be done making the new images.. Just have to re-size them..." echo "" echo "" echo "If you made over 400 images, this could get messy, as 'convert' buffers, meaning it will chew up a bunch of system memory. If you don't have enough memory, your computer may slow, or just eat it.." echo "" echo "This will re-size (making a copy of) every image in the directory who's name begins with your chosen re-naming mask, then delete all the old ones with said mask." echo "" echo "Are you sure you want to continue? y / n" read ans if [ "$ans" = "y" ]; then ?reSizeAll $xres $yres $renmask ? elif [ "$ans" = "n" ]; then ?echo "exiting.." ?exit else ?echo "invalid option, should be either 'y' or 'n', exiting.." ?exit fi; echo "All done.." exit