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
Smashing Pixels with Imanee
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Erika Heidi
June 24, 2015
Programming
700
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Smashing Pixels with Imanee
Presenting Imanee, a simple PHP library for image manipulation
Erika Heidi
June 24, 2015
Transcript
22 slides
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
More Decks by Erika Heidi
See All by Erika Heidi
FreeCAD 101 Lightning Talk
erikaheidi
0
110
Learning Lab: WordPress
erikaheidi
0
200
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
260
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
320
Automatizando documentação em PHP com Autodocs
erikaheidi
0
240
Building the World: The Story Behind Wolfi
erikaheidi
0
920
Hello Wolfi
erikaheidi
1
860
Container Images for the Cloud Native Era
erikaheidi
1
510
Creating Secure Container Images with apko
erikaheidi
0
820
Other Decks in Programming
See All in Programming
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
240
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
320
あなたはMCPの機能を、まだ知らない。
4geru
1
350
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
110
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
340
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.3k
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
250
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
4
4.6k
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
210
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
340
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
640
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
The Curse of the Amulet
leimatthew05
4
17k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
580
Marketing to machines
jonoalderson
1
6k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
560
It's Worth the Effort
3n
188
29k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k