/[drupal]/contributions/modules/imagecache_actions/utility.inc
ViewVC logotype

Diff of /contributions/modules/imagecache_actions/utility.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4.2.12, Tue Sep 15 23:42:00 2009 UTC revision 1.4.2.13, Fri Oct 30 13:54:39 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: utility.inc,v 1.4.2.11 2009/08/31 04:12:20 dman Exp $  // $Id: utility.inc,v 1.4.2.12 2009/09/15 23:42:00 dman Exp $
3  /**  /**
4   * @file Utility form, conversion and rendering functions for image processes   * @file Utility form, conversion and rendering functions for image processes
5   */   */
# Line 181  function hex_to_rgb($hex) { Line 181  function hex_to_rgb($hex) {
181   *   *
182   */   */
183  function imagecache_actions_keyword_filter($value, $current_size, $object_size) {  function imagecache_actions_keyword_filter($value, $current_size, $object_size) {
184    $keyword = 0;    $keyword = '';
185    $offset = 0;    $offset = 0;
186    
187    // Check if we have plus or minus values    // Check if we have plus or minus values
188      // Assume that no + means a raw value
189    
190    $keyword_split = explode('+', $value);    $keyword_split = explode('+', $value);
191    $keyword = $keyword_split[0];    $keyword = $keyword_split[0];
192    if (! empty($keyword_split[1]) ) {    if (! empty($keyword_split[1]) ) {
193      $offset = $keyword_split[1];      $offset = intval($keyword_split[1]);
194    }    }
195    
196    if (strstr($value, '-')) {    if (strstr($value, '-')) {
197      $k2 = explode('-', $value);      $keyword_split = explode('-', $value);
198      $keyword = $k2[0];      $keyword = $keyword_split[0];
199      $offset = -intval($k2[1]);      if (! empty($keyword_split[1]) ) {
200          $offset = -1 * intval($keyword_split[1]);
201        }
202    }    }
203    
204    
205    // handle % values    // handle % values
206    if (substr($value, strlen($value), 1) == '%') {    if (substr($value, strlen($value)-1, 1) == '%') {
207      $percent = TRUE;      $percent = TRUE;
208      $offset = intval($offset);      $offset = intval($offset);
209      $value = intval($value / 100 * $current_size);      $value = intval($value / 100 * $current_size);
# Line 210  function imagecache_actions_keyword_filt Line 216  function imagecache_actions_keyword_filt
216        $offset = intval($offset / 100 * $current_size);        $offset = intval($offset / 100 * $current_size);
217      }      }
218    }    }
219      #dpm(get_defined_vars());
220    
221    // Whether the value is 'top or left doesn't matter, treat both axes the same.    // Whether the value is 'top or left doesn't matter, treat both axes the same.
222    switch ($keyword) {    switch ($keyword) {
# Line 224  function imagecache_actions_keyword_filt Line 230  function imagecache_actions_keyword_filt
230        $offset = -1 * $offset;        $offset = -1 * $offset;
231        break;        break;
232      case 'center':      case 'center':
233        case 'middle':
234        $value = $current_size/2 - $object_size/2;        $value = $current_size/2 - $object_size/2;
235        break;        break;
236      default :      default :
237        // if no keyword, it was a raw number - assume top left then        // if no keyword, it was a raw number - assume top left then
238        $value = intval($value);        $value = intval($value);
239    }    }
240      #dpm(get_defined_vars());
241    #dpm("Placing an object $object_size big on a range of $current_size at a position of $value , $offset");    #dpm("Placing an object $object_size big on a range of $current_size at a position of $value , $offset");
242    
243    // Add any extra negative or positive    // Add any extra negative or positive
244    if (!empty($offset)) {    if (!empty($offset)) {
245      $value = $value + $offset;      $value = $value + $offset;
# Line 245  function imagecache_actions_keyword_filt Line 254  function imagecache_actions_keyword_filt
254  function imagecache_actions_calculate_relative_position($base, $layer, $style) {  function imagecache_actions_calculate_relative_position($base, $layer, $style) {
255    // $textimage should now have its size info available.    // $textimage should now have its size info available.
256    // Calc the position    // Calc the position
257    if (!empty($style['top'])) {    if (isset($style['top'])) {
258      $ypos = $style['top'];      $ypos = $style['top'];
259    }    }
260    if (!empty($style['bottom'])) {    if (isset($style['bottom'])) {
261      $ypos = $base->info['height'] - ( $layer->info['height'] + $style['bottom']);      $ypos = $base->info['height'] - ( $layer->info['height'] + $style['bottom']);
262    }    }
263    if (! isset($ypos)) {    if (! isset($ypos)) {
# Line 256  function imagecache_actions_calculate_re Line 265  function imagecache_actions_calculate_re
265      $ypos = ($base->info['height']/2) - ($layer->info['height']/2);      $ypos = ($base->info['height']/2) - ($layer->info['height']/2);
266    }    }
267    
268    if (!empty($style['left'])) {    if (isset($style['left'])) {
269      $xpos = $style['left'];      $xpos = $style['left'];
270    }    }
271    if (!empty($style['right'])) {    if (isset($style['right'])) {
272      $xpos = $base->info['width'] - ( $layer->info['width'] + $style['right']);      $xpos = $base->info['width'] - ( $layer->info['width'] + $style['right']);
273    }    }
274    if (! isset($xpos)) {    if (! isset($xpos)) {

Legend:
Removed from v.1.4.2.12  
changed lines
  Added in v.1.4.2.13

  ViewVC Help
Powered by ViewVC 1.1.2