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
MiniMagickの型を生成したい
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
a_fujisaki
August 01, 2024
Programming
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MiniMagickの型を生成したい
a_fujisaki
August 01, 2024
More Decks by a_fujisaki
See All by a_fujisaki
自作マクロと型生成
aki19035vc
0
57
rails newと同時に型を書く
aki19035vc
6
1.3k
“Rails × 型”での2年間を振り返る
aki19035vc
2
1.2k
rbs-inlineを使ってみた
aki19035vc
0
1.1k
Emacs × LSP × Steep
aki19035vc
0
290
最近追加した型の紹介とその振り返り
aki19035vc
0
900
Other Decks in Programming
See All in Programming
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
6.4k
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
960
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
600
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
130
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
140
Intent as Code
shoppingjaws
6
970
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
450
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
170
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
150
What We Talk About When We Talk About XP
m_seki
2
580
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Cult of Friendly URLs
andyhume
79
7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Claude Code のすすめ
schroneko
67
230k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
270
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Transcript
MiniMagickの型を生成したい Roppongi.rb#21 2024-08-01 @aki19035vc
自己紹介 ❏ 藤崎 亮人 ❏ @aki19035vc ❏ 所属: イタンジ株式会社 ❏
バックエンドエンジニア ❏ 不動産物件データベースの基盤開発 ❏ 学生の頃からEmacs使ってます
今日話すこと ❏ MiniMagickの型の話 ❏ MiniMagickの基本的な型の追加と困ったこと ❏ ImageMagickのドキュメントから型を生成するGemの紹介 ❏ https://github.com/aki19035vc/rbs_mini_magick ※
前回の Roppongi.rb#20 で話した内容の続き ※ 型についての基本的な解説はしません
なぜMiniMagickに型をつけるのか ❏ 業務で書いているRailsアプリケーションでは型をほぼ100%書いている ❏ MiniMagickの型がなかったので、必要な部分は自前で書いていた ❏ 他のRailsアプリケーションでも使いたい事もある ❏ せっかくなのでコミュニティに還元していきたい
そもそもMiniMagickとは ❏ ImageMagickという画像を扱うソフトウェアのRubyバインディング ❏ 画像をリサイズしたりフォーマットを変換したりできる $ magick mogrify -resize 100x100
-format png -write output.png input.jpg require "mini_magick" image = MiniMagick::Image.open("input.jpg") image.resize "100x100" image.format "png" image.write "output.png"
MiniMagickの基本的な型を追加した ❏ MiniMagickのソースコードを読んで型を書く ❏ 人力型推論なので意外と大変 ❏ gem_rbs_collectionにPRを出す (自分でマージできる) ❏ 4.13:
https://github.com/ruby/gem_rbs_collection/pull/616 ❏ 5.0 : https://github.com/ruby/gem_rbs_collection/pull/629
困ったこと ❏ method_missing で黒魔術してる ❏ ImageMagickのコマンドを作るDSLが提供されているイメージ ❏ 使用可能なオプションが何百と存在するため、それら全てをメソッドとして定義するのは大 変 module
MiniMagick class Tool def method_missing(name, *args) option = "-#{name.to_s.tr('_', '-')}" self << option self.merge!(args) self end end end image.resize "100x100" image.format "png" image.write "output.png" #=> これらのメソッドは定義されていない
ドキュメントから型を生成する Gemを作った ❏ プロジェクトのsigディレクトリにMiniMagickの型を出力する ❏ 内部的にはImageMagickのhelpオプションで出力されるusageを使用 している ❏ インストールされているImageMagickのバージョンで利用できる オプションに応じた型を生成できる
(はず) $ bundle exec rbs-mini-magick generate https://github.com/aki19035vc/rbs_mini_magick
None
今後やりたいこと ❏ MiniMagickの5系以外のバージョンへの対応 ❏ 今はMiniMagick 5.0 しか対応していない (5.0は最近出たばかり) ❏ 最低でも4.13には対応したい
❏ 複数バージョンに対応できるようには作ってはある ❏ ImageMagickの7.1 系以外でも正しく動くことを確認 ❏ 今はImageMagick 7.1 でした動作確認をしていない ❏ 最低でも7.0では動くことを確認したい (6.9は気が向いたら) ❏ 業務で使用しているRailsアプリケーションの型検査で使ってみる