| 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(). |
| 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 |
|
|
| 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 |
} |
} |