Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

whoami

Slide 3

Slide 3 text

Image manipulation ● Important in any programming language ● Essential operations – Resizing – Creating Thumbnails – Cropping ● More fun stuf – Filters and collages – Animated gifs

Slide 4

Slide 4 text

Image manipulation in PHP ● GD ● Imagick (Imagemagick) ● Wrappers

Slide 5

Slide 5 text

Resize Example: GD $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);

Slide 6

Slide 6 text

Resize Example: Imagick resizeImage($width, $height, IMAGICK::FILTER_LANCZOS, 1, true); echo $image->getImageBlob();

Slide 7

Slide 7 text

Resize Example: Imanee resize(300, 300) ->output();

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Getting Started resize(300, 300) ->output();

Slide 10

Slide 10 text

Basic operations: Thumbnail header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->thumbnail(300, 300) ->output();

Slide 11

Slide 11 text

Basic operations: Thumbnail w/ crop header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->thumbnail(300, 300, true) ->output();

Slide 12

Slide 12 text

Basic operations: Crop header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->crop(300, 300, 260, 0) ->output();

Slide 13

Slide 13 text

WRITING TEXT

Slide 14

Slide 14 text

Writing Text header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->placeText('testing imanee', Imanee::IM_POS_MID_CENTER) ->output();

Slide 15

Slide 15 text

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();

Slide 16

Slide 16 text

FILTERS AND COLLAGES

Slide 17

Slide 17 text

Filters header("Content-type: image/jpg"); $imanee = new Imanee('img01.jpg'); echo $imanee->applyFilter('filter_bw') ->output();

Slide 18

Slide 18 text

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();

Slide 19

Slide 19 text

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);

Slide 20

Slide 20 text

RESOURCES

Slide 21

Slide 21 text

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]

Slide 22

Slide 22 text

[email protected] @erikaheidi