forked from masterexploder/PHPThumb
/
crop_basic_fromstring.php
42 lines (36 loc) · 1.34 KB
/
crop_basic_fromstring.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* PhpThumb Library Example File
*
* This file contains example usage for the PHP Thumb Library
*
* PHP Version 5 with GD 2.0+
* PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
* Copyright (c) 2009, Ian Selby/Gen X Design
*
* Author(s): Ian Selby <ian@gen-x-design.com>
*
* Licensed under the MIT License
* Redistributions of files must retain the above copyright notice.
*
* @author Ian Selby <ian@gen-x-design.com>
* @copyright Copyright (c) 2009 Gen X Design
* @link http://phpthumb.gxdlabs.com
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 3.0
* @package PhpThumb
* @subpackage Examples
* @filesource
*/
require_once '../ThumbLib.inc.php';
$fileData = file_get_contents('test.jpg');
$thumb = PhpThumbFactory::create($fileData, array(), true);
$thumb->crop(100, 100, 300, 200);
// $imageAsString will contain the image data suitable for saving in a database.
$imageAsString = $thumb->getImageAsString();
?>
<h2>Here's the Image Data:</h2>
<strong>Note:</strong> This should be a bunch of gibberish<br />
<div style="overflow: auto; width: 500px; height: 400px; border: 1px solid #e4e4e4; padding: 5px;"><?php echo htmlentities($imageAsString); ?></div>
<h2>Here's that data as an image:</h2>
<img src="data:image/png;base64,<?php echo base64_encode($imageAsString); ?>" />