Prepare Images: How To
Prepare Images: How To
Prepare Images: How To
prepare images
for use
on the web
by Geoff Powell
www.photografica.com.au
photografica
Images are a crucial part of good web design, and are
ubiquitous on virtually all websites, but technically, are so
often one of the main reasons for slow loading sites. To add
images and other graphics to websites effectively, a small
amount of knowledge goes a long way. Here’s what you
need to know.
If you are a small business owner and managing your own website, it’s likely you
use a visual interface or page builder to build, maintain and add new content. In
short, the code part will be largely invisible to you, and be assured, you don’t need
to be a code guru to get by. But you do need to know what size and type of images
you are uploading. Like many other environments, the GIGO (Garbage In; Garbage
Out) principle applies. But if you apply some basic principles in preparing your
images (size, format and best-practice saving options) your site will perform better
and you will sleep easier. Surely a job worth doing is worth doing well?
In this guide, I want to show you the basics of how to prepare images for the web:
what size they need to be, what format they need to be, and how to save them so
they look good but don’t take a long time to download.
Most of the time though, when we are uploading normal images, we are going to
be using jpgs.
Source: http://theydiffer.com/difference-between-gif-png-and-jpg/
Pixel dimensions
The best way to think of pixel dimensions is that they indicate the physical size of
the image.
It doesn’t help that pixels don’t have a fixed size, and this is why images of the
same pixel dimensions can be different sizes on different screens. How big it looks
on a screen is dependent on the number of pixels the screen displays. Two similarly
sized screens side by side might have completely different screen resolutions and
the image will be different sizes on each. This muddies the waters somewhat, but
it’s something easily catered for in preparing your images.
The resolution of the actual image (known as ppi—pixels per inch, or incorrectly as
dpi—dots per inch) has absolutely NO impact on how big the image is displayed
on the screen. It is only the pixel dimensions and the screen resolution that matter.
PPI is only relevant when printing images, and there is a widespread but mistaken
belief that images for the web should be saved at 72ppi. This is an old chestnut
that is hard to kill, but it is simply not true and totally irrelevant. A browser totally
ignores the ppi of an image, as the only thing it needs to know are the pixel
dimensions—how many pixels wide and how many pixels high the image is.
If we look at the same page on a full HD monitor with a resolution of 1920 x 1200px,
then the image will fill much less of the width and more of the height (see Image 2).
It’s still displaying at 1200 x 800px, but now there is more screen space. See the
connection between the screen and how big the image is displayed?
IMAGE 2: This is the same 1200px wide image now displayed on a screen, 1920px wide.
IMAGE 3: Note how on the laptop (front right), which has a 1366px resolution width,
the 1200px content width almost fills the entire screen, while on the desktop which has a
resolution of 1920px width (centre back), there is more white space on either side. With
smaller resolution devices—tablets and phones (front left), the responsive layout kicks in
and elements are re-arranged to fit the smaller dimensions and aspect ratio of the screen.
Pixel size?
To determine how big, in terms of pixel size, your images should be for use in your
website, you need to know how and where you want to use them.
The starting point is to understand how wide your content area is. Most websites
are currently using around 1100 or 1200px as a standard width because there are
still many devices which only have a screen resolution of 1366px. If the content
width was wider, the content would not fit the screen and we would have to scroll
to see it, or the site would have to go into responsive mode.
The guiding principle is to size your images for roughly the pixel dimensions they
will fill in your layout.
It makes no sense to use larger images, as they will be much larger in size (kilobytes)
and therefore take longer to load, while still displaying as smaller on screen.
Let’s look at a diagram to simplify the concepts.
IMAGE 4: Note here how if the content width is 1200px, it makes no sense for an image
that will only fill half of that space to be any bigger than 600px. Unless you are going to
allow people to click on it to open it in a lightbox, and then, depending on the theme,
you might either add a bigger size image for the pop up, or just add a bigger image in
the half container. That way, a 1000px image would display as approximately 600px,
but when opened in a popup would show at its true size.
With this method, the full screen image will fill the full width of the screen, regardless
of the physical dimensions of the image and the resolution of the screen. To achieve
this, the browser ‘squashes’ or ‘stretches’ the image to make it fit the browser width.
So it makes sense to use an image that is large enough for the largest screen
resolution that is likely. It is important to note that an image looks fine if it is reduced
in size, but it can’t be enlarged too much before pixilation occurs.
Higher resolution screens are becoming increasingly popular, but this creates
tension in preparing images for display as we want the best display, but at the
smallest file size (bytes). If we use an image that is around 2000px in width, it will
fill the screen of a full HD or smaller resolution monitor without issue, and if it’s
displayed on a larger screen, for example a 27” iMac which has a resolution of
2560px, then it will be slightly stretched, but not enough to cause obvious image
deterioration through pixilation.
With the advent of 5K and even 8K monitors, we start to run into issues and the only
real solution is to use larger images for those screens. We can only hope that internet
speeds will keep pace as images get larger (pixels) and require more bandwidth for
the resultant files (bytes). At this point, however, it appears to be mostly common
practice to use images around 2000px in width and allow them to stretch.
As a rough guide, if your template content width is 1200px, you could think of
these sizes as appropriate.
Simply put, a 1200 x 800px image might be 600kb+ saved without compression,
but with compression it might be at little as 60kb, with no discernible loss in
quality. That’s a massive difference in file size, which will noticeably reduce the
time for a page to fully load.
604kb 68kb
I use Adobe Photoshop to save images for web use, and apply compression
to all files after I resize them. But image compression can be achieved with
almost all image editing software including Lightroom (http://www.adobe.com/
au/products/photoshop-lightroom.html), the free GIMP program
(https://www.gimp.org/), as well as many web-based applications.
PNGS do not compress as readily as jpgs, but there are some great online tools as
well as WordPress plugins to help you with compression and managing file size. Two
great online tools used before uploading include Tiny PNG (http://tinypng.org/)
and Caesium (https://saerasoft.com/caesium/), while WP Smush
(https://wordpress.org/plugins/wp-smushit/) and EWWW Image Optimizer
(https://wordpress.org/plugins/ewww-image-optimizer/) are examples of
WordPress plugins to help you optimise images at the server level.
If you have done your job well before uploading, those tools will have very little
to do.
Conclusion
There is much more to the subject of preparing your images for web, including the
topic of Retina and the complications caused by high resolution screens, as well as
the various tools within WordPress for adding SEO and other value to the images
you upload. These more advanced topics will be the subject of other Photografica
guides in the near future, so watch this space.
Hopefully you have enough information here to understand the concepts at play
and to help you begin sizing and saving your images at appropriate dimensions and
compression so they look great and keep your web page load time to a minimum.
Geoff
photografica