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
660
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
More Decks by Erika Heidi
See All by Erika Heidi
FreeCAD 101 Lightning Talk
erikaheidi
0
67
Learning Lab: WordPress
erikaheidi
0
150
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
220
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
270
Automatizando documentação em PHP com Autodocs
erikaheidi
0
200
Building the World: The Story Behind Wolfi
erikaheidi
0
850
Hello Wolfi
erikaheidi
1
820
Container Images for the Cloud Native Era
erikaheidi
1
480
Creating Secure Container Images with apko
erikaheidi
0
670
Other Decks in Programming
See All in Programming
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
4.7k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
180
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
100
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.9k
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
160
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
120
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.6k
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
370
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
440
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
580
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Everyday Curiosity
cassininazir
0
230
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
410
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
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