/[drupal]/contributions/modules/image_exact/image_exact.module
ViewVC logotype

Diff of /contributions/modules/image_exact/image_exact.module

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

revision 1.5.2.2, Fri Mar 7 20:58:47 2008 UTC revision 1.5.2.3, Fri Mar 7 21:41:17 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: image_exact.module,v 1.5.2.1 2008/03/07 20:18:59 joshk Exp $  // $Id: image_exact.module,v 1.5.2.2 2008/03/07 20:58:47 joshk Exp $
3    
4  /**  /**
5   * Implementation of hook_help().   * Implementation of hook_help().
# Line 127  function image_exact_user($op, &$edit, & Line 127  function image_exact_user($op, &$edit, &
127      list($final_w, $final_h) = explode('x', variable_get('user_picture_dimensions', '190x190'));      list($final_w, $final_h) = explode('x', variable_get('user_picture_dimensions', '190x190'));
128      $w = round($final_w / 2);      $w = round($final_w / 2);
129      $h = round($final_h / 2);      $h = round($final_h / 2);
130     image_exact_resize($edit['picture'], $edit['picture'], $w, $h);      image_exact_resize($edit['_account']->picture, $edit['_account']->picture, $w, $h);
131    }    }
132  }  }
133    
# Line 144  function image_exact_resize($source, $de Line 144  function image_exact_resize($source, $de
144          $y = 0;          $y = 0;
145          $height = $source_info['height'];          $height = $source_info['height'];
146          image_crop($source,$destination,$x,$y,$width,$height);          image_crop($source,$destination,$x,$y,$width,$height);
         // drupal_set_message("Crop: $x,$y,$width,$height",'message');  
147        } elseif ($source_ar < $final_ar) { // Too tall!        } elseif ($source_ar < $final_ar) { // Too tall!
148          $height = round($source_info['height'] * ($source_ar / $final_ar));          $height = round($source_info['height'] * ($source_ar / $final_ar));
149          $y = round(($source_info['height'] - $height) / 2); //Start the crop at the halfway point to retain center          $y = round(($source_info['height'] - $height) / 2); //Start the crop at the halfway point to retain center
150          $x = 0;          $x = 0;
151          $width = $source_info['width'];          $width = $source_info['width'];
152          image_crop($source,$destination,$x,$y,$width,$height);          image_crop($source,$destination,$x,$y,$width,$height);
         // drupal_set_message("Crop: $x,$y,$width,$height",'message');  
153        }        }
154      }      }
155      image_resize($destination, $destination, $final_w, $final_h);      image_resize($destination, $destination, $final_w, $final_h);
     // drupal_set_message("Resize: $final_w, $final_h",'message');  
156      if(!file_exists($destination)) {      if(!file_exists($destination)) {
157        drupal_set_message("Image_exact: Image resize failed.","error");        drupal_set_message("Image_exact: Image resize failed.","error");
158      }      }

Legend:
Removed from v.1.5.2.2  
changed lines
  Added in v.1.5.2.3

  ViewVC Help
Powered by ViewVC 1.1.2