Author: uncleringo
Date: 2010-09-10 18:38:18 +0200 (Fri, 10 Sep 2010)
New Revision: 30879
Modified:
plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
Log:
Now uses original image if the same size as the final image
Correctly loads images without blurring on db reload
Fix for incorrect ratio thanks to Nicholas Tipping
(nicki-at-bigredmonster-dot-com)
Modified: plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
===================================================================
--- plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
2010-09-10 15:16:54 UTC (rev 30878)
+++ plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
2010-09-10 16:38:18 UTC (rev 30879)
@@ -318,7 +318,7 @@
return;
}
}
- else
+ else if (sfContext::hasInstance())
{
/**
* Move the new image to be named as the original
@@ -350,13 +350,12 @@
$img->saveAs($dir . DIRECTORY_SEPARATOR . $original);
}
- $height = ($img->getHeight() / $img->getWidth() ) * 400;
- $img->resize(400, $height);
+ $img->resize(400, null, true, true);
$img->saveAs($dir . DIRECTORY_SEPARATOR . $editable);
- if ($imageConfig['ratio'])
+ if (isset($imageConfig['ratio']))
{
$ratioOriginal = $img->getWidth() / $img->getHeight();
$ratioDesired = $imageConfig['ratio'];
@@ -579,6 +578,8 @@
return false;
}
+ $fullPath = $this->getImageDir() . DIRECTORY_SEPARATOR .
$this->getImageFromName($fieldName, $size);
+
$ratio = $this->originalImages[$fieldName]->getWidth() /
$this->editableImages[$fieldName]->getWidth();
@@ -586,7 +587,16 @@
$dims['y'] = (int)$this->getInvoker()->{$fieldName . '_y1'} * $ratio;
$dims['w'] = (int)($this->getInvoker()->{$fieldName . '_x2'} * $ratio) -
$dims['x'];
$dims['h'] = (int)($this->getInvoker()->{$fieldName . '_y2'} * $ratio) -
$dims['y'];
-
+
+ if ($dims['x'] == 0 && $dims['y'] == 0 && $dims['w'] ==
$imageConfig['sizes'][$size]['width'])
+ {
+ if (empty($imageConfig['ratio']) || $dims['h'] ==
(int)($imageConfig['sizes'][$size]['width'] / $imageConfig['ratio']))
+ {
+ copy($this->originalImages[$fieldName]->getFilename(), $fullPath);
+ return;
+ }
+ }
+
$origCrop = $this->originalImages[$fieldName]
->crop($dims['x'], $dims['y'], $dims['w'], $dims['h']);
@@ -596,8 +606,6 @@
null :
round($imageConfig['sizes'][$size]['width'] / $imageConfig['ratio']));
- $fullPath = $this->getImageDir() . DIRECTORY_SEPARATOR .
$this->getImageFromName($fieldName, $size);
-
$finalCrop->saveAs($fullPath);
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.