Пример #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 a border to the inside of your image
 *	Usage:	 addBorder([size], [color])
 * 	Params:	 size - Size in pixels
 *			 color - the color of the boder	(optional. Default is white)
 *	Output:	 This will add a 5px gray border to your image
 */
$magicianObj->addBorder(5, '#cccccc');
/*	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_6.1.png', 100);
Пример #2
0
/*
	As of version 4.2.5 you can now "chain" your image processing for the same
	image. That is, you can process the same image to produce multiple different
	outputs. 
	For example, say you need 3 sizes of an image. By calling reset() after each 
	save, you can freely apply new transformations to produce the next image.
*/
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');
// *** Resize and add a border to the first	copy
$magicianObj->resizeImage(300, 200, 'crop');
$magicianObj->addBorder(5, '#f0f0f0');
$magicianObj->addCaptionBox('b', 40, 0, '#000', 50);
$magicianObj->addTextToCaptionBox('Racecar 2000');
$magicianObj->saveImage('output_15.1_a.png', 100);
$magicianObj->reset();
# resets the image resource
// *** Resize and add a border to the second copy
$magicianObj->resizeImage(200, 100, 'crop');
$magicianObj->addBorder(5, '#333');
$magicianObj->saveImage('output_15.1_b.png', 100);
$magicianObj->reset();
# resets the image resource
// *** Resize and add a border to the third	copy
$magicianObj->resizeImage(200, 200, 'crop');
$magicianObj->addBorder(5, '#333');
$magicianObj->saveImage('output_15.1_c.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);