Example #1
0
<?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 <*****@*****.**>
 *
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @author Ian Selby <*****@*****.**>
 * @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 '../tests/bootstrap.php';
$thumb = new PHPThumb\GD(__DIR__ . '/../tests/resources/test.jpg');
$thumb->resize(100, 100);
$thumb->show();
Example #2
0
 /**
  * Create thumbnails from uploaded image
  *
  * @return void
  */
 private function _create_thumbs()
 {
     // Thumbnails
     foreach ($this->_thumbnails as $thumbnail) {
         // Create dir for thumbnail
         $this->_fs->mkdir($this->_config['dir'] . $thumbnail['dir']);
         // Previous saved image
         $thumb = new PHPThumb\GD($this->_config['dir'] . $this->_newfilename);
         // Set jpeg quality for thumbnail
         $thumb->setOptions(array('jpegQuality' => $thumbnail['jpeg_quality']));
         // If fixed size
         if ($thumbnail['adaptive']) {
             $thumb->adaptiveResize($thumbnail['max_width'], $thumbnail['max_height']);
         } else {
             $thumb->resize($thumbnail['max_width'], $thumbnail['max_height']);
         }
         // Save the image file to directory
         $thumb->save($this->_config['dir'] . $thumbnail['dir'] . DS . $this->_newfilename);
     }
 }
Example #3
0
<?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 <*****@*****.**>
 *
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @author Ian Selby <*****@*****.**>
 * @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 '../vendor/autoload.php';
$thumb = new PHPThumb\GD('http://phpthumb.gxdlabs.com/wp-content/themes/phpthumb/images/header_bg.png');
$thumb->resize(200, 200);
$thumb->show();
Example #4
0
 private function thumbs_save($path)
 {
     $path_parts = pathinfo($path);
     $filename = $path_parts['basename'];
     $this->json['group'] = Arr::get($_POST, 'group');
     $config = Config::get($this->json['group'], true);
     $dir = UPLOAD_DIR . $config['dir'] . DS;
     if (isset($config['thumbnails'])) {
         foreach ($config['thumbnails'] as $thumbnail) {
             // Cropped saved image
             $thumb = new PHPThumb\GD($dir . $filename);
             // If fixed size
             if ($thumbnail['adaptive']) {
                 $thumb->adaptiveResize($thumbnail['max_width'], $thumbnail['max_height']);
             } else {
                 $thumb->resize($thumbnail['max_width'], $thumbnail['max_height']);
             }
             // Save the image file to directory
             $thumb->save($dir . $thumbnail['dir'] . DS . $filename);
         }
     }
 }