Пример #1
0
<?php

require_once '../php_image_magician.php';
/*	Purpose: Open image
 *	Usage:	 resize('filename.type')
 * 	Params:	 filename.type - the filename to open
 */
$magicianObj = new imageLib('sample_images/racecar.jpg');
/*	Purpose: Add text to your image
 *	Usage:	 addText([text], [position], [padding], [font_color], [font_size], [angle], [font])
 * 	Params:	 text - the string of text to add
 * 			 position - Specified by "width x height". EG: 200 x 300
 * 			 padding - Ignored when specifying exact pixel location
 *			 font_color - The color of the font
 *			 font_size - The size of the font in pixels
 *			 angle - The angle of the text in degress
 *			 font - You can supply your own ttf font. Pass in the name and
 *				path
 *	Output:	 This will add the word "test" 20px in and 30px down on the 
 *			 original image. The text will be gray (#ccc), 12px high, read
 * 				left to right (angle = 0) and will use the font arialbd.ttf
 *			 default color, white.
 */
$magicianObj->addText('test', '20x30', 0, '#ccc', 12, 0, 'image_lib/fonts/arimo.ttf');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_5.2.png', 100);
Пример #2
0
/*	Purpose: Open image
 *	Usage:	 resize('filename.type')
 * 	Params:	 filename.type - the filename to open
 */
$magicianObj = new imageLib('sample_images/racecar.jpg');
/*	Purpose: Add text to your image
 *	Usage:	 addText([text], [position], [padding])
 * 	Params:	 text - the string of text to add
 * 			 position - choose from the below options
 * 
 * 				tl = top left,
 * 				t  = top (middle), 
 * 				tr = top right,
 * 				l  = left,
 * 				m  = middle,
 * 				r  = right,
 * 				bl = bottom left,
 * 				b  = bottom (middle),
 * 				br = bottom right
 * 			 padding - This moves the image away from the edges (in pixels)
 *	Output:	 This will add the word "test" to the middle of your image in
 *			 default color, white.
 */
$magicianObj->addText('test', 'm');
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_5.1.png', 100);
Пример #3
0
require_once '../php_image_magician.php';
/*	Purpose: Open image
 *	Usage:	 resize('filename.type')
 * 	Params:	 filename.type - the filename to open
 */
$magicianObj = new imageLib('sample_images/racecar.jpg');
/*	Purpose: Add a caption box to your image. The intended purpose is to 
 *			 allow text to be easier to read by placing it on a caption box
 *	Usage:	 addCaptionBox([side], [thickness], [padding], [color], [transparency])
 * 	Params:	 side - the side of the image to display the box. The options are:
 *
 *     			t = top of the image
 *				r = right side of the image
 *				b = bottom of the image
 *				l = left side of the image
 *
 *			thickness - how wide you want the caption box, in pixel.
 *			padding - distance from the caption box to the image edge.
 *			color - the color of the caption box
 *			transparency - how transparent the caption box is. 0-100. 
 *				100 being not transparent at all.
 */
$magicianObj->addCaptionBox('b', 40, 0, '#000', 50);
$magicianObj->addText('Racecar 2000', 'b', 14);
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_12.1.png', 100);
require_once '../php_image_magician.php';
/*	Purpose: Open image
 *	Usage:	 resize('filename.type')
 * 	Params:	 filename.type - the filename to open
 */
$magicianObj = new imageLib('sample_images/racecar.jpg');
/*
		It's also possible to "stack" transformations. The following is one
		example of many possibilities	
*/
// *** Resize image
$magicianObj->resizeImage(200, 200, 'crop');
// *** Add greyscale
$magicianObj->greyScaleDramatic();
// *** Add white border
$magicianObj->addBorder(25, '#fff');
// *** Add black border
$magicianObj->addBorder(5, '#000');
// *** Add white border
$magicianObj->addBorder(1, '#fff');
// *** Add watermark (bottom, 40px from boarder, 50% opacity)
$magicianObj->addWatermark('sample_images/bear.png', 'tr', 30, 20);
// *** Add text
$magicianObj->addText('Racer', 'b', 10, '#000', 10);
/*	Purpose: Save image
 *	Usage:	 saveImage('[filename.type]', [quality])
 * 	Params:	 filename.type - the filename and file type to save as
 * 			 quality - (optional) 0-100 (100 being the highest (default))
 *				Only applies to jpg & png only
 */
$magicianObj->saveImage('output_8.1.bmp', 100);