Breadfan
04-28-2008, 10:45 PM
(Note, image example links at bottom)
For anyone who takes a lot of digital images and wants to pass them along to folks, batch processing is a way to automate tasks that could become extremely tedious when applied to several images.
Take for instance, compressing a JPEG file. If your camera saves images in JPEG format (or higher end/dslr in RAW format) the size of the image may be very big. This is good - you get the BEST quality. That can be handy when working with the image for things such as blowing it up, printing large format, etc.
But, say you want to store them online - well, 1,000 3mb images = 3gb. Over time, your images can take up some space. While it may not matter locally thanks to large hard drives and DVD backup media, storing them online or emailing large amounts of photos, you will reach some online limitations faster.
So, compressing and resizing images are two VERY common operations done to the images that come directly off a camera, prior to sharing.
I like to do both. (I've actually switched to only compress, then upload to a Coppermine image gallery that auto-processes resizes based on parameters I previously inputted on the server side...but that's another story...)
So if you take 200 images, and want to compress them, you may use something like the GIMP (http://www.gimp.org/) (a great open source image editor) that can resize a digital photo.
So you'd:
1.) Open image
2.) Save image as .jpg
3.) Set .jpg quality
4.) Save
That's four steps. Do it 200 times, and it's 800 steps. At least 800 mouse clicks - OUCH!
How about resising?
1.) Open image
2.) Set image size parameters and apply
3.) Save as (Rename to save original high res version)
4.) Set .jpg quality
5.) Save
That's 1,000 clicks!
Batch processing would allow you to setup a single operation, and let the batch process apply that to all image you wish.
Batch processing can be VERY VERY powerful, or, relatively simple.
These examples are relatively simple but very time-saving operations.
First, you'll need an image editor that supports Batch processing. Many high end image editors support batch processing, some are done by recording a "Macro", i.e. doing the operation while "Recording" the steps, then playing it back automatically.
The GIMP has a script editor called script-fu, but it can be confusing to use.
A program I like to use, is called "ImageMagick" and is certainly an odd beast being a "command" line image editor - that's right, you can create and edit images fully by text commands! ImageMagick support batch, gives high quality images in it's output, AND it's free!
Now, I know command line can sound scary, but I don't think you'll have a problem with these simple operations.
First, download and install ImageMagick (http://www.imagemagick.org/script/index.php):
Most users will want to install from a binary. Cool folks and other Linux/Unix/BSD users may choose to install from source. Let's not get into that, let's just install Windows version via Binary.
http://www.imagemagick.org/script/binary-releases.php#windows
Per the text, 99% of you will want this release: ImageMagick-6.4.0-11-Q16-windows-dll.exe
(Note: version # may change over time, but this is for the dynamic Windows 16bit per pixel)
Get it - install it.
The cool thing about image magick is that it will integrate commands into your user environment. So........image magick commands will work from Windows command line (or .bat files if you wanted to)!
So let's keep it simple for now.
We will assume:
1.) You are "converting" images meaning the ORIGINALS will be saved and NEW VERSIONS will be created with each command.
2.) Operations are to be run on an ENTIRE directory. Place ONLY the images you wish to convert in this directory. (HINT: I like to use a "temp" directory, for instance, create a dir on root (C:\) called "IMTEMP", use it to stage and process files, and move them to their permanent homes when processing is done.)
3.) We'll do two separate operations to compress and resize
Compressing Images
To create compressed versions of images using ImageMagick, move all the originals you wish to make compressed versions of into your temp directory (C:\IMTEMP if you followed my lead)
Open your command line tool, in Windows click Start, then Run... and type "cmd" You will be presented with a command line sitting the your home directory. Follow the commands, first step you will change to the C:\IMTEMP dir
\[Homedir]\> cd \IMTEMP
Next, we run the convert command, set to compress the images. What we are doing here, is "converting" the images using the convert command, tell it which images to do (all images in the dir) what quality level to save them as (90% is a good benchmark) and finally the new file name schema (ImageMagic will automatically add numbering to the end of the file name)
C:\IMTEMP> convert *.jpg -quality 90% sample_image.jpgRunning this command will convert all images to the new file name, saving them at 90% quality, which is about half the original file size. (Due to how jpg compression works)
When you hit enter, depending on the amount of files you have to process, you will not see the command prompt reappear until the operation is done. (Your command shell window will remain open, but the prompt will not be available until the operation is done)
TIPS:
1.) You can see the convert process in Task Manager. Go to task manager, processes tab, and find "convert". I have noticed it does use a fair amount of memory if you process alot of images.
2.) If you want to background process alot of images with minimal slowdown to the rest of you work, right click the "convert" image name, go to "Set Priority" and set it to "Low". This will make it a low prioirty process that will slow down before higher priority tasks you may be running, such as your net browser, DVD player, etc.
When done the command prompt will reappear.
So, in your temp dir, if you started with IMG_1.jpg and IMG_2.jpg you will now see four files:
IMG_1.jpg
IMG_2.jpg
sample_image-1.jpg (compressed image)
sample_image-2.jpg (compressed image)
So there you have it, you batch compressed using open source software, and yes, the image quality you will get will be very good!
Resizing
Another common batch is resizing. Emailing a 3000 pixel wide image may make it hard to view for the receiver. (Most monitors are only 1024 pixels to 1920 pixes wide depending on size and pixel density). Same goes for putting them on websites, smaller images will usually fit better. Yes, it is true that modern browsers support scaling of images (Automatic Image Resizing) but these are very crude tools and make big images look pretty bad when scaled down.
My favorite image width is 780 pixels. It just seems to work for 95% of monitors, yet still be pretty big even on high resolution displays. (Anyway, if you REALLY want to send or post that high res version, you have that niced compressed yet full pixel-size vresion we created above!)
So, again, let's use our temp directory. Clean it out - otherwise you'll resize all four images in there now, the originals AND the compressed ones. That's redundant, as resizing will save compressed anyway!
Move any images in the directory that were created during the past processing. Keep or replace the original versions you wish to resize. Again, use the originals off the camera for best quality...
The hard part of this will be getting the pixels you want to resize. For the same resolution, you only have to get this ONCE and then just tuck it away somewhere, i.e a sticky note, notepad note, etc! Use your normal resize technique like GIMP to resize the image keeping the scaling constraints.
So...my D40's images come off the camera at 3008x2000
When I resize to 780 pixel width, I get 518 height keeping the image ratio (H vs W) the same. Your image editor such as GIMP will tell you this.
So, I will use 780x518 to get my pics looking right at 780 pixel width.
Open your command line, go to your temp directory, and run this command:
C:\IMTEMP\> convert -resize 780x518 *.jpg -quality 90% sample_image_rs.jpgWhat you'll end up with in your dir would be...
IMG_1.jpg
IMG_2.jpg
sample_image_rs-1.jpg
sample_image_rs-2.jpg
TIP: You can name your resultant images whatever you'd like. You can make it descriptive, or match the camera's naming convention. I like to use "rs" simply to denote a resized version.
The two "rs" images in the directory, if you open them, will be 780x518 in dimension, and were saved at 90% jpg quality. They will look nice too!
So there you have it, batch processing compress and resize for everyone!
So you like that and want to do more with ImageMagick???
Have at it!: http://www.imagemagick.org/Usage/
Example...original, compressed, and resized. Click the filename to view/compare the quality and pixel size of each image.
Original image from Nikon D40 (ISO 800) - File Size: 2,731kb, Dimensions 3008x2000 pixels
DSC_0600.JPG (http://www.ionicflux.com/gallery/albums/userpics/10002/DSC_0060.JPG)
ImageMagick Batch Compressed to 90 - File Size: 1,244kb, Dimensions 3008x2000 pixels
sample_image-0.jpg (http://www.ionicflux.com/gallery/albums/userpics/10002/sample_image-0.jpg)
ImageMagick Batch Resize (and compressed to 90) - File Size: 183kb, Dimensions 799x518 pixels
sample_image_rs-0.jpg (http://www.ionicflux.com/gallery/albums/userpics/10002/sample_image_rs-0.jpg)
For anyone who takes a lot of digital images and wants to pass them along to folks, batch processing is a way to automate tasks that could become extremely tedious when applied to several images.
Take for instance, compressing a JPEG file. If your camera saves images in JPEG format (or higher end/dslr in RAW format) the size of the image may be very big. This is good - you get the BEST quality. That can be handy when working with the image for things such as blowing it up, printing large format, etc.
But, say you want to store them online - well, 1,000 3mb images = 3gb. Over time, your images can take up some space. While it may not matter locally thanks to large hard drives and DVD backup media, storing them online or emailing large amounts of photos, you will reach some online limitations faster.
So, compressing and resizing images are two VERY common operations done to the images that come directly off a camera, prior to sharing.
I like to do both. (I've actually switched to only compress, then upload to a Coppermine image gallery that auto-processes resizes based on parameters I previously inputted on the server side...but that's another story...)
So if you take 200 images, and want to compress them, you may use something like the GIMP (http://www.gimp.org/) (a great open source image editor) that can resize a digital photo.
So you'd:
1.) Open image
2.) Save image as .jpg
3.) Set .jpg quality
4.) Save
That's four steps. Do it 200 times, and it's 800 steps. At least 800 mouse clicks - OUCH!
How about resising?
1.) Open image
2.) Set image size parameters and apply
3.) Save as (Rename to save original high res version)
4.) Set .jpg quality
5.) Save
That's 1,000 clicks!
Batch processing would allow you to setup a single operation, and let the batch process apply that to all image you wish.
Batch processing can be VERY VERY powerful, or, relatively simple.
These examples are relatively simple but very time-saving operations.
First, you'll need an image editor that supports Batch processing. Many high end image editors support batch processing, some are done by recording a "Macro", i.e. doing the operation while "Recording" the steps, then playing it back automatically.
The GIMP has a script editor called script-fu, but it can be confusing to use.
A program I like to use, is called "ImageMagick" and is certainly an odd beast being a "command" line image editor - that's right, you can create and edit images fully by text commands! ImageMagick support batch, gives high quality images in it's output, AND it's free!
Now, I know command line can sound scary, but I don't think you'll have a problem with these simple operations.
First, download and install ImageMagick (http://www.imagemagick.org/script/index.php):
Most users will want to install from a binary. Cool folks and other Linux/Unix/BSD users may choose to install from source. Let's not get into that, let's just install Windows version via Binary.
http://www.imagemagick.org/script/binary-releases.php#windows
Per the text, 99% of you will want this release: ImageMagick-6.4.0-11-Q16-windows-dll.exe
(Note: version # may change over time, but this is for the dynamic Windows 16bit per pixel)
Get it - install it.
The cool thing about image magick is that it will integrate commands into your user environment. So........image magick commands will work from Windows command line (or .bat files if you wanted to)!
So let's keep it simple for now.
We will assume:
1.) You are "converting" images meaning the ORIGINALS will be saved and NEW VERSIONS will be created with each command.
2.) Operations are to be run on an ENTIRE directory. Place ONLY the images you wish to convert in this directory. (HINT: I like to use a "temp" directory, for instance, create a dir on root (C:\) called "IMTEMP", use it to stage and process files, and move them to their permanent homes when processing is done.)
3.) We'll do two separate operations to compress and resize
Compressing Images
To create compressed versions of images using ImageMagick, move all the originals you wish to make compressed versions of into your temp directory (C:\IMTEMP if you followed my lead)
Open your command line tool, in Windows click Start, then Run... and type "cmd" You will be presented with a command line sitting the your home directory. Follow the commands, first step you will change to the C:\IMTEMP dir
\[Homedir]\> cd \IMTEMP
Next, we run the convert command, set to compress the images. What we are doing here, is "converting" the images using the convert command, tell it which images to do (all images in the dir) what quality level to save them as (90% is a good benchmark) and finally the new file name schema (ImageMagic will automatically add numbering to the end of the file name)
C:\IMTEMP> convert *.jpg -quality 90% sample_image.jpgRunning this command will convert all images to the new file name, saving them at 90% quality, which is about half the original file size. (Due to how jpg compression works)
When you hit enter, depending on the amount of files you have to process, you will not see the command prompt reappear until the operation is done. (Your command shell window will remain open, but the prompt will not be available until the operation is done)
TIPS:
1.) You can see the convert process in Task Manager. Go to task manager, processes tab, and find "convert". I have noticed it does use a fair amount of memory if you process alot of images.
2.) If you want to background process alot of images with minimal slowdown to the rest of you work, right click the "convert" image name, go to "Set Priority" and set it to "Low". This will make it a low prioirty process that will slow down before higher priority tasks you may be running, such as your net browser, DVD player, etc.
When done the command prompt will reappear.
So, in your temp dir, if you started with IMG_1.jpg and IMG_2.jpg you will now see four files:
IMG_1.jpg
IMG_2.jpg
sample_image-1.jpg (compressed image)
sample_image-2.jpg (compressed image)
So there you have it, you batch compressed using open source software, and yes, the image quality you will get will be very good!
Resizing
Another common batch is resizing. Emailing a 3000 pixel wide image may make it hard to view for the receiver. (Most monitors are only 1024 pixels to 1920 pixes wide depending on size and pixel density). Same goes for putting them on websites, smaller images will usually fit better. Yes, it is true that modern browsers support scaling of images (Automatic Image Resizing) but these are very crude tools and make big images look pretty bad when scaled down.
My favorite image width is 780 pixels. It just seems to work for 95% of monitors, yet still be pretty big even on high resolution displays. (Anyway, if you REALLY want to send or post that high res version, you have that niced compressed yet full pixel-size vresion we created above!)
So, again, let's use our temp directory. Clean it out - otherwise you'll resize all four images in there now, the originals AND the compressed ones. That's redundant, as resizing will save compressed anyway!
Move any images in the directory that were created during the past processing. Keep or replace the original versions you wish to resize. Again, use the originals off the camera for best quality...
The hard part of this will be getting the pixels you want to resize. For the same resolution, you only have to get this ONCE and then just tuck it away somewhere, i.e a sticky note, notepad note, etc! Use your normal resize technique like GIMP to resize the image keeping the scaling constraints.
So...my D40's images come off the camera at 3008x2000
When I resize to 780 pixel width, I get 518 height keeping the image ratio (H vs W) the same. Your image editor such as GIMP will tell you this.
So, I will use 780x518 to get my pics looking right at 780 pixel width.
Open your command line, go to your temp directory, and run this command:
C:\IMTEMP\> convert -resize 780x518 *.jpg -quality 90% sample_image_rs.jpgWhat you'll end up with in your dir would be...
IMG_1.jpg
IMG_2.jpg
sample_image_rs-1.jpg
sample_image_rs-2.jpg
TIP: You can name your resultant images whatever you'd like. You can make it descriptive, or match the camera's naming convention. I like to use "rs" simply to denote a resized version.
The two "rs" images in the directory, if you open them, will be 780x518 in dimension, and were saved at 90% jpg quality. They will look nice too!
So there you have it, batch processing compress and resize for everyone!
So you like that and want to do more with ImageMagick???
Have at it!: http://www.imagemagick.org/Usage/
Example...original, compressed, and resized. Click the filename to view/compare the quality and pixel size of each image.
Original image from Nikon D40 (ISO 800) - File Size: 2,731kb, Dimensions 3008x2000 pixels
DSC_0600.JPG (http://www.ionicflux.com/gallery/albums/userpics/10002/DSC_0060.JPG)
ImageMagick Batch Compressed to 90 - File Size: 1,244kb, Dimensions 3008x2000 pixels
sample_image-0.jpg (http://www.ionicflux.com/gallery/albums/userpics/10002/sample_image-0.jpg)
ImageMagick Batch Resize (and compressed to 90) - File Size: 183kb, Dimensions 799x518 pixels
sample_image_rs-0.jpg (http://www.ionicflux.com/gallery/albums/userpics/10002/sample_image_rs-0.jpg)