Slide 1

Slide 1 text


 @COLINBENDELL HIGH PERF. IMAGES #✈"#

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

What elephant?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

VS.

Slide 7

Slide 7 text

94% ARTICLES WITH IMAGES GET M O R E TOTAL VIEWS

Slide 8

Slide 8 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 9

Slide 9 text

The 
 Business PROFIT! ... MAKE MONEY
 ... LOWER COSTS

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Linen Chest optimized images: 30% increase in tablet; 10% increase in conversion

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

TODO
 ☑︎make images "fast"

Slide 14

Slide 14 text

30% faster without images (3G) Guy Podjarni

Slide 15

Slide 15 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 16

Slide 16 text

User FAST EXPERIENCE ... DESPITE HARDWARE
 ... EVEN ON CELLULAR

Slide 17

Slide 17 text

NOV-2010 NOV-2016 1,624KB 416KB Images Javascript Video CSS WebFonts HTML Other 2,509KB 702KB

Slide 18

Slide 18 text

H T T PA R C H I V E . O R G : I M A G E S > 6 0 % 0KB 400KB 800KB 1,200KB 1,600KB 0 25 50 75 100 125 15-NOV-10 15-MAR-11 15-JUL-11 15-NOV-11 15-MAR-12 15-JUL-12 15-NOV-12 15-MAR-13 15-JUL-13 15-NOV-13 1-APR-14 1-AUG-14 1-DEC-14 1-APR-15 1-AUG-15 1-DEC-15 1-APR-16 1-AUG-16 1,577KB 416KB 48 56

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

R W D : O N E U R L , A D A P T T O S C R E E N S I Z E

Slide 21

Slide 21 text

DESKTOP MOBILE 1,465KB 1,624KB Images Javascript Video CSS WebFonts HTML Other 2,175KB 2,509KB

Slide 22

Slide 22 text

AUTOMOTIVE BUSINESS CMG EDUCATION FIN. TECH NOT 4 P GAMING HIGH TECH TRAVEL MANUFACTURIN MEDIA HEALTH PUBLIC SECTOR RETAIL SAAS 38KB 27KB 46KB 29KB 22KB 36KB 42KB 51KB 45KB 56KB 42KB 71KB 33KB 47KB 72KB AVERAGE JPG SIZE

Slide 23

Slide 23 text

360X 760X 1260X 370 KB 293 KB 168 KB 635 KB 623 KB 604 KB Responsive Images can save 72% of bytes! Tim Kadlec

Slide 24

Slide 24 text

TODO
 ☑︎make images "fast"
 ☑︎use responsive images

Slide 25

Slide 25 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 26

Slide 26 text

Marketing AWESOME BRAND ... EXPERIENCE ... EMOTION

Slide 27

Slide 27 text

94% ARTICLES WITH IMAGES GET M O R E TOTAL VIEWS

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

http://www2.palomar.edu/users/rmorrissette/Lectures/Physio/210Vision_files/slide0212_image003.jpg

Slide 30

Slide 30 text

S P E C T R A L S E N S I T I V I T Y 
 ( P R O B A B I L I T Y V. WAV E L E N G T H )

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

P3 sRGB

Slide 34

Slide 34 text

https://upload.wikimedia.org/wikipedia/commons/6/63/Human_eye_-_blue.JPG

Slide 35

Slide 35 text

TODO
 ☑︎make images "fast"
 ☑︎use responsive images
 ☑︎high quality

Slide 36

Slide 36 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 37

Slide 37 text

Operations RELIABLE OPERATIONS ... CONSISTENCY
 ... WITHOUT INTERRUPTION

Slide 38

Slide 38 text

0 18.75 37.5 56.25 75 4KB SHALLOW DIRECTORY STRUCTURE 4KB DEEP DIRECTORY SHALLOW 4MB SHALLOW DIRECTORY STRUCTURE 4MB DEEP DIRECTORY STRUCTURE 72MB/s 80MB/s 2MB/s 4MB/s

Slide 39

Slide 39 text

TODO
 ☑︎make images "fast"
 ☑︎use responsive images
 ☑︎high quality
 ☑︎Disaster recovery

Slide 40

Slide 40 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 41

Slide 41 text

Security PROTECT THE BUSINESS ... REDUCE RISK 
 ... STOP BAD GUYS

Slide 42

Slide 42 text

PREVENT TRANSPARENT PROXIES CAN HIJACK YOUR IMAGES
 ... FOR GOOD OR ILL

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

CRITICAL VULNERABILITIES AND EXPOSURE (CVE) 0 4.5 9 13.5 18 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 ImageMagick libjpegturbo libjpeg libpng giflib openjpeg

Slide 45

Slide 45 text

ImageMagick Is On Fire — CVE-2016–3714

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

TODO
 ☑︎make images "fast"
 ☑︎use responsive images
 ☑︎high quality (p3, retina)
 ☑︎Disaster Recovery 
 ☑︎secure

Slide 48

Slide 48 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business"

Slide 49

Slide 49 text

Dev GET STUFF DONE ... BALANCING OPINIONS
 ... GSD FASTER

Slide 50

Slide 50 text

0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 M A G I C N U M B E R : 2 S E C O N D S ( E V E N O N C E L L U L A R )

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

☑︎make images "fast"
 ☑︎use responsive images
 ☑︎high quality (p3, retina)
 ☑︎Disaster Recovery 
 ☑︎secure
 ☑︎get stuff done by monday

Slide 53

Slide 53 text

http://davemakes.tumblr.com/post/36136418100/50000-red-lego-bricks

Slide 54

Slide 54 text

So... where do I start? User Sec. Mktg Dev Ops Business

Slide 55

Slide 55 text

STEP 1:
 USE THE RIGHT FORMAT

Slide 56

Slide 56 text

VECTOR IMAGES
 MADE OF MATH

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Slide 60

Slide 60 text

SVG: 256K PNG: 24K PNG (crush): 20K PNG8: 7K SVG (svgo): 91K

Slide 61

Slide 61 text

O P T I M I Z E S V G • Scour
 www.coderead.com/scour/ • SVGO
 github.com/svg/svgo • SVGOMG (gui)
 jakearchibald.github.io/svgomg

Slide 62

Slide 62 text

B O N U S : S V G C S S S T Y L E W I T H W I D E G A M U T .main { background: rgb(241, 0, 0); } @media (color-gamut: p3) { .main { background: rgb(244, 0, 0); } } /* future */ @media (color-gamut: p3) { .main { background: color(p3 1.0 0 0); } }

Slide 63

Slide 63 text

RASTER IMAGES:
 MADE OF PIXELS • GIF • PNG • WebP • JPEG • JPEG 2000 • JPEG XR

Slide 64

Slide 64 text

LOSSLESS GIF, PNG, WEBP, JP2 RAW, TIFF, BMP, BPG, FLIF

Slide 65

Slide 65 text

LOSSY GIF, JPG, WEBP, JP2

Slide 66

Slide 66 text

G I F • 1987 (Previously Patented) • 256 Colors • “Simple” Transparency • Supported Everywhere • Universal support for Animation • image/gif

Slide 67

Slide 67 text

P N G – P O R TA B L E N E T W O R K G R A P H I C S • 1996 (no patent) • PNG8 and PNG24 • Supports Alpha Transparency • Good browser support • image/png • image/apng

Slide 68

Slide 68 text

L O S S L E S S P N G O P T I M I Z AT I O N - Convert from PNG 24 -> 8 - Trade “Alpha” transparency with simple (100%) transparency - PNG Optimization Tools: TinyPNG, PNGCrush, OptiPNG

Slide 69

Slide 69 text

J P E G – J O I N T P H O T O G R A P H I C E X P E R T S G R O U P - 21 years old (1992) - Supports RGB Colors (8 bit per channel) - First major lossy format. - No transparency support. - Extensive chroma subsampling support. - Supports progressive loading. - Compressed with: - Discrete Cosine Transformation - Quantization - Huffman encoding

Slide 70

Slide 70 text

J P E G C O M P R E S S I O N 1. Divide image into 8x8 pixel blocks

Slide 71

Slide 71 text

J P E G C O M P R E S S I O N 1. Divide image into 8x8 pixel blocks 2. Split Luminance & Chrominance Y Cb Cr

Slide 72

Slide 72 text

J P E G C O M P R E S S I O N - S I M P L I F I E D 1. Divide image into 8x8 pixel blocks 2. Split Luminance & Chrominance 3. Write pixels as ~delta from average • and round (DCT + Quantization) Y Cb Cr

Slide 73

Slide 73 text

Define Quantization Table 0 precision 0 160 110 100 160 240 255 255 255 120 120 140 190 255 255 255 255 140 130 160 240 255 255 255 255 140 170 220 255 255 255 255 255 180 220 255 255 255 255 255 255 240 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 Define Quantization Table 1 precision 0 170 180 240 255 255 255 255 255 180 210 255 255 255 255 255 255 240 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 Define Quantization Table 0 precision 0 10 7 6 10 14 24 31 37 7 7 8 11 16 35 36 33 8 8 10 14 24 34 41 34 8 10 13 17 31 52 48 37 11 13 22 34 41 65 62 46 14 21 33 38 49 62 68 55 29 38 47 52 62 73 72 61 43 55 57 59 67 60 62 59 Define Quantization Table 1 precision 0 10 11 14 28 59 59 59 59 11 13 16 40 59 59 59 59 14 16 34 59 59 59 59 59 28 40 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 QUALITY 70 QUALITY 5

Slide 74

Slide 74 text

J P E G C O M P R E S S I O N 1. Divide image into 8x8 pixel blocks 2. Split Luminance & Chrominance 3. Write pixels as ~delta from average and round (DCT + Quantization) 4. Write as line, compress (Huffman) = -9,-1,0(x62)

Slide 75

Slide 75 text

J P E G C O M P R E S S I O N 1. Divide image into 8x8 pixel blocks 2. Split Luminance & Chrominance 3. Write pixels as delta from average and round (DCT + Quantization) 4. Write as line, compress (Huffman) Q=10 Q=50 Original

Slide 76

Slide 76 text

L O S S Y C O M P R E S S I O N – N O T F O R E V E RY O N E

Slide 77

Slide 77 text

J P E G B A S E L I N E V S . P R O G R E S S I V E http://www.bookofspeed.com/chapter5.html 1 2 0 0 1 0 0 0 3 -1 0 0 1 2 0 0 1 0 0 0 3 -1 0 0 1 1 3 2 0 -1 0 0 0 0 0 0 1 1 3 2 0 -1 EOB

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

J P E G 2 0 0 0 • Supports full transparency • Supports chroma subsampling • Supports progressive loading • Compressed with: • Discrete Wavelet Transformation • Quantization • Arithmetic encoding

Slide 80

Slide 80 text

W E B P ( 2 0 1 1 ) • Supports full transparency. • Supports animation on some recent browsers. • Supports only 4:2:0 chroma subsampling. • Does NOT support progressive loading. • Compresses with: • Discrete Cosine Transformation • Block prediction • Quantization • Arithmetic encoding

Slide 81

Slide 81 text

J P E G X R • Supports full transparency. • Supports chroma subsampling. • Supports progressive loading. • Compressed with: • Hierarchical Lapped Biorthogonal Transform • Block prediction • Quantization • Huffman encoding

Slide 82

Slide 82 text

GIF 25% WebP 1% PNG 27% JPEG 45%

Slide 83

Slide 83 text

F O R M AT F E AT U R E S U P P O R T

Slide 84

Slide 84 text

O P T I M I Z E R A S T E R • Use JPeg2000 for iOS/Safari • Use WebP for Android/Chrome • Progressive Jpeg • Image Optim (Jpeg/PNG/Gif): https://imageoptim.com • Tiny PNG: https://tinypng.com/

Slide 85

Slide 85 text

STEP 2:
 OPTIMIZE FOR MOBILE

Slide 86

Slide 86 text

0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 NOT YOU YOU

Slide 87

Slide 87 text

0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 M A G I C N U M B E R : 2 S E C O N D S ( E V E N O N C E L L U L A R )

Slide 88

Slide 88 text

Nexus 7 Android 1 Moto e Moto g Nexus 5 334ms 1002ms 1180ms 222ms 494ms Desktop 103ms 2.0s 1.0s 3.0s N O T A L L M O B I L E D E V I C E S M A D E E Q U A L

Slide 89

Slide 89 text

Copy to GPU Display Network
 Request Decode

Slide 90

Slide 90 text

CELLULAR: OUT OF YOUR CONTROL

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

0 1250 2500 3750 5000 CARRIER 1 CARRIER 3 CARRIER 4 CARRIER 5 CARRIER 6 HTTP TLS

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

PREVENT TRANSPARENT PROXIES FROM DISTORTING YOUR IMAGES CACHE-CONTROL: NO-TRANSFORM

Slide 95

Slide 95 text

1280 x 520

Slide 96

Slide 96 text

R: 78 G: 101 B: 23 A: 1 R: 31 G: 33 B: 26 A: 1

Slide 97

Slide 97 text

1 2 8 0 X 5 2 0 X 4 B Y T E S = 2 . 6 M B !

Slide 98

Slide 98 text

600x600 200x200 1000x1000 x4 x4 x4 1.4MB 156KB 3.9MB

Slide 99

Slide 99 text

550x550 150x150 950x950 x4 x4 x4 1.2MB (-200KB) 88KB (-68KB) 3.5MB (-400KB)

Slide 100

Slide 100 text

Nexus 7 Android 1 Moto e Moto g Nexus 5 334ms 1002ms 1180ms 222ms 494ms Desktop 103ms 2.0s 1.0s 3.0s N O T A L L M O B I L E D E V I C E S M A D E E Q U A L

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

More breakpoints the larger the image dimensions Tim Kadlec 100 1000p

Slide 104

Slide 104 text

COMPRESSION V. QUALITY

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

Quality is JUST an Index! It is not compression Nick Doyle

Slide 107

Slide 107 text

Q5: 5KB Q10: 9KB Q15: 13KB Q50: 31KB Q75: 46KB Q90: 99KB

Slide 108

Slide 108 text

Changing File Size with Quality is snakeoil! Kornel Lesiński

Slide 109

Slide 109 text

SSIM(x, y) = (2µx µy +c 1 )(2σxy +c 2 ) (µx 2 +µy 2 +c 1 )(σx 2 +σy 2 +c 2 ) Zhou Wang, Alan C. Bovik, Hamid R. Sheikh, and Eero P. Simoncelli

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

Q10 DSSIM: 0.0566 Q50 DSSIM: 0.0251 Q80 DSSIM: 0.0179

Slide 112

Slide 112 text

Q85 61KB Q78 48KB

Slide 113

Slide 113 text

Q85 30KB Q78 23KB

Slide 114

Slide 114 text

QUALITY V. DSSIM 0.0000 0.0400 0.0800 0.1200 0.1600 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 100 95 90 85 80 75 70 65 60 55 50 45 40 35 30 25 20 15 10 5 0 JPEG (libjpegturbo) JPEG (mozjpeg) JPEG 2000 (OpenJPEG) JPEG 2000 (Kakadu) JPEG XR WebP

Slide 115

Slide 115 text

QUALITY (90-40) V. DSSIM 0.0000 0.0109 0.0218 0.0327 0.0436 0.0545 0.0655 0.0764 0.0873 0.0982 0.1091 0.1200 90 85 80 75 70 65 60 55 50 45 40 JPEG (libjpegturbo) JPEG (mozjpeg) JPEG 2000 (OpenJPEG) JPEG 2000 (Kakadu) JPEG XR WebP

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

O P T I M I Z E F O R S S I M • RGBA Structural Similarity
 kornel.ski/dssim • butteraulgi
 github.com/google/butteraugli

Slide 119

Slide 119 text

CHROMA-SUB SAMPLING TRICKING THE EYE

Slide 120

Slide 120 text

No content

Slide 121

Slide 121 text

No content

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

R G B A = 2 . 6 M B ! 4 : 4 : 4 = 1 . 9 M B 4 : 2 : 2 = 1 . 3 M B 4 : 2 : 0 = 0 . 9 M B

Slide 124

Slide 124 text

JPG includes EXIF, I can strip this out - right?

Slide 125

Slide 125 text

No content

Slide 126

Slide 126 text

M E TA D ATA https://blog.dexecure.com/impact-of-metadata-on-image-performance/

Slide 127

Slide 127 text

No content

Slide 128

Slide 128 text

ICC PROFILES

Slide 129

Slide 129 text

ONLY WIDE-GAMUT DISPLAYS CAN SEE THIS

Slide 130

Slide 130 text

O P T I M I Z E M E TA D ATA • STRIP Most Metadata • Keep Copyright • Keep ICC (convert to RGB first!)

Slide 131

Slide 131 text

☑︎WebP & JP2000
 ☑︎Resize
 ☑︎Chroma Subsampling 
 ☑︎DSSIM
 ☑︎TLS

Slide 132

Slide 132 text

STEP 3:
 SIMPLIFY

Slide 133

Slide 133 text

new Imager({ availableWidths: [200, 260, 320, 600], availablePixelRatios: [1, 1.3, 2] });

Slide 134

Slide 134 text

Slide 135

Slide 135 text

Slide 136

Slide 136 text

Slide 137

Slide 137 text

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

1. Use srcset to list image dimensions 2. Use 'w' notation for pixel 'widths' 3. don't use 'x' for DPR 4. Use sizes to help the browser pick the right size
 (defaults to using the device viewport) 5. Use small src for default

Slide 140

Slide 140 text

Copy to GPU Display Pre- Loader Network
 Request Decode

Slide 141

Slide 141 text

150px 2,000px 1000px

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

150px 2,000px 300px 600px 800px 1000px

Slide 144

Slide 144 text

0KB 23KB 45KB 68KB 90KB 150X 300X 600X 800X 123.0KB 58.3KB 21.2KB 7.6KB 74.7KB 33.9KB 12.0KB 4.1KB 46.3KB 20.3KB 7.3KB 2.5KB 25th Median 75th

Slide 145

Slide 145 text

0KB 175KB 350KB 525KB 700KB 1000X 1200X 2000X 4000X 953KB 388KB 251KB 186KB 432KB 320KB 144KB 113KB 217KB 120KB 83KB 70KB 25th Median 75th

Slide 146

Slide 146 text

Slide 147

Slide 147 text

No content

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

Slide 150

Slide 150 text

1. Use SrcSet not for Responsive Images 2. Use a polyfill 
 scottjehl.github.io/picturefill/ 3. Use lazy sizes polyfill
 github.com/aFarkas/lazysizes 4. Hide hidden Images 5. Hide Blow the Fold R E S P O N S I V E I M A G E S

Slide 151

Slide 151 text

Slide 152

Slide 152 text

Slide 153

Slide 153 text

No content

Slide 154

Slide 154 text

CLIENT HINTS: BACK TO BASICS

Slide 155

Slide 155 text

GET /You-Won't-Believe-What-Happened-Next.html 200 OK (PS: send Hints) GET /giant-galoshes.jpg (PS: I'm a S7 note; on cellular) (PPS: I'm on fire) 200 OK (PS: I shrunk the image) CLIENT HINTS: BACK TO BASICS

Slide 156

Slide 156 text

response.setHeader('Accept-CH', 'Viewport-Width, Width, DPR'); OR

Slide 157

Slide 157 text

Slide 158

Slide 158 text

Viewport-Width: 375

Slide 159

Slide 159 text

Width: 150

Slide 160

Slide 160 text

DPR: 2

Slide 161

Slide 161 text

Width: 150 300

Slide 162

Slide 162 text

GET /is_awesome.jpg Accept: image/webp, */* DPR: 2 Width: 300 Viewport-Width: 375

Slide 163

Slide 163 text

GET /is_awesome.jpg Accept: image/webp, */* DPR: 2 Width: 300 Viewport-Width: 375 User-Agent: Mozilla/5.0 (iPhone; CPU OS 10_0 ...

Slide 164

Slide 164 text

HTTP/1.1 200 OK Content-Type: image/jp2 Content-DPR: 2 Vary: Accept, DPR, Width response.setHeader('Content-Type', 'image/jp2'); response.setHeader('Content-DPR', '2'); response.setHeader('Vary', 'Accept, DPR, Width');

Slide 165

Slide 165 text

By Jon Sullivan - http://pdphoto.org/PictureDetail.php?mat=pdef&pg=8232, Public Domain, https://commons.wikimedia.org/w/index.php?curid=95997

Slide 166

Slide 166 text

By Jon Sullivan - http://pdphoto.org/PictureDetail.php?mat=pdef&pg=8232, Public Domain, https://commons.wikimedia.org/w/index.php?curid=95997

Slide 167

Slide 167 text

By Jon Sullivan - http://pdphoto.org/PictureDetail.php?mat=pdef&pg=8232, Public Domain, https://commons.wikimedia.org/w/index.php?curid=95997 Content-DPR: 0.5

Slide 168

Slide 168 text

No content

Slide 169

Slide 169 text

Save-Data: on

Slide 170

Slide 170 text

LEGACY SUPPORT

Slide 171

Slide 171 text

// place JavaScript at top of the page to prevent race condition // reset the CH (ClientHint) cookie values with actual display width if (document.cookie.match(/(^|;)\s*CH-Verify=/)) { var width = (screen.availWidth || screen.width); var dpr = (window.devicePixelRatio || 1); document.cookie = 'CH=Viewport-Width=' + width + ',DPR=' + dpr + ';expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/'; document.cookie ='CH-Set=; expires=Thu, 01 Jan 1970 00:00:01 GMT;' }

Slide 172

Slide 172 text

No content

Slide 173

Slide 173 text

if (Save-Data = 'on') then DPR = 1 let image_width = Width || Viewport-Width * DPR || Cookie.Viewport-Width * Cookie.DPR || DefaultWidth

Slide 174

Slide 174 text

APP SUPPORT

Slide 175

Slide 175 text

/// /// Add Client Hints to the HTTP request for images to populate the UIImageView. /// This will interrogate the screen and UIView to determine the hint values. /// func clientHints(imageUrl: String, targetImage:UIImageView) { let nsURL = NSURL(string: imageUrl) let config = NSURLSessionConfiguration.defaultSessionConfiguration() let screen = UIScreen.mainScreen() /// use the main screen for size and scale; UIView frame for let viewportWidthPx = screen.bounds.size.width let dpr = screen.scale let width = targetImage.frame.size.width /// convert to CSS Pixels let viewportWidth = Int(Double(viewportWidthPx) / Double(dpr)) config.HTTPAdditionalHeaders = ["Viewport-Width" : viewportWidth] config.HTTPAdditionalHeaders = ["DPR" : dpr] config.HTTPAdditionalHeaders = ["Width" : width] config.HTTPAdditionalHeaders = ["Save-Data" : "on"] /// usual NSURLSession to UIImage work from here /// Accept-CH likely won't make sense since your app /// controls the UIView dimensions let session = NSURLSession(configuration: config) let task = session.dataTaskWithURL(nsURL) { (data, response, error) in if !error { /// make sure that the image is drawn on screen var image:UIImage = UIImage(data: data) dispatch_async(dispatch_get_main_queue(), { targetImage.image = image }) } } task.resume() }

Slide 176

Slide 176 text

F O R M AT F E AT U R E S U P P O R T

Slide 177

Slide 177 text

1. Opt-In to Client Hints (for 3rd party content!) 2. Add sizes to 3. Use Accepts header and Device Detection P R I O R I T Y L I S T

Slide 178

Slide 178 text

☑︎Responsive Breakpoints
 ☑︎Client Hints
 ☑︎Lazy Loading

Slide 179

Slide 179 text

User Batman Security Marketing Dev Ops W H O C A R E S A B O U T I M A G E S ? "Business" ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓

Slide 180

Slide 180 text

1. Optimize for Mobile a) Use SVG, WebP & Jpeg 2000 b) Resize Images & Use Chroma-Subsampling c) DSSIM not Quality Index d) Use TLS 2. Use Client Hints (& Lazy Loading) with 
 Breakpoints: 150, 300, 600, 800 1000, 1200, 2000, 4000 3. Build a Disaster-Recovery-Plan 4. Monitor user performance S U M M A RY

Slide 181

Slide 181 text

No content

Slide 182

Slide 182 text

Thank-You! @colinbendell

Slide 183

Slide 183 text

XYZ RGB sRGB CMYK YCbCr YCgCo COLOUR

Slide 184

Slide 184 text

No content

Slide 185

Slide 185 text

No content

Slide 186

Slide 186 text

http://www.dpbestflow.org/color/color-space-and-color-profiles s

Slide 187

Slide 187 text

RGB

Slide 188

Slide 188 text

http://www.dpbestflow.org/color/color-space-and-color-profiles

Slide 189

Slide 189 text

CMYK

Slide 190

Slide 190 text

YCbCr

Slide 191

Slide 191 text

YCgCo v. YCbCr R = Y + 1.402 (Cr - 128) G = Y - 0.34414 (Cb - 128) - 0.71414 (Cr - 128) B = Y + 1.772 (Cb - 128) Y 1/4 1/2 1/4 R Cg = -1/4 1/2 -1/4 G Co 1/2 0 -1/2 B [ [ [ [ [ [

Slide 192

Slide 192 text

XYZ RGB sRGB CMYK YCbCr YCgCo COLOUR

Slide 193

Slide 193 text

TCP UNDER THE COVERS

Slide 194

Slide 194 text

No content

Slide 195

Slide 195 text

SMALL IMAGES

Slide 196

Slide 196 text

No content

Slide 197

Slide 197 text

No content

Slide 198

Slide 198 text

No content

Slide 199

Slide 199 text

Pixels Bytes Browser Cache 128x128 1.39KB 3.6 KB 128x128 3.34KB 5.6 KB 128x128 6.55 KB 9.6 KB 128x128 5.42 KB 9.6 KB

Slide 200

Slide 200 text

No content

Slide 201

Slide 201 text

BONUS: VIDEO

Slide 202

Slide 202 text

Video Screenshot ffmpeg -i video.gif -c:v libx264 -an -movflags faststart 
 -pix_fmt yuv420p -s 544x292 video.mp4 GIF = 4,3 MB WebP = 3,3 MB MP4 = 143 kB