aboutsummaryrefslogtreecommitdiff
path: root/actions/resize.php
diff options
context:
space:
mode:
authorGreg Froese <greg.froese@gmail.com>2009-05-12 18:07:59 +0000
committerGreg Froese <greg.froese@gmail.com>2009-05-12 18:07:59 +0000
commita95c6c02347c847aa000d0d8e5db9b7bb3c5b3bd (patch)
treed016afcc8905fd887a1c739c96c6c90238de8508 /actions/resize.php
parent30b3d62f17b48cbc4ce0e9322bb2e1d282a3afcb (diff)
downloadelgg-a95c6c02347c847aa000d0d8e5db9b7bb3c5b3bd.tar.gz
elgg-a95c6c02347c847aa000d0d8e5db9b7bb3c5b3bd.tar.bz2
made small thumbnail square again and put watermarking where it belongs
Diffstat (limited to 'actions/resize.php')
-rw-r--r--actions/resize.php65
1 files changed, 31 insertions, 34 deletions
diff --git a/actions/resize.php b/actions/resize.php
index 8a8a5bb34..5dfc30975 100644
--- a/actions/resize.php
+++ b/actions/resize.php
@@ -65,40 +65,37 @@
// If it's a file we can manipulate ...
if (array_key_exists($imgsizearray['mime'],$accepted_formats)) {
-// $function = "imagecreatefrom" . $accepted_formats[$imgsizearray['mime']];
-// $newimage = imagecreatetruecolor($newwidth,$newheight);
-
-// if (is_callable($function) && $oldimage = $function($input_name)) {
- // Crop the image if we need a square
- if ($square) {
- if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) {
- $widthoffset = floor(($imgsizearray[0] - $width) / 2);
- $heightoffset = floor(($imgsizearray[1] - $height) / 2);
- } else {
- $widthoffset = $x1;
- $heightoffset = $y1;
- $width = ($x2 - $x1);
- $height = $width;
- }
- } else {
- if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) {
- $widthoffset = 0;
- $heightoffset = 0;
- } else {
- $widthoffset = $x1;
- $heightoffset = $y1;
- $width = ($x2 - $x1);
- $height = ($y2 - $y1);
- }
- }//else {
- // Resize and return the image contents!
- if ($square) {
- $newheight = $maxheight;
- $newwidth = $maxwidth;
- }
- $command = "convert $input_name -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." $output_name";
- system($command);
- return $output_name;
+ // Crop the image if we need a square
+ if ($square) {
+ if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) {
+ $widthoffset = floor(($imgsizearray[0] - $width) / 2);
+ $heightoffset = floor(($imgsizearray[1] - $height) / 2);
+ } else {
+ $widthoffset = $x1;
+ $heightoffset = $y1;
+ $width = ($x2 - $x1);
+ $height = $width;
+ }
+ } else {
+ if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) {
+ $widthoffset = 0;
+ $heightoffset = 0;
+ } else {
+ $widthoffset = $x1;
+ $heightoffset = $y1;
+ $width = ($x2 - $x1);
+ $height = ($y2 - $y1);
+ }
+ }
+
+ // Resize and return the image contents!
+ if ($square) {
+ $newheight = $maxheight;
+ $newwidth = $maxwidth;
+ }
+ $command = "convert $input_name -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." $output_name";
+ system($command);
+ return $output_name;
}
}