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
Rethink image manipulations with Glide
Search
Jonathan Reinink
May 21, 2015
Technology
650
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rethink image manipulations with Glide
Jonathan Reinink
May 21, 2015
More Decks by Jonathan Reinink
See All by Jonathan Reinink
The formula to awesome docs (phpDay 2017)
reinink
0
270
How to open source a PHP package (phpDay 2017)
reinink
1
250
The formula to awesome docs (Lone Star PHP 2016)
reinink
0
1.2k
The PHP Package Checklist (Lone Star PHP 2016)
reinink
0
410
Framework agnostic packages for the win (SkiPHP 2016)
reinink
1
480
Framework agnostic packages for the win (ForumPHP 2015)
reinink
8
1.2k
Rethink image manipulations with Glide (ForumPHP 2015)
reinink
0
760
Enough about Classes, Let's Talk Templates
reinink
8
4k
Practical deployments for average projects
reinink
4
500
Other Decks in Technology
See All in Technology
検証フェーズはAIの回答を判断するための学習機会
toru_kubota
2
510
しろおびから始める!ログ活用の第一歩
shumei_ito
0
400
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
110
不可逆な意思決定を避けながら10億超の顧客データを AI Ready にするデータ基盤設計
baseballyama
1
140
今こそ知りたいAmplifyGen2
mkdev10
2
150
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
300
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
390
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
140
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
530
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
650
3つのアプローチで目指す チームを強くするAI駆動開発
thkt
0
120
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
250
Unsuck your backbone
ammeep
672
58k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
sira's awesome portfolio website redesign presentation
elsirapls
0
440
Music & Morning Musume
bryan
48
7.4k
Building the Perfect Custom Keyboard
takai
2
890
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Google's AI Overviews - The New Search
badams
0
1.6k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
550
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Transcript
None
Jonathan Reinink Canadian web developer.
A native PHP template system
What is Glide? A wonderfully easy on-demand image manipulation library
written in PHP.
Glide has an HTTP based API. Manipulate images using GET
parameters.
/img/kayaks.jpg /img/kayaks.jpg?w=500 /img/kayaks.jpg?w=500&h=600 /img/kayaks.jpg?w=500&h=600&fit=crop /img/kayaks.jpg?w=500&h=600&fit=crop&filt=sepia
So where did the idea come from? Anyone remember TimThumb?
None
None
It’s a good time for HTTP + PHP. Middleware and
PSR-7 are changing how we build applications in PHP.
Only save your original images, not the manipulations. Then request
different image sizes when they are needed.
Use GD or ImageMagick. Glide is built on the Intervention
Image library.
use League\Glide\ServerFactory; ! $server = ServerFactory::create([ 'driver' => 'imagick', ]);
Use any file storage. Glide uses the Flysystem file system
abstraction library.
Use Glide in an app, or create a separate image
server. Offload image manipulations to a separate server on larger projects
Basic Glide installation. Using out-of-the-box settings.
get('/img/users/{id}', function ($id) { ! $server = ServerFactory::create([ 'source' =>
'path/to/source', 'cache' => 'path/to/cache', ]); ! $server->outputImage( 'users/'.$id.'.jpg', [ 'w' => 300, 'h' => 400 ] ); });
get('/img/{path}', function ($path) { ! $server = ServerFactory::create([ 'source' =>
'path/to/source', 'cache' => 'path/to/cache', ]); ! $server->outputImage($path, $_GET); });
get('/img/{path}', function (Request $request) { ! $server = ServerFactory::create([ 'source'
=> 'path/to/source', 'cache' => 'path/to/cache', ]); ! $server->outputImage($request); });
get('/img/{path}', function (Request $request, Glide $glide) { $glide->outputImage($request); });
https://vimeo.com/118089742
Setup Glide using S3. Free your images from the local
disk.
$server = ServerFactory::create([ 'source' => 'path/to/source', 'cache' => 'path/to/cache', ]);
$source = new Local('path/to/source'); $cache = new Local('path/to/cache'); ! $server
= ServerFactory::create([ 'source' => new Filesystem($source), 'cache' => new Filesystem($cache), ]);
$client = S3Client::factory([ 'key' => 'your-key', 'secret' => 'your-secret', ]);
! $s3 = new AwsS3Adapter($client, 'your-bucket'); $cache = new Local('path/to/cache'); ! $server = ServerFactory::create([ 'source' => new Filesystem($s3), 'cache' => new Filesystem($cache), ]);
Set a max image size. Prevent accidental resizing of massive
images.
use League\Glide\ServerFactory; ! $server = ServerFactory::create([ 'max_image_size' => 2000*2000, ]);
Prevent URL hacking by signing the image URLs. An important
security step that should always be used in production.
$builder = UrlBuilderFactory::create( 'http://example.com', 'your-sign-key' ); ! // Generate a
URL $url = $builder->getUrl('cat.jpg', ['w' => 500]); ! // Use the URL in your app echo '<img src="'.$url.'">';
$templates->registerFunction('img', function ($path, $params) { ! $builder = UrlBuilderFactory::create( 'http://example.com',
'your-sign-key' ); ! return $builder->getUrl($path, $params); });
<img src="<?=$this->img('cat.jpg', ['w' => 500])?>">
<img src="http://example.com/img/cat.jpg? w=500&token=af3dc18fc6bfb2afb521e587c348b904">
$request = Request::createFromGlobals(); $signature = SignatureFactory::create('your-sign-key'); ! try { $signature->validateRequest($request);
} catch (SignatureException $e) { // Handle error }
Resizing.
/img/kayaks.jpg?w=500 /img/kayaks.jpg?h=600 /img/kayaks.jpg?w=500&h=600 /img/kayaks.jpg?w=500&h=600&fit=contain
Cropping.
/img/kayaks.jpg?w=500&h=500&fit=crop
/img/kayaks.jpg?w=500&h=500&fit=crop&crop=left
/img/kayaks.jpg?rect=300,300,810,140
/img/kayaks.jpg?or=90
Adjustments.
/img/kayaks.jpg?bri=-25
/img/kayaks.jpg?con=25
/img/kayaks.jpg?sharp=15
Effects.
/img/kayaks.jpg?blur=10
/img/kayaks.jpg?pixel=10
/img/kayaks.jpg?filt=sepia
/img/kayaks.jpg?filt=greyscale
Output.
/img/kayaks.jpg?fm=gif /img/kayaks.jpg?fm=png /img/kayaks.jpg?fm=jpg /img/kayaks.jpg?fm=jpg&q=90
Extend! Adding your own manipulations.
Moving forward.
Thanks! Follow me on Twitter at @reinink Rate this talk
https://joind.in/13761 Thanks!