Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Using ImageMagick to resize your Images [WebPer...
Search
newtron
March 18, 2015
Technology
820
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Using ImageMagick to resize your Images [WebPerfTO]
Toronto Web Performance Group,
2015-03-17
https://github.com/nwtn/pres-imagemagick-webperfto
newtron
March 18, 2015
More Decks by newtron
See All by newtron
Universal web design [Accessibility Camp Toronto]
newtron
0
250
Universal web design [HackerYou a11y club]
newtron
0
230
Universal web design [Full Stack Toronto]
newtron
0
280
Information architecture as knowledge translation [World IA Day]
newtron
0
310
Improving performance with responsive (and responsible!) images [CSSDay.io]
newtron
1
410
Universal Web Design: How to create an awesome experience for every user [Open Source Bridge]
newtron
0
300
Improving performance with responsive (and responsible!) images [CSSConf]
newtron
6
730
Universal Web Design: How to create an awesome experience for every user [OpenWest]
newtron
0
300
Improving performance with responsive (and responsible!) images [OpenWest]
newtron
2
390
Other Decks in Technology
See All in Technology
小さく始める AI 活用推進 ― 日経電子版 Web チームの事例/nikkei-tech-talk47
nikkei_engineer_recruiting
0
270
非エンジニアがClaudeと挑んだ「1ヶ月間プロダクト30本ノック」
askokc
0
520
スキルと MCP ツール、責務をどう分けるか? AI が迷わないインターフェース設計の戦略
cdataj
1
1.1k
SONiCで構築・運用する生成AI向けパブリッククラウドネットワーク ~実装編~
sonic
0
210
連合学習と機密コンピューティング
lycorptech_jp
PRO
0
120
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
330
新しいUbuntu/GNOMEが使いたいからXからWaylandへ移行頑張ってるの巻 2026-06-20
nobutomurata
0
100
Disciplined Vibes: Scaling AI-Assisted Engineering
sheharyar
0
140
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
2
330
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
750
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
130
小さくはじめるSLI/SLO ~育てながら組織に定着させる実践知~ / Starting Small with SLI/SLOs: Building Adoption Through Continuous Growth
nari_ex
7
1.9k
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
Designing for humans not robots
tammielis
254
26k
For a Future-Friendly Web
brad_frost
183
10k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Producing Creativity
orderedlist
PRO
348
40k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
330
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
190
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
420
Transcript
David Newton, St. Michael’s Hospital 1 1 Using ImageMagick to
resize your Images Toronto Web Performance Group, 2015-03-17 Twitter: @newtron Github: @nwtn Email:
[email protected]
Slides + image credits: https://github.com/nwtn/pres-imagemagick-webperfto
2
3 Responsive images are a pain in the butt
4
5
6
7 ImageMagick, y’all
8
9 $ brew install imagemagick
10 Condition File size: mean File size: % difference Photoshop
CC, with optimization 260,304.70 KB ImageMagick `-resize` 337,665.98 KB 52.39%
11 How does image resizing work?
12 685,936 pixels 189,739 pixels
13 …to 64 pixels? How do we get from 16
pixels…
14 != resampling
15 …to 64 pixels? How do we get from 16
pixels…
16 …to 64 pixels? How do we get from 16
pixels… Background interpolation
17 …to 64 pixels? How do we get from 16
pixels… Nearest-neighbour interpolation
18 Nearest-neighbour interpolation
19 Bicubic interpolation
20 Nearest-neighbour vs. bicubic interpolation
21 7 colours 1,146 colours
22
More colours = More bytes* 23
24 https://github.com/nwtn/image-resize-tests/
25 How do we know which options are best?
Quality objective: measured with DSSIM 26
27 Control Test Difference
28
Quality subjective: from me 29
Test a variety of images 30
31 The best* settings for ImageMagick
32 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH With optimization:
33 https://imageoptim.com/
34 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH Without optimization:
35 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
36 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
37 Adaptive resize Distort resize Geometry Interpolative resize Liquid rescale
Resize Sample Scale Thumbnail
38 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
39 (x1 ,y2 ) (x2 ,y2 ) (x1 ,y1 )
(x2 ,y1 ) (x,y) = + + +
40 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
41
42 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH
43 Fancy
43 Fancy
44 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
45 -unsharp 0.25x0.08+8.3+0.045 radius sigma gain threshold
46 -unsharp 0.25x0.08+8.3+0.045 radius sigma gain threshold
47 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
48
49
50
51
52 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH
53
More colours = More bytes* 54
55
56 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
57 quality 10 quality 40 quality 70 quality 100
58 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH
59 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
60 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH
61
62 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH
63
63
64
64
65 Progressive JPEGs Good? Evil?
66 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH
67
68 mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH
-unsharp 0.25x0.08+8.3+0.045 -dither None - posterize 136 -quality 82 -define png:preserve-colormap=true - interlace none INPUT_PATH With optimization:
69 mogrify -path OUTPUT_PATH -filter Triangle - define filter:support=2.0 -thumbnail
OUTPUT_WIDTH -unsharp 0.25x0.25+8.00+0.065 - dither None -posterize 136 -background Black - alpha Background -quality 82 -define jpeg:fancy- upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude- chunk=all -interlace none -colorspace sRGB - strip INPUT_PATH Without optimization:
70 Why even bother?
71 Condition File size: mean File size: % difference My
settings, optimization 221,583.36 KB My settings, no optimization 260,250.18 KB 17.45% Photoshop CC, optimization 260,304.70 KB 17.48% CodeIgniter / ExpressionEngine 276,112.95 KB 24.61% Photoshop CC, no optimization 299,709.70 KB 35.26% TYPO3.CMS 321,602.95 KB 45.14% WordPress 337,665.98 KB 52.39% Drupal 344,246.42 KB 55.36% Perch 348,735.82 KB 57.38% Craft CMS 372,055.63 KB 67.91% grunt-responsive-images 426,623.28 KB 92.36%
72 OK… but it’s still a pain in the butt
73 https://www.npmjs.com/package/grunt-respimg
74 Resizing with smart defaults SVG to PNG rasterization Optimization
75 npm install grunt-respimg --save-dev
76
77
David Newton, St. Michael’s Hospital 78 1 Using ImageMagick to
resize your Images Toronto Web Performance Group, 2015-03-17 Twitter: @newtron Github: @nwtn Email:
[email protected]
Slides + image credits: https://github.com/nwtn/pres-imagemagick-webperfto