In a previous post (Restraint, Lack of) I remarked that I make my digital collage files as large as I practically can because "an unresampled reduction of a large file always gives far better results than a resampled enlargement of a small one"; an uncontroversial observation, but it seems that even fairly experienced users of image-editing software find it hard to understand whether or not to "resample" a file when resizing it. So, here, for what it's worth, is my attempt at an Idiot's Guide to resizing. Not interested? Only ever look at your photos on a phone screen? You're excused this class.
What follows may be confusing. The trouble, where digital imaging is concerned, is that it's a case of metaphors all the way down: until and unless you print the damned thing, there is no actual "picture", just various analogue interpretations of some digital data held in your camera, computer, or phone. We're in the perplexing world where analogue meets digital. Where, for example, on an RGB device like a computer screen "white" is also "255255255" (i.e. red, green, and blue all at the maximum value of 255), and "black" is "000000000" (i.e. red, green, and blue all at the minimum value 000), with nearly 17 million other nameless but precise colours in between.
However, a technical understanding is not needed to grasp the basics. No-one really needs to get into pixel binning, demosaicing, Bayer filters, and all that, just in order to edit an image. So, let's be bold and over-simplify some essential concepts: for a start, let's say that a digital camera captures a real-world image by turning it into a two-dimensional grid of identically-sized square dots (pixels), each filled with just one of those 17 million nameless colours.
Megapixels vs. Megabytes: The size of the image captured by a digital camera or phone is expressed in "megapixels" (MP) i.e. millions of pixels, which is simply the result of multiplying the length in pixels of one side of the grid with the length in pixels of the other side. For example, an "eight MP" iPhone image has dimensions 2448 px by 3264 px: so (2448 x 3264) = 7,990,272, which is close enough to eight million for jazz. However, 8 MP is is not a measure of the size of the resulting digital image file, which is measured in bytes (kilobytes, megabytes, or even gigabytes) just like any other digital file. Some confusion arises, I suspect, from the use of the word "size" to refer to both the image's dimensions and the size of the file containing it.
File types: If no processing is applied to the image data "in camera" (stuff like sharpening, contrast, white balance, etc.) then all the original data captured by the camera can be saved as what is known as a "raw" file. However, although raw files have advantages for the advanced user, they first have to be be re-interpreted by a raw-file converter into a standard file type like TIFF or JPEG before they can be used in any image-editing software, and this is a step too far for most camera users [1]. Most users prefer to use files which have been pre-processed in the camera by its inbuilt algorithms to some standard notion of optimum attractiveness and saved in the standard and widely-used JPEG format (most phones only offer this option, anyway).
It's important to know, however, that there are so-called "lossless" file types and "lossy" file types. That is, there are file types which keep all the image data when an edit is made, and types which throw data away. A TIFF file is an example of the former, and the ubiquitous JPEG of the latter. The maximum quality and flexibility is achieved by using lossless files, but because they preserve all the image data they are relatively large. The process of discarding image data is known as "compression", but more often referred to as "quality" within editing software. A maximum quality JPEG (i.e. one with the least compression) is an excellent image file, and a good starting point, but the more compression that is applied in order to make the saved JPEG file smaller – which is convenient – then the lower the final image quality, because more and more image data gets thrown away with each step down the quality / compression ladder. The thing to realise is that these lost data cannot be recovered: "compression" is a misleading term, with its implication that the image might be able to bounce back to its original full quality.
So, let us now – finally! – discuss image resizing and resampling.
Let's assume you've transferred your image files onto a computer, and are using some image-editing software (I use Photoshop Elements 10, nothing fancy). Let's also assume you know how to open your resizing dialogue, and have noticed that there is a setting (usually a tickbox) labelled "resample". There are essentially four inter-related quantities that come into play when resizing: the image resolution (the number of pixels per inch); the image's linear dimensions measured in inches or centimeters; its linear dimensions measured in pixels; and the file size in bytes [2]. All of these will normally be visible in a resizing dialogue. So:
If you resize an image without resampling, you are saying, in effect, "give me that exact same grid of pixels, but with its outer dimensions changed to this new size". No changes will be made to the pixels, as such, just to the size of the grid containing them. If you make the grid smaller, the pixels shrink to fit (the resolution, measured as "pixels per inch", goes up, as there are now more pixels per inch); if you make it bigger, the pixels expand (the resolution goes down, as there are now fewer pixels per inch). In a non-resampled resized file all the pixels remain exactly the same – they're just coloured squares – and simply shrink or expand to fit the new grid dimensions. The converse is also true: if you resize by changing the resolution, there will be a resulting proportional change in the linear dimensions.
But, in a non-resampled resize, although the resolution and the linear size in inches/cm are linked together proportionally – as one goes up, the other goes down – the file's size in bytes and its pixel count are constant. No change has been made to the actual grid of pixels, no image data has been lost or added, and so the file's size in bytes remains exactly the same.
If you resize by resampling, on the other hand, you are saying, in effect, "resize the grid dimensions for this image, and also recreate all the pixels to fit the new grid at the specified resolution". To achieve this, the image is completely reinterpreted by the image-editing software, and a whole new grid of pixels is created.
In a resampled resize the resolution, the dimensions measured in inches, and the dimensions in pixels can all be changed, separately or in combination. For example, if you enter a new image width in inches, the file will be recreated at the existing resolution unless you also specify a new resolution value; similarly, if you enter a new resolution, the file will be recreated at the existing width in inches unless you also specify a new width. And, because the grid of pixels will have been reinterpreted and fully recreated by the software to fit the new grid at the required resolution, there will always be a change in the pixel count and the file's size in bytes.
Resampling a file also means that, once it has been saved, irreversible changes will have been made to the image, changes which may also have an effect on the image quality, especially if a "lossy" filetype like JPEG is used. If an image is made smaller and/or not compressed too much it will look fine, but if it's enlarged too much and/or over-compressed it will almost certainly look bad – unsharp, pixelated, and full of "artefacts" – because the image editor is working with maths and little coloured squares, not the original real world image.
So when would one choose to use which of the two methods of resizing?
Most often, resizing by resampling is done in order to reduce the dimensions of the image, the size in bytes of the image file, and/or its resolution. As an example, let's take a photo from my iPhone 12 mini. It produces a 12 megapixel image, with dimensions 3024 px by 4032 px, at a resolution of 72 pixels per inch (ppi).
Now, 72 ppi is the traditional resolution for images to be viewed on a screen but, without resizing, the length of this image is (4032 / 72) = 56 inches, which is impractically huge for viewing on a screen [3]. So, if I wanted to use it in a webpage, for example, I'd need to resize it radically; let's say to 8.5 inches long at 96 ppi (a more suitable screen resolution for modern devices). In that case, I would resize it by resampling: I'd tick the "resample" box in the resizing dialogue [4], set the resolution to 96 ppi, and the long edge length to 8.5 inches. The pixels would then be reinterpreted to fit into a new, smaller grid of 612 x 816 pixels, resulting in a much smaller file, one which is not only just the right size for the webpage, but will also be a lot quicker to load online.
In other words, the picture was re-interpreted by the image editor so that those 12 million-ish pixels became a mere 499,392 pixels, which nonetheless still represent the same image adequately at the new dimensions and resolution required. The actual new size of the file in bytes and the quality of the picture will depend on the level of compression I choose, assuming I save it as a JPEG (the file type mainly used in webpages). But even at the highest quality it will have become a much smaller file.
On the other hand, let's say I want to print it. Generally speaking, you wouldn't resample a file for printing purposes. For good-quality printing, 300 or 360 ppi are the gold standard, but anything over that is fine: you don't need to resample a large image down to 300 ppi when resizing in order to print it. This example iPhone file has sufficient pixels to print well at a decent size at 300 ppi: (4032 / 300) = 13.44 inches. So if, let's say, I wanted to print it 9 inches wide, I would do a non-resampled resize: untick the "resample" box, set the width at 9 inches, and let the resolution change in proportion to 448 ppi. [5]
Making an image larger either with or without resampling is more problematic, and is where case-by-case judgement comes into play, especially for printing purposes. It's a subject in its own right, and I won't discuss it here. You can get specialised "up-ressing" software that uses all sorts of cunning AI ploys to achieve a better result, allegedly, than the standard tools available in regular image-editing software – handy, I suppose, if you want to make a poster out of a postage stamp – but I have no experience of these, and to be honest I distrust their claims. There's only so much you can do with maths and little coloured squares.
Finally, at some point you will also need to make an informed choice of what file format to use if you need to save your new, resized version of an image file.
If you choose JPEG (most people seem to), then you will be offered a choice of levels of "compression" (or "quality") as described above. A high-quality JPEG is great for finalised images, even for printing exhibition-quality work, especially as the smaller file size is more practical for uploading to a commercial printer; it's not so great if you might want to make further edits, as a little more data will be thrown away each time you re-save it. Also, if you compress the file too far because you want to save disk space, you will very quickly lose image quality as more and more data is discarded.
A "lossless" format like TIFF is the best option for anyone wanting to work at the highest levels of quality, but this will make for much larger files, even if your camera or phone is rated as modestly as 12 or 16 MP, never mind some 100 MP monster. The TIFF version of a raw or JPEG file produced by a camera or phone will always be significantly bigger than its source file, simply because of the different way that format codes its data.
An example. That 12 MP image from my iPhone 12 mini is:
5.6 MB in its "native" HEIC file type [6]
10.5 MB when the HEIC is converted to the highest-quality JPEG
10.5 MB as a "raw" DNG file created on the phone by the Halide app
35.8 MB when either the JPEG or the DNG file is saved as a TIFF file.
361 KB (tiny) when the TIFF is resized by resampling as a high-quality JPEG, 8.5 inches long and at 96 dpi for my blog.
Despite this, I always save any photo I want to work on as a TIFF: did I mention I was running out of disk space?
The crucial thing to remember, though, is never to save a file which you have resized by resampling with the same name and file type as the original file. NEVER! The changes made by resampling are irreversible. In fact, I'd recommend that you never save a file edited in any way with the same name as the original. Just get in the habit of adding "_v2", "_v3", or something of the sort to the filename, and saving it as a new file. It's far better to use up precious disk space than to lose even more precious file data. (Says the man with the disk-space problem...)
Phew, what a lot of words to explain something so simple... OK, there's the bell, lesson's over. Don't forget your homework, and no running in the corridors!
1. Those of us who prefer to work with raw files do so because we believe, rightly or wrongly, that working with all the image data as captured keeps more options open than working with the over-tweaked subset delivered by the camera's preset algorithms. It does require work, but it can take just as much work to undo the over-saturated eye-candification of a smartphone JPEG image made under grey British skies, and TBH not much can be done after the event to remedy the over-enthusiastic noise-reduction and sharpening that make a photo look so gorgeous on a tiny phone screen.
2. It is unfortunate that resolution tends to be measured in inches, but image dimensions and paper sizes (in civilised countries, anyway) in millimetres / centimetres. To keep things simple, I'll use inches. Also, all of my examples presume that the original picture proportions ("aspect ratio") will be kept, so that the short side of the image is automatically resized in proportion to the long side, and vice versa. There is usually a tick box in the dialogue to ensure this, which can be unticked, but madness lies down that road...
3. So why doesn't it look huge on my phone, I hear you ask? Well, they don't call them "smart" phones for nothing... The phone's software creates a temporary display-sized version of the actual file without being told to do so.
4. Don't ask me about which of the resampling methods is best (usually offered as a dropdown menu of choices). I have always used the Photoshop default of "bicubic" without any problems. As I say, this is about maths and tiny coloured squares...
5. Printing is a whole other zone of confusion, of course. I remember struggling to explain to one guy, a very competent photographer, why he didn't need to resample his images to 1440 ppi to match his printer's output of 1440 dpi ("dots per inch"). Having read this post, you probably sympathise with him.
6. The newer "High Efficiency Image" file type is claimed to have various technical advantages over JPEG, and has been adopted by Apple. The main problem for us users of cheap, old editing software is that these files can't be opened, and must be converted into JPEGs using a standalone utility anyway! Despite being rather smaller in size, the actual image quality of HEIC images does look identical to me.
2 comments:
Thanks, Mike, for a very good run at explaining this oft confused concept to those who really do need to get it! --Pat
Pat,
Thanks! I've probably lost 80% of the readers with this one, but as the Big Fellow liked to say, "He who has ears to hear, let him hear"...
The missing component is how (and why) to resize photos on a phone, rather than on a [proper] computer. I can't be the only one to regularly receive multi-megabyte email attachments from well-meaning friends... I can't understand why most phones, for example, don't always offer a simple resize option when "sharing" a photo. Some do, some don't; some do for certain options, but not all; some automatically resize, but without saying so, etc.
Mike
Post a Comment