source: extensions/header_manager/include/banner.class.php @ 27153

Last change on this file since 27153 was 26308, checked in by mistic100, 10 years ago

hide NESW handles when forcing ratio

File size: 1.7 KB
Line 
1<?php
2defined('HEADER_MANAGER_PATH') or die('Hacking attempt!');
3
4include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php');
5
6/**
7 * class derivated from pwg_image, with special function for banner creation
8 */
9class banner_image extends pwg_image
10{
11  function banner_resize($destination_filepath, $selection)
12  {
13    global $conf;
14    $starttime = get_moment();
15
16    // width/height
17    $source_width  = $this->image->get_width();
18    $source_height = $this->image->get_height();
19
20    $crop = array(
21      'width' => $selection['x2']-$selection['x'],
22      'height' => $selection['y2']-$selection['y'],
23      'x' => $selection['x'],
24      'y' => $selection['y'],
25      );
26   
27    // maybe resizing/cropping is useless ?
28    if ($conf['header_manager']['width'] == $source_width and $conf['header_manager']['height'] == $source_height)
29    {
30      // the image doesn't need any resize! We just copy it to the destination
31      copy($this->source_filepath, $destination_filepath);
32      return $this->get_resize_result($destination_filepath, $source_width, $source_height, $starttime);
33    }
34   
35    $this->image->set_compression_quality(90);
36    $this->image->strip();
37   
38    // crop
39    $this->image->crop($crop['width'], $crop['height'], $crop['x'], $crop['y']);
40   
41    // resize to what is displayed on crop screen
42    if ($crop['width'] > $conf['header_manager']['width'])
43    {
44      $this->image->resize($conf['header_manager']['width'], $crop['height']*$conf['header_manager']['width']/$crop['width']);
45    }
46   
47    // save
48    $this->image->write($destination_filepath);
49
50    // everything should be OK if we are here!
51    return $this->get_resize_result($destination_filepath, $crop['width'], $crop['height'], $starttime);
52  }
53}
Note: See TracBrowser for help on using the repository browser.