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
Smashing Pixels with Imanee
Search
Erika Heidi
June 24, 2015
Programming
1
580
Smashing Pixels with Imanee
Presenting Imanee, a simple PHP library for image manipulation
Erika Heidi
June 24, 2015
Tweet
Share
More Decks by Erika Heidi
See All by Erika Heidi
Learning Lab: WordPress
erikaheidi
0
40
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
110
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
140
Automatizando documentação em PHP com Autodocs
erikaheidi
0
110
Building the World: The Story Behind Wolfi
erikaheidi
0
610
Hello Wolfi
erikaheidi
1
690
Container Images for the Cloud Native Era
erikaheidi
1
360
Creating Secure Container Images with apko
erikaheidi
0
500
Criando GitHub Actions em PHP com Minicli
erikaheidi
0
230
Other Decks in Programming
See All in Programming
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
120
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
260
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
sappoRo.R #12 初心者セッション
kosugitti
0
230
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
370
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
41
15k
Software Architecture
hschwentner
6
2.1k
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
7
2.5k
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
1
170
自分ひとりから始められる生産性向上の取り組み #でぃーぷらすオオサカ
irof
8
2.6k
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
770
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
310
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
29
2.2k
Into the Great Unknown - MozCon
thekraken
35
1.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
GitHub's CSS Performance
jonrohan
1030
460k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Practical Orchestrator
shlominoach
186
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Transcript
None
whoami
Image manipulation • Important in any programming language • Essential
operations – Resizing – Creating Thumbnails – Cropping • More fun stuf – Filters and collages – Animated gifs
Image manipulation in PHP • GD • Imagick (Imagemagick) •
Wrappers
Resize Example: GD <?php header("Content-type: image/jpg"); $image = imagecreatefromjpeg('img01.jpg'); $width
= 200; $height = 200; $finalWidth = $width; $finalHeight = ($finalWidth * imagesy($image)) / imagesx($image); if ($finalHeight > $height) { $finalHeight = $height; $finalWidth = ($finalHeight * imagesx($image)) / imagesy($image); } $newimage = imagecreatetruecolor($finalWidth, $finalHeight); imagecopyresampled($newimage, $image, 0, 0, 0, 0, $finalWidth, $finalHeight, imagesx($image), imagesy($image)); echo imagejpeg($newimage);
Resize Example: Imagick <?php header("Content-type: image/jpg"); $image = new Imagick('img01.jpg');
$width = 200; $height = 200; $image->resizeImage($width, $height, IMAGICK::FILTER_LANCZOS, 1, true); echo $image->getImageBlob();
Resize Example: Imanee <?php include __DIR__ . '/vendor/autoload.php'; header("Content-type: image/jpg");
$imanee = new Imanee\Imanee('img01.jpg'); echo $imanee ->resize(300, 300) ->output();
Introducing: Imanee • Image manipulation for fun projects • Requirements
– PHP >= 5.4 – Imagick (php5-imagick) OR – GD (php5-gd)* • Installation – $ composer require imanee/imanee * the GD extension doesn't support animated gifs
Getting Started <?php include __DIR__ . '/vendor/autoload.php'; use Imanee\Imanee; header("Content-type:
image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee ->resize(300, 300) ->output();
Basic operations: Thumbnail header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo
$imanee->thumbnail(300, 300) ->output();
Basic operations: Thumbnail w/ crop header("Content-type: image/jpg"); $imanee = new
Imanee('img01.jpg'); echo $imanee->thumbnail(300, 300, true) ->output();
Basic operations: Crop header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo
$imanee->crop(300, 300, 260, 0) ->output();
WRITING TEXT
Writing Text header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->placeText('testing
imanee', Imanee::IM_POS_MID_CENTER) ->output();
Writing Text with custom Drawer header("Content-type: image/jpg"); $imanee = new
Imanee('img01.jpg'); $imanee->getDrawer() ->setFont('almonte_wood.ttf') ->setFontColor('yellow') ->setFontSize(100); echo $imanee->placeText('testing imanee!', Imanee::IM_POS_MID_CENTER) ->output();
FILTERS AND COLLAGES
Filters header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->applyFilter('filter_bw') ->output();
Collages header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee ->placeImage('cat01.png',
Imanee::IM_POS_TOP_LEFT) ->placeImage('cat02.png', Imanee::IM_POS_TOP_RIGHT) ->output();
Animated Gifs header("Content-type: image/gif"); $frames = ['cat01.png', 'cat02.png', 'cat03.png', 'cat04.png'];
$imanee = new Imanee(); $imanee->addFrames($frames); echo $imanee->animate(30); $frames = ['cat01.png', 'cat02.png', 'cat03.png', 'cat04.png']; echo Imanee::arrayAnimate($frames, 30); echo Imanee::globAnimate(__DIR__ . '/*.png', 30);
RESOURCES
Resources • Getting Started – Documentation: http://docs.imanee.io – Simple demos:
http://imanee.io • Built with Imanee – Placephant: http://placephant.com • Try: http://placephant.com/{width}/{height} – Gifagram: [demo]
[email protected]
@erikaheidi