When it comes to optimizing images, there are a few strategies that can make a big impact.
If you have a repeating pattern, try to identify where the repetition occurs and crop the image accordingly. Then, in your CSS, you can easily set the background using:
body { background: url("pattern.jpg") repeat-all; }
For patterns that only repeat in one direction, like a column pattern that needs to repeat vertically, you can use:
body { background: url("column.png") repeat-y #your-background-rgb-colour; }
This will ensure the pattern repeats only in the specified direction. The same principle applies for horizontal repetition using repeat-x.
Now, let's talk about image formats. There are four main options to consider:
- .jpg: Ideal for photo-realistic images without color loss. A quality setting of around 70% is generally suitable for web viewing.
- .gif: Best for images with a limited color palette. Gif files are compact but may sacrifice some colors.
- .png (Limited Palette): Similar to gif, this png format can sometimes result in smaller file sizes while maintaining quality.
- .png (Full-bit): Comparable to jpg in terms of color range and realism. While slightly larger in size, png files have fewer compression artifacts.
Experimenting with compression settings can help you find the right balance between quality and file size.
Claire D.