diff options
author | sybio <clement.guillemain@gmail.com> | 2012-10-11 16:34:55 +0200 |
---|---|---|
committer | sybio <clement.guillemain@gmail.com> | 2012-10-11 16:34:55 +0200 |
commit | 16f51cb011ae2ac7063bf689c3b4fdb574a39613 (patch) | |
tree | be87d4f50c3f4b48f01eaa0db401432fab1a32e7 | |
parent | ee534a55da12127f702ed077a0a4b19cbad8cef7 (diff) | |
download | ImageWorkshop-16f51cb011ae2ac7063bf689c3b4fdb574a39613.zip ImageWorkshop-16f51cb011ae2ac7063bf689c3b4fdb574a39613.tar.gz ImageWorkshop-16f51cb011ae2ac7063bf689c3b4fdb574a39613.tar.bz2 |
Version 1.3.0: allows horizontal or vertical flip1.3.0
-rw-r--r-- | README.md | 19 | ||||
-rwxr-xr-x | src/PHPImageWorkshop/ImageWorkshop.php | 48 |
2 files changed, 51 insertions, 16 deletions
@@ -11,12 +11,19 @@ http://phpimageworkshop.com/ ### Latest updates
+**Version 1.3.0 - 2012-10-11**
+- You are able to apply a horizontal or vertical flip (transformation) on a layer
+```php
+ $layer->flip('horizontal');
+```
+- Refactoring mergeTwoImages() method.
+
**Version 1.2.6 - 2012-09-27**
- You can now initialize a layer from an image string (obtained with cURL, file_get_contents...):
```php
$imgString = file_get_contents("/myfolder/pic.jpg");
- $layer1 = new ImageWorkshop(array(
+ $layer = new ImageWorkshop(array(
"imageFromString" => $imgString,
));
```
@@ -40,16 +47,6 @@ apply a rotation (->rotate()) and then an opacity (->opacity()) on a layer witho - Refactoring methods that change the position of a sublayer for the new method
- Adding some informations in the composer file
-**Version 1.2.3 - 2012-08-30**
-- Fixing a position bug when cropping with some positioning choices on crop() method
-- Changing the comportment of updateLayerPositionsAfterCropping(), an internal method
-- Removing useless cropBackground() method
-- Refactoring crop() method (comportment doesn't change)
-- Updating the lib path in the test file
-
-**Version 1.2.2 - 2012-08-16**
-- Fixing a bug when applying a filter because of given parameter number
-
### Usage
- Learn how to use the class in 5 minutes: http://phpimageworkshop.com/quickstart.html
diff --git a/src/PHPImageWorkshop/ImageWorkshop.php b/src/PHPImageWorkshop/ImageWorkshop.php index 8addb6d..86ea81b 100755 --- a/src/PHPImageWorkshop/ImageWorkshop.php +++ b/src/PHPImageWorkshop/ImageWorkshop.php @@ -8,7 +8,7 @@ namespace PHPImageWorkshop; * Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP).
* ImageWorkshop can be used as a layer, a group or a document.
*
- * @version 1.2.6
+ * @version 1.3.0
* @link http://phpimageworkshop.com
* @author Sybio (Clément Guillemain / @Sybio01)
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -1554,6 +1554,47 @@ class ImageWorkshop return false;
}
+
+ /**
+ * Apply horizontal or vertical flip. (Transformation)
+ *
+ * @param string $type
+ */
+ public function flip($type = 'horizontal')
+ {
+ $layers = $this->layers;
+
+ foreach ($layers as $key => $layer) {
+
+ $layer->flip($type);
+ $this->layers[$key] = $layer;
+ }
+
+ $temp = static::generateImage($this->width, $this->height);
+
+ if ($type == 'horizontal') {
+
+ imagecopyresampled($temp, $this->image, 0, 0, $this->width - 1, 0, $this->width, $this->height, -$this->width, $this->height);
+ $this->image = $temp;
+
+ foreach ($this->layerPositions as $layerId => $layerPositions) {
+
+ $this->changePosition($layerId, $this->width - $this->layers[$layerId]->getWidth() - $layerPositions['x'], $layerPositions['y']);
+ }
+
+ } elseif ($type == 'vertical') {
+
+ imagecopyresampled($temp, $this->image, 0, 0, 0, $this->height - 1, $this->width, $this->height, $this->width, -$this->height);
+ $this->image = $temp;
+
+ foreach ($this->layerPositions as $layerId => $layerPositions) {
+
+ $this->changePosition($layerId, $layerPositions['x'], $this->height - $this->layers[$layerId]->getHeight() - $layerPositions['y']);
+ }
+ }
+
+ unset($temp);
+ }
// Internals
// ===================================================================================
@@ -1819,10 +1860,7 @@ class ImageWorkshop */
public static function mergeTwoImages(&$destinationImage, $sourceImage, $destinationPosX = 0, $destinationPosY = 0, $sourcePosX = 0, $sourcePosY = 0)
{
- $sourceImageX = imagesx($sourceImage);
- $sourceImageY = imagesy($sourceImage);
-
- imagecopy($destinationImage, $sourceImage, $destinationPosX, $destinationPosY, $sourcePosX, $sourcePosY, $sourceImageX, $sourceImageY);
+ imagecopy($destinationImage, $sourceImage, $destinationPosX, $destinationPosY, $sourcePosX, $sourcePosY, imageSX($sourceImage), imageSY($sourceImage));
}
/**
|