Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
【20250622】クライアントサイドで_ 高品質画像圧縮したいからウェブアプリ版 Squoo...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
asaringo
June 25, 2025
Programming
92
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
【20250622】クライアントサイドで_ 高品質画像圧縮したいからウェブアプリ版 Squoosh参照してwasmに手を出す
間違いあったら優しく教えてください
asaringo
June 25, 2025
More Decks by asaringo
See All by asaringo
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
330
Other Decks in Programming
See All in Programming
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
130
Webの地図
yosuke_furukawa
PRO
6
5.1k
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
350
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
120
Agents on Rails - Rails at Scale 2026
irinanazarova
0
330
SREの越境 / SRE Collaboration
y0hgi
2
300
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
470
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
120
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
Rでドレミ/Do-Re-Mi_with_R
florets1
0
120
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
Jetpack Compose Mechanisms
skydoves
2
370
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
420
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
450
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
GraphQLとの向き合い方2022年版
quramy
50
15k
How to Ace a Technical Interview
jacobian
280
24k
Believing is Seeing
oripsolob
1
240
Transcript
クライアントサイドで 高品質画像圧縮したいから ウェブアプリ版 Squoosh 参照してwasmに手を出す 2025/06/22 あさりんご
徒然なるままに… wasmとの出会いを振り返る 結論ありきの順番ではなく、 探索していった時の順番で話してみる (スピーチ結論から話せと言われがちだけどほんとかな? ということでお試ししてみる)
Squoosh Googleが提供しているオープンソースの高品質画像圧縮アプリ ⇒今回はこのオープンソースから、mozjpeg(C言語の高品質画像 圧縮ライブラリ)をwasmにしてjsから呼べるようにしてみる
ここっぽい
すでにwasmのファイルあるっぽいけど、 生成方法は…? ( ゚Д゚) こやつか! 名前的に!
ぐっ… _(´ཀ`」 ∠)_
いったん理解より動かすの優先でいこ Emscriptenを使えるようにするぞ☆ bashで以下コマンドどん git clone https://github.com/emscripten-core/emsdk.git cd /mnt/c/Users/[お名前]/source/repos/emsdk ./emsdk install
latest ./emsdk activate latest source ./emsdk_env.sh 動かしてくうちにわかってくるだろ… ^^) _旦~~
MakefileをEmscriptenに読ませるぞ bashで以下コマンドどん git clone https://github.com/GoogleChromeLabs/squoosh.git cd /mnt/c/Users/[お名 前]/source/repos/squoosh/codecs/mozjpeg/ emmake make
最初makeだけで打っててうまくいかずなんでや…? とかなってた思ひ出 Emscriptenつかうのだから、それ用のコマンドを!
あれ足りないこれ足りない言われる エラー文言に従ってとにかく sudo apt update && sudo apt install [パッケージ名]
できたので使ってみる 生成されたmozjpeg_enc.js ⇒約3000行のコード(;´∀`)コレモウワカンネエナ このjsどうやって使うんや… いったんexportとかないかな ⇒最後の行にexport default Moduleあった ⇒多分importして使えばいいけど、何のメソッドが使えるんや…
これなに?
mozjpeg_enc.cpp⇒バインドファイル Makefileに指定ある バインドファイルを自由に書き換えて何を生成するか決められるんだ jsから何が呼び出せるものかはここ見ればわかるんだ! mozjpeg_enc.cpp Makefile
Mozjpeg_enc.cpp内のコメント • // The code below is basically the `write_JPEG_file`
function from • // https://github.com/mozilla/mozjpeg/blob/master/example.c • // I just write to memory instead of a file. ここ肝である感 I just wirteとかいってるけどめっちゃ大事なことしてくれてる... そこにしびれるあこがれる...☆
使ってみる 生成したmozjpeg_enc.jsとmozjpeg_enc.wasmを 使用したいプロジェクトに連れていく import MozjpegEnc from [ファイルの場所] const mozjpegEnc =
await MozjpegEnc(); const result = mozjpegEnc.encode([画像],[画像の横幅],[画像の 縦幅],[オプション]) ※詳しくはmozjpeg_enc.cpp参照
CanvasAPIで画像圧縮したのと 見た目品質あんま変わらんのやが…(^_^;) • CanvasAPIが使用するのはブラウザ内蔵のjpegエンコーダ/デ コーダ(具体的な実装不明) ⇒こやつ…そこそこ優秀なのでは • オプションをもう少しちゃんといじればよくなる? • そしてCanvasAPIのほうでOKとなったので、
難しいmozjpegとはバイバイしました。
いろいろ新体験 • Emscriptenをつかってみること • chatGPTヘルプもらいつつオープンソースのコードを見てみること • オープンソースから拝借してくること(していいんだ!) • C++に触れる •
個人がGitHubにコードを公開する意味を知る(今度やってみよう)