High Performance Images

Book description

High-quality images have an amazing power of attraction. Just add some stunning photos and graphics to your website or app and watch your user engagement and conversion numbers climb. It can be tricky, but with this practical guide, you’ll master the many facets of delivering high performance images on the internet—without adversely affecting site performance.

You’ll learn the nuts and bolts of color theory, image formats, storage and management, operations delivery, browser and application behavior, the responsive web, and many other topics. Ideal for developers, this book also provides useful tips, tricks, and practical theory for processing and displaying powerful images that won’t slow down your online product.

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who Should Read This Book
    2. What This Book Isn’t
    3. Navigating This Book
    4. Why We Wrote This Book
    5. Acknowledgments
    6. Conventions Used in This Book
    7. Using Code Examples
    8. Safari® Books Online
    9. How to Contact Us
  2. 1. The Case for Performance
    1. What About Mobile Apps?
    2. Speed Matters
    3. Do Images Impact the Speed of Websites?
    4. Lingering Challenges
  3. I. Image Files and Formats
  4. 2. The Theory Behind Digital Images
    1. Digital Image Basics
      1. Sampling
      2. Image Data Representation
      3. Color Spaces
      4. Additive Versus Substractive
      5. Color Profiles
      6. Alpha Channel
      7. Frequency Domain
    2. Image Formats
      1. Why Image-Specific Compression?
      2. Raster Versus Vector
      3. Lossy Versus Lossless Formats
      4. Lossy Versus Lossless Compression
      5. Prediction
      6. Entropy Encoding
      7. Relationship with Video Formats
    3. Comparing Images
      1. PSNR and MSE
      2. SSIM
      3. Butteraugli
    4. Summary
  5. 3. Lossless Image Formats
    1. GIF (It’s Pronounced “GIF”)
      1. Block by Block
    2. Animation
    3. Transparency with GIF
    4. LZW, or the Rise and Fall of the GIF
    5. The PNG File Format
    6. Understanding the Mechanics of the PNG Format
      1. PNG Signature
      2. Chunks
      3. Filters
      4. Interlacing
    7. Image Formats
    8. Transparency with PNG
    9. There Can Be Only One!
    10. Summary
  6. 4. JPEG
    1. History
    2. The JPEG Format
      1. Containers
      2. Markers
      3. Color Transformations
      4. Subsampling
      5. Entropy Coding
      6. DCT
      7. Progressive JPEGs
      8. Unsupported Modes
    3. JPEG Optimizations
      1. Lossy
      2. Lossless
    4. MozJPEG
    5. Summary
  7. 5. Browser-Specific Formats
    1. WebP
      1. WebP Browser Support
      2. WebP Details
      3. WebP Tools
    2. JPEG XR
      1. JPEG XR Browser Support
      2. JPEG XR Details
      3. JPEG XR Tools
    3. JPEG 2000
      1. JPEG 2000 Browser Support
      2. JPEG 2000 Details
      3. JPEG 2000 Tools
    4. Summary
  8. 6. SVG and Vector Images
    1. The Trouble with Raster Formats
    2. What Is a Vector Image?
    3. SVG Fundamentals
      1. The Grid
      2. Understanding the Canvas
      3. viewBox
    4. Getting into Shape
      1. Grouping Shapes Together
      2. Filters
    5. SVG Optimizations
      1. Enabling GZip or Brotli
      2. Reducing Complexity
      3. Converting Text to Outlines
    6. Automating Optimization Through Tooling
      1. Installing the SVGO Node Tool
      2. SVGOMG: The Better to See You With, My Dear
      3. Pick Your Flavor
    7. Summary
  9. II. Image Loading
  10. 7. Browser Image Loading
    1. Referencing Images
      1. <img> tag
      2. CSS background-image
    2. When Are Images Downloaded?
      1. Building the Document Object Model
      2. The Preloader
      3. Networking Constraints and Prioritization
      4. HTTP/2 Prioritization
      5. CSSOM and Background Image Download
      6. Service Workers and Image Decoding
    3. Summary
  11. 8. Lazy Loading
    1. The Digital Fold
    2. Wasteful Image Downloads
    3. Why Aren’t Browsers Dealing with This?
    4. Loading Images with JavaScript
      1. Deferred Loading
      2. Lazy Loading/Images On Demand
      3. IntersectionObserver
    5. When Are Images Loaded?
      1. The Preloader and Images
    6. Lazy Loading Variations
      1. Browsers Without JS
      2. Low-Quality Image Placeholders
      3. Critical Images
    7. Summary
  12. 9. Image Processing
    1. Decoding
      1. Measuring
      2. How Slow Can You Go?
      3. Memory Footprint
    2. GPU Decoding
      1. Triggering GPU Decoding
    3. Summary
  13. 10. Image Consolidation (for Network and Cache Efficiencies)
    1. The Problem
      1. TCP Connections and Parallel Requests
      2. Small Objects Impact the Connection Pool
      3. Efficient Use of the Connection
      4. Impact on Browser Cache: Metadata and Small Images
      5. Small Objects Observed
      6. Logographic Pages
    2. Raster Consolidation
      1. CSS Spriting
      2. Data URIs
    3. Vector Image Consolidation
      1. Icon Fonts
      2. SVG Sprites
    4. Summary
  14. 11. Responsive Images
    1. How RWD Started
    2. Early Hacks
    3. Use Cases
      1. Fixed-Dimensions Images
      2. Variable-Dimensions Images
      3. Art Direction
      4. Art Direction Versus Resolution Switching
      5. Image Formats
      6. Avoiding “Download and Hide”
      7. Use Cases Are Not Mutually Exclusive
    4. Standard Responsive Images
      1. srcset x Descriptor
      2. srcset w Descriptor
      3. <picture>
      4. Serving Different Image Formats
    5. Practical Advice
      1. To Picturefill or Not to Picturefill, That Is the Question
      2. Intrinsic Dimensions
      3. Selection Algorithms
      4. srcset Resource Selection May Change
      5. Feature Detection
      6. currentSrc
    6. Client Hints
    7. Are Responsive Images “Done”?
      1. Background Images
      2. Height Descriptors
    8. Responsive Image File Formats
      1. Progressive JPEG
      2. JPEG 2000
      3. Responsive Image Container
      4. FLIF
    9. Summary
  15. 12. Client Hints
    1. Overview
      1. Step 1: Initiate the Client Hints Exchange
      2. Step 2: Opt-in and Subsequent Requests
      3. Step 3: Informed Response
    2. Client Hint Components
      1. Viewport-Width
      2. Device Pixel Ratio
      3. Width
      4. Downlink
      5. Save-Data
      6. Accept-CH
      7. Content-DPR
    3. Mobile Apps
    4. Legacy Support and Device Characteristics
      1. Fallback: “Precise Mode” with Device Characteristics + Cookies
      2. Fallback: Good-Enough Approach
      3. Selecting the Right Image Width
    5. Summary
  16. 13. Image Delivery
    1. Image Dimensions
    2. Image Format Selection: Accept, WebP, JPEG 2000, and JPEG XR
    3. Image Quality
      1. Quality and Image Byte Size
      2. Quality Index and SSIM
      3. Selecting SSIM and Quality Use Cases
      4. Creating Consensus on Quality Index
      5. Quality Index Conclusion
    4. Achieving Cache Offload: Vary and Cache-Control
      1. Informing the Client with Vary
      2. Middle Boxes, Proxies with Cache-Control (and TLS)
      3. CDNs and Vary and Cache-Control
      4. Near Future: Key
    5. Single URL Versus Multiple URLs
    6. File Storage, Backup, and Disaster Recovery
      1. Size on Disk
      2. Cost of Metadata
    7. Domain Sharding and HTTP2
      1. How Do I Avoid Cache Busting and Redownloading?
      2. How Many Shards Should I Use?
      3. What Should I Do for HTTP/2?
      4. Best Practices
    8. Secure Image Delivery
      1. Secure Transport of Images
      2. Secure Transformation of Images
      3. Secure Transformation: Architecture
    9. Summary
  17. 14. Operationalizing Your Image Workflow
    1. Some Use Cases
      1. The e-Commerce Site
      2. The Social Media Site
      3. The News Site
    2. Business Logic and Watermarking
    3. Hello, Images
      1. Getting Started with a Derivative Image Workflow
      2. ImageMagick
      3. A Simple Derivative Image Workflow Using Bash
      4. An Image Build System
      5. A Build System Checklist
    4. High Volume, High Performance Images
      1. A Dynamic Image Server
  18. 15. Summary
    1. So…What Do I Do Again?
    2. Optimize for the Mobile Experience
    3. Optimize for the Different “Users”
    4. Creating Consensus
  19. A. Raster Image Formats
  20. B. Common Tools
    1. PNG Utilities
    2. JPEG Utilities
    3. Animated GIF Utilities
    4. GUI Utilities
    5. Exif Utilities
  21. C. Evolution of <img>
    1. 1989: Inline Images, GIFs, and Patents
    2. 1995: HTML 2.0 and <img lowsrc>
    3. 2000: Dark Ages of Images—HTML 4.01, CSS, and the Status Quo
    4. 2007: Mobile! Mobile! Mobile!
    5. 2010: Responsive Web Design, Retina Displays, and Responsive Images
    6. 2014 Responsive Images HTML Spec
    7. New Image Formats
    8. 2015: Client Hints and Accepts
  22. Index

Product information

  • Title: High Performance Images
  • Author(s): Colin Bendell, Tim Kadlec, Yoav Weiss, Guy Podjarny, Nick Doyle, Mike McCall
  • Release date: November 2016
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491925805