Image Manipulation Using Irfanview
IrfanView (pronounced Ear-Fan-View) is a freeware program (for non-commercial use) developed by Irfan Skiljan, a Bosnian developer presently residing in Austria. ‘Simple enough for beginners and powerful enough for professionals,’ this program supports tasks and formats that not even many commercially available image viewers can.1 If you’d like to download or simply learn more about this program, visit www.irfanview.com. That said, IrfanView is deployed across campus for the purpose of viewing, manipulating and optimizing images and other media.
Using the Interface
Perhaps one of the best features about this program is its deceptive simplicity. Unlike other image viewers that overload the beginner with controls and effects, IrfanView instead assumes its users have a familiarity with other Windows-based programs and tries to match that skill set without sacrificing functionality. Take a look at the interface featured below:
- Title bar: Includes the title on the viewed image and the zoom factor (if any) in parentheses.
- Menu bar: Here you’ll find all functions and tasks available specifically to the program. Pop through these to get a sense of where to find what you will need.
- Toolbar: Hover you mouse over each in turn to get information on the purpose of the button. A few of special interest: Image Information: Useful when you are interested in the properties and meta-data of any given file. Zoom Tool: Use these to zoom in and out from the image. Your level of zoom will be indicated in pixels in the title bar. Alternately use Ctrl + Mouse WheelNavigation Tool: Use to navigate from one image to the next in a directory. The neighboring up and down arrows serve a similar function with multi-page images such as TIFF files. Alternately use your left and right arrow keys.
- Status bar: Shown above, the status bar is a common and often ignored component of most Windows-based applications. Here it is useful to get an idea of what type of image your are working with before manipulating it:
Resolution (3504 x 2336 x 24 BPP): This means the image is optimally displayed at 3504 pixels in width, 2336 pixels in height at 24 bits per pixel (8 bits x 3 color channels) This is about the size and pixel depth of a standard computer monitor.
Image Index (5/6): Image 5 of 6 in your working directory.
Zoom (17%): Image is presently 17% of its optimal size.
Disk Size to Memory (6.53 MB/23.42 MB): This indicator helps to explain compression. What we see here is that the image has a size of about 6.5 megabytes on the disk but is taking up about 23.5 megabytes in machine memory to display. The difference is due to the compression method used.
Time & Date (3/11/2009 09:40:09): This tells us when the image was last modified, not when it was taken.
Cropping, shown right, is the process of discarding the area outside of an given rectangular portion of an image while keeping the resolution of the original.
- Holding down your left mouse button, draw a rectangle around the portion of the image that you want to keep. Release when satisfied.
- You may need to redraw the rectangle or resize the edges of the selection using the double-ended arrow mouse cursors (↔) if you are not satisfied with the results. You can also hold down the right-click on your mouse to drag the cropping box around.
- Edit → Crop Selection or simply use the keyboard shortcut Ctrl + Y
If you are still not satisfied, do not despair. You can Undo any action by using the Undo button in the toolbar (alternately Edit → Undo or Ctrl + Z) or simply Reopen the image: File → Reopen.2
Orientation (Flip and Rotate)
When scanning images or working with photos taken in in portrait orientation, it is sometimes necessary to rotate the image before inserting it into your work. Similarly, you might have reason to invert or otherwise flip an image horizontally or vertically.3
- Open the image you’d like to re-orient
- Image → Rotate Right (Note the other options)
This essentially moves the image 90° clockwise. Similarly, flipping essentially turns the image over horizontally (mirror-effect) or vertically (inversion).
Remove Imperfections with Cloning
Nothing worse than taking a great photo and having a piece of trash or blemish ruining the whole thing. With IrfanPaint, a new plugin for Irfanview, you have access to some Photoshop-esque tools. For our interests, the so called clone tool [ ] allows you to arbitrarily copy one portion of a photo over another portion. The usefulness of this is obvious by demonstration:
- Bring up IrfanPaint by pressing F12 or Edit → Show Paint dialog
- Select the clone tool [ ]
- Right-click over the area that you wish to clone from
- Left-click and drag over the area that you want to copy to
Applying Image Effects
IrfanView offers a variety of effects that can be used to manipulate the appearance of your images. While detailing each would outstrip the scope of this help sheet, I’ve taken some liberty in listing some of those your likely to have use for:
- Increase/Decrease Color Depth: IrfanView has the ability to adjust your color depth (See more about color depth below in Concepts & Topics). Now why would you want to do this? At times it is useful for aesthetic reasons such as decreasing a figure to 2 colors (ie. B/W) to achieve a silhouette.
- Convert to Grayscale: I know what your thinking, but this is NOT black and white. For all intents and purposes, this is a color mode in that it contains just as much color depth information, only the information is nominalized into shades of gray.
- Enhance Colors: There are several options here but you’re most likely to use the Gamma Correction option. When you think of correcting gamma, imagine your adjusting the amount of sunshine in your picture. This is useful for pictures that are just a little bit too bright or dark.
- Redeye Reduction(selection): Select the area around the eye with you mouse and use this utility to suck the red right out. 4
You’ll find several other effects under Effects including what is called the Effects Browser (Image → Effects → Effects browser …). This handy tool (shown above) allows you to preview the results of an effect before applying it to your image.
Some images displayed at their optimal dimensions are too big for your purposes. For example, an image that is 1024 pixels in length and 768 pixels in height is approximately the size of a standard computer screen. To use it in a word processing document, you will want to resize the image to something more suited to your purposes. Otherwise, when you come to print the paper, it will take an excruciating amount of time to render.
- Click Image → Resize/Resample.
- In the resulting dialog box, insure that the Preserve aspect ratio option is selected. If not, your image will be distorted or otherwise stretched.
- Unless you know the exact dimensions you’d like, use the Set size as percentage of original option for a more intuitive resizing.
- Keep an eye on the New Size in the upper left of the dialog box as you make your changes
- Click OK.
If you are not satisfied with the resize for whatever reason, click Edit → Undo.
Often when working with images you’ll find that the image is far too big to utilize effectively in your work. By ‘too big’ I do not mean just length and height but rather that it takes up too much space on your disk. This is when you’ll start hearing terms such as optimization and conversion thrown about by lab consultants (as if you’re supposed to know what these mean!) For more information on these and many other terms, see Concepts and Topics below. Till then, here’s what to do:
- First be certain you have your image looking the way you want it to appear in your work. The best image quality is achieved when optimization and/or conversion is the last process performed on the image before it is inserted into your work.
- File → Save as…
- Select which compression method you’d like from the Save as type pop-down menu. We’ll be using the JPEG format. If you are changing file types; for example, the original was an uncompressed Bitmap (BMP) and you want the more manageable JPEG format, this process is known as conversion.
- Click the Options button. This will open the tabbed dialog shown to the right. Your interest here is the JPEG Save Quality. The higher the quality, the larger the file and visa versa. JPEG’s are already fairly well compressed so we’ll leave it at its default of 77. Be certain the other JPEG options are as shown unless you prefer otherwise. Ignore the other tabs in that they will not factor into this compression type. When finished, click OK.
- Back at the Save as dialog, check that your file name and location are as you’d like and click Save. When working with images, it is usually best NOT to overwrite your originals… Just in case, always save with a different file name.
Concepts and Topics
It is all well and good to have the procedural knowledge detailed above, but it is critical if you are going to spend anytime around technology in your career to develop a competence in its terminology and concepts. What follows should help serve that end:
Data compression and its mysterious cousin, encryption are considered high art among information theorists and other mathematicians, however, for our purposes we can simply say that compression is the process of making a file smaller by predicting its most frequent information and storing it in less space. Using the figure shown right as an example, I’ve developed an algorithm that replaces common character sequences with a unique placeholder (here I used numbers). Applying this compressor I have effectively shrunk the file by approximately 28%.
As you might imagine, if I want to read this file after it has been compressed, I’m going to need the compressor to reverse the process. It is for this reason that all compressed images include information on its compressor, typically in the form of a file extension. (*.gif, *.jpg, *.png …)
A compressor can be lossy or lossless. With a lossless compressor the original and decompressed files are identical bit per bit. With some data we can have big benefits in compression efficiency by throwing away most of it, without however losing much quality. We use lossless compression for text or binary data, and lossy for data like signals: audio, image or video.
Images come in a variety of formats each with their own advatages and disadvantages. Each of these are easily identified with a file extension such as mypicture.jpg that tells your operating system what format it is in and therefore, how to open it properly. Listed here are some of the more widely known formats in a variety of categories:
BMP:(Bitmap) | Uncompressed Editing Format
BMPs, Windows’ bitmap format, like other bitmaps are formed from pixels-a matrix of dots with different colors. Bitmap images are defined by their dimension in pixels as well as by the number of colors they represent. For example, a 640 x 480 image contains 640 pixels and 480 pixels in horizontal and vertical direction respectively. If you enlarge a small area of a bit-mapped image, you can clearly see the pixels that are used to create it. When viewed normally, the small pixels merge into continuous tones much as do the dots used to create newspaper photographs. Each of the small pixels can be a shade of gray or a color (see right). Using 24-bit color, each pixel can be set to any one of 16 million colors. All digital photographs and paintings are bitmapped, and any other kind of image can be saved or exported into a bitmap format. In fact, when you print any kind of image on a laser or ink-jet printer, it is first converted (rasterized) by either the computer or printer into a bitmap form so it can be printed with the dots the printer uses. To edit or modify these bitmapped images you use a program such as IrfanView or Microsoft’s Paint. Bitmap images are widely used but they suffer from a few unavoidable problems.
- They must be printed or displayed at a size determined by the number of pixels in the image. Printing or displaying one at any other size can create unwanted patterns in the image.
- Bitmap images also have large file sizes that are determined by the image’s dimensions in pixels and its color depth.
JPEG: jay-peg (Joint Photographic Experts Group) | Digital Camera Format
By far the most popular format for displaying of photographic images on the Web. The format is optimized for the display of photographs and doesn’t work as well as GIF for type or line drawings. JPEG images have two distinctive features:
- You can vary the amount of compression and hence trade off file size for image quality.
- JPEG supports 24-bit color. GIF, the other format widely used on the Web supports only 8-bits.
NOTE: Don’t use JPEG to save original images you expect to modify later. Every time you open one of these files, and then save it again, the image is compressed. As you go through a series of saves, the image become more and more degraded. Be sure your originals are in a loss-free format such as TIFF or BMP at maximum color depth. Also, when you save an image as a JPEG, the image on the screen won’t reflect the compression unless you load the saved version.
GIF: jif or gif (Graphics Interchange Format) | Web Format
Developed in 1987 by CompuServe to store multiple images into one file, GIF’s are the oldest graphic format on the Web. Unlike JPEG’s which can store 24-bit color, GIF can manage only 8-bits (256 colors) making them well suited for graphs and line art but not for photos and the like. Examine the gradients shown right. At relative file sizes you can easily see GIF’s inability to appropriately render the gradient. So why, you may ask, is GIF still around?
- File Size: When representing line art, graphs, text and the like, GIFs can achieve optimal quality at a smaller file size than JPEGs
- Transparency: Image backgrounds can be made transparent. To do so, you specify which color in the table is to be transparent. When viewed with a Web browser, the browser replaces every pixel in the image that is this color with a pixel from the web page’s background. This allows the background to show through the image in those areas. You have to choose the transparent color carefully. If you select one that occurs anywhere in the image besides the background, your image will appear to have “holes” in it.
- Animation: Since GIFs can store multiple images in one file, an images can be animated by rapidly flipping through a series of images much as a movie simulates motion.
Optimal Image Resolution & Dimensions
The optimal resolution of an image is based on three factors: Image Resolution, Color Depth, and its Optimal Dimension. What is best or optimal for your purposes will vary with your intended means of display: print or computer monitor. This again is further limited by the quality of these devices.
- Image Resolution: the density of pixels per inch (ppi). Although there is variation between monitors, the rule of thumb is that screen resolution is 72 ppi. This means that all images used for the Web should have an image resolution of 72 ppi. Why not use higher resolution? More pixels per inch means a higher quality image, right? Well, only if your are displaying your images on something that can show all those extra pixels. On the Web, your reader’s monitor is the limiting factor. You could send more pixels to display, but they’d just be ignored. If, however, you intend to print the image, rather than display it on a Web page, printers typically produce from 300 to 600 dots per inch, or dpi. (Dots and pixels are the same concept, different terms.)
- Color Depth: the number of bits of data used to store information about the color of each pixel in an image. This is also known as bit depth or color resolution. The higher the color depth, the greater range of possible colors in the image, and the larger the file size. (Typical bit depths are 8-bit, 16-bit, or 32-bit, although others are possible.
- Optimal Dimensions: the length and height measured in pixels. An image displayed optimally on your monitor will have a 1:1 pixel ratio. That is, one image pixel for one screen pixel. If you were then to enlarge the picture beyond optimal, each image pixel will then need to span two or more monitor pixels. In a similar manner, shrinking an image below optimal will require some pixels to be ignored, causing distortions or sacrificing quality.
Q: I’m trying to open an image I got from a friend (or that I can view from home) but Windows keeps telling me it can’t read the format.
A: This could be do to a variety of things. One of the most common is that the image was created in a Macintosh machine and does not have a file extension to tell a Window’s machine what format it is in. Macintosh OS 9.x historically stored that information in what is called a data fork. Solution, find out what format it is in and append the proper extension. Sometimes you just have to guess and see what works.
Q: What’s the deal with only being able to undo ONE action? I constantly have to start over if I don’t catch a mistake immediately.
A: I know. I don’t care much for this limitation either, but since IrfanView is not intended for large scale image manipulation (not to mention it being free) I can’t complain too much. All I can recommend is to work carefully.
Q: I’d like to be able to browse through thumbnails of my images. Other image viewers can do this. Can IrfanView?
A: Certainly. Either press t on your keyboard with IrfanView as the active window or File → Thumbnails. This will open a thumbnail browser excellently suited for getting a birds eye view of your images.
- See Wikipedia’s Comparison of image viewers for more details on what and what is not offered in other image viewers. [↩]
- One of Irfanview’s more irritating limitations is the inability to undo more than one action. [↩]
- NOTE: When rotating JPEG images, it is better to use the JPG Lossless Rotation plugin utility (Options → JPG Lossless Rotation). This will preserve a greater degree of the JPEG’s quality. [↩]
- As if this writing, this is one of the worst features of the program. The results are simply not as good as what you’d get with Google’s Picasa or Apple’s iPhoto [↩]
Trackback from your site.