Hipstirred: Hi-Res Images
Master High-Resolution Images for Modern Web Development
Key Concepts You'll Learn
Retina/HiDPI Graphics
Understanding how high pixel density screens display images and why standard images appear fuzzy on modern devices.
2x Image Implementation
Learn to create and implement high-resolution images that appear crisp on all screen types while maintaining proper sizing.
Code vs Hardware Pixels
Grasp the fundamental difference between coded pixels and actual screen pixels in modern web development.
This exercise requires the Hipstirred Hi-Res Images folder from Desktop > Class Files > Web Dev Class. Make sure to close any existing files in your code editor to avoid confusion.
Screen Types: Standard vs HiDPI
| Feature | Standard Screens | HiDPI/Retina Screens |
|---|---|---|
| Pixel Density | Standard resolution | 2x or higher pixel density |
| Image Appearance | Standard images look fine | Standard images appear fuzzy |
| Optimal Image Type | 1x resolution images | 2x resolution images |
Adding the Standard Resolution Logo
Insert Image Element
Add the img tag with src='images/logo.png' above the first h2 element in your HTML file
Set Native Dimensions
Include height='36' and width='105' attributes to display the image at its native 105 pixel width
Test Display Quality
Save and preview in browser - standard screens show crisp image, HiDPI screens may show fuzzy appearance
Hi-res images use @2x at the end of their filename as an industry-standard practice so developers can easily identify high-resolution versions.
1 pixel in code may equal 2 or more pixels of hardware on hi-res screens
iPhone Evolution: Code vs Hardware Pixels
| Feature | Original iPhone | First Retina iPhone |
|---|---|---|
| Code Width | 320px | 320px |
| Hardware Width | 320px | 640px |
| Physical Screen Size | Same | Same |
Implementing 2x Images at Proper Size
Use 2x Image Source
Reference the @2x image file which contains double the pixel information of the standard version
Set Half Native Dimensions
Specify width and height as exactly half the image file's actual pixel dimensions
Verify Cross-Device Display
The image appears same size on all screens but sharper on HiDPI displays due to extra pixel data
Hipstirred Hi-Res Image Updates
Update src to images/logo@2x.png while keeping height='36' width='105'
Change to facebook@2x.png maintaining width='24' height='24'
Change to twitter@2x.png maintaining width='28' height='23'
Change to instagram@2x.png maintaining width='24' height='24'
Update CSS background-image to url(images/hero@2x.jpg)
Use Option+Click (Mac) or ALT+Click (Windows) in Visual Studio Code to create multiple cursors and edit all three social media icons simultaneously.
Comment out the background-size: cover property temporarily to see the actual 2x image size, confirming your retina image is loading correctly before restoring proper sizing.
Key Takeaways
