Higher-level PHP constructs for manipulating image files (contd.)

Slides:



Advertisements
Similar presentations
PHP Sample Application Simple graphics and database.
Advertisements

Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Introduction to Programming
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Topics  Applets  Classes used for graphics Graphics Point Dimension.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Higher-level PHP constructs for manipulating image files.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Java Graphics Applets.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Applets and Graphics.
Four simple expressions in meta. Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Georgia Institute of Technology Drawing in Java part 1 Barb Ericson Georgia Institute of Technology September 2006.
Graphics Development Adobe Photoshop. Contents Needs of images and graphics, market size, animation Drawing basic shapes, filling, colors Adjusting an.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
Computer Graphics Lecture 1 July 11, Computer Graphics What do you think of? The term “computer graphics” is a blanket term used to refer to the.
Python Image Library PIL 10/13/05. PIL – What is it? Pythonic library for Loading and Saving images (diverse formats) Scaling, cropping, compositing,
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Chapter 7 Graphics. © Daly and Wrigley Objectives Use Graphic Components: ▫ Strings ▫ Lines ▫ Rectangles ▫ Ovals ▫ Arcs Change the color and font of elements.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
Lecture 16 Image Document Formats. Bitmap vs. Vector Images Bitmaps do not generally.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Tkinter Canvas.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
CPSC 217 T03 Week II Part #1: SimpleGraphics.py Hubert (Sathaporn) Hu.
CISC 110 Day 8 “The Outliers, Part 2” Frames, Classes, Vectors, String Manipulation, File I/O, Downloading Images.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
CSC1401 Drawing in Java - 1. Goals Understand at a conceptual and practical level How to use the Turtle class to draw on a picture How to use the java.awt.Graphics.
1 HTML. 2 Full forms WWW – world Wide Web HTTP – Hyper Text Transfer Protocol HTML – Hyper Text Markup Language.
Georgia Institute of Technology Drawing in Java – part 1 Barb Ericson Georgia Institute of Technology September 2005.
3. Drawing Let’s Learn Saengthong School, June – August 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
GD Library in PHP CH. Pradeep Reddy Assistant Professor VIT University, Vellore.
[Charts| Generating Graphic| Creating Graphic]
12 Graphics and Java 2D™.
Chapter 8 Graphics.
Logo with Curved Text.
9. Drawing.
Barb Ericson Georgia Institute of Technology September 2005
Raster Images CPSC 1030.
9. Drawing Let's Learn Python and Pygame
Chapter 10 Graphics.
Basic Graphics Drawing Shapes 1.
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Project title Scheduled dates Team members JAN FEB MAR APR MAY JUN
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
What do you wonder about? “Find your passion and begin your journey.”
DIRECTIONS: 1. Click Enable Editing in the yellow bar above.
Signature: Microsoft Word 2003
موضوع بحث: تعریف علم اصول جلسه 43.
اشاره به نتایج قیاس های فقهی گاهی، حکم شرعی است
علم اصول، «نفس قواعد» است نه «علم به قواعد»
نظریات پیرامون «تمایز علوم»
نظریات پیرامون «تمایز علوم» بررسی دلایل عدم احتیاج علوم به موضوع
نظریات پیرامون «تمایز علوم» بررسی دلایل احتیاج علوم به موضوع
Chapter 8 Graphics.
نظریات پیرامون «تمایز علوم» بررسی دلایل احتیاج علوم به موضوع
قاعده لا ضرر، تنها در شبهات حکمیه جاری است
جلسه 34.
TITLE BYOT Half Circle (Advanced)
1 ج : اشاره بعضی از اصولیون به تعریف ترکیبی آخوند با «یک لفظ»
Presentation transcript:

Higher-level PHP constructs for manipulating image files (contd.)

A library of tools for manipulating images So far, we have seen the following GD functions –imageCreateTrueColor create a new true colour image –imageGIF export image in GIF format –imagecolorallocate add a new colour to the palette for an image –imagefilledrectangle add a filled rectangle to an image –imagefill flood fill part of an image –imagefilledellipse add a filled circle or ellipse to an image –imagefilledpolygon add a filled polygon to an image

More functions for exporting images We are not restricted to exporting images in the GIF format As well as imageGIF, the GD library provides –imagePNG export image in PNG format Example usage: imagePNG($image,"someFile.png"); –imagejpeg export image in JPG format Example usage: imageJPEG($image,"someFile.jpg");

Functions for drawing unfilled shapes We are not restricted to drawing filled shapes As well as imagefilledrectangle, the GD library provides imagerectangle draws an unfilled rectangle Example usage: imagerectangle($image, 50, 50, 150, 150, $someColour); Note that this does not allow us to specify the thickness of the border of the rectangle By default, the thickness is 1 pixel, but we can change this imagesetthickness set the thickness for lines in subsequent drawing in the image Example usage: imagesetthickness($image, 3);

Drawing a thick-bordered unfilled rectangle

Functions for drawing unfilled shapes (contd.) Similarly, there is imageellipse –Example usage: imageellipse($image, $cx, $cy, $width, $height, $colour); imagepolygon –Example usage: imagepolygon($image, $arrayOfPoints, $numPoints, $colour); imageline –Example usage: imageline($image, $x1, $y1, $x2, $y2, $colour); imagearc –Draws an arc from a circle or ellipse of some width and height –0 degrees is at 3 o’clock and arc is drawn clockwise –Example usage: imageline($image, $cx, $cy, $ellipseWidth,$ellipseHeight, $startAngle,$endAngle, $colour);

Drawing a smiley face

<?php $im = imageCreateTrueColor(200, 200); $white = imagecolorallocate($im, 255, 255, 255); $red = imagecolorallocate($im, 255, 0, 0); $green = imagecolorallocate($im, 0, 255, 0); $blue = imagecolorallocate($im, 0, 0, 255); $yellow = imagecolorallocate($im, 255, 255, 0); imagefill($im,1,1,$white); // draw filled circle for head imagefilledellipse($im, 100, 100, 200, 200, $yellow); imagesetthickness($im,4); // draw the mouth imagearc($im, 100, 100, 150, 150, 25, 155, $red); // draw left eye and then the right eye imagearc($im, 60, 75, 50, 50, 0, 360, $green); imagearc($im, 140, 75, 50, 50, 0, 360, $blue); imageGIF($im,"head.gif"); ?>

Creating our own style of line imagestyle takes two arguments imagestyle($image, $arrayOfPixelColours); To use our newly defined style of line in subsequent drawing statements, we must use the special identified IMG_COLOR_STYLED instead of a colour name

Using a thick line of our own style

Adding text to an image imagestring takes six arguments imagestring($image, $font, $x, $y, $string, $colour); The font can be 1, 2, 3, 4, 5, where higher numbers produce bigger characters

We can also import images and then edit them imagecreatefromgif –Example usages: $im=imagecreatefromgif("someImage.gif"); $im=imagecreatefromgif("someUrlPointingToAGifFile"); Similarly, there is –imagecreatefrompng –imagecreatefromjpeg

Drawing on an existing image

Making animations with PHP

Making an animation with PHP <?php include "GIFEncoder.class.php"; if ($dh = opendir ( "frames/" ) ) { while (false !== ( $dat = readdir ( $dh ) ) ) { if ($dat != "." && $dat != ".." ) {$frames [ ] = "frames/$dat"; $framed [ ] = 5; } } closedir ( $dh ); } $gif = new GIFEncoder($frames,$framed,0,2,0,0,0,"url"); fwrite ( fopen( "myanimation.gif","wb"), $gif- >GetAnimation()); ?>

Making an animation with PHP <?php include "GIFEncoder.class.php"; /* Build a frames array from sources... */ if ($dh = opendir ( "frames/" ) ) { while (false !== ( $dat = readdir ( $dh ) ) ) { if ($dat != "." && $dat != ".." ) {$frames [ ] = "frames/$dat"; $framed [ ] = 5; } } closedir ( $dh ); } /* GIFEncoder constructor: image_stream = new GIFEncoder (URL or Binary data 'Sources' int 'Delay times' int 'Animation loops' int 'Disposal' int 'Transparent red, green, blue colors' int 'Source type'); */ $gif = new GIFEncoder($frames,$framed,0,2,0,0,0,"url"); fwrite ( fopen( "myanimation.gif","wb"), $gif->GetAnimation()); ?>