|
@@ -465,17 +465,39 @@ class Img
|
|
|
|
|
|
$source_x = imagesx($this->_image);
|
|
|
$source_y = imagesy($this->_image);
|
|
|
- $water_x = isset($this->_mark['width']) ? $this->_mark['width'] : imagesx($water);
|
|
|
- $water_y = isset($this->_mark['height']) ? $this->_mark['height'] : imagesy($water);
|
|
|
+ $water_x = imagesx($water);
|
|
|
+ $water_y = imagesy($water);
|
|
|
+ $width = isset($this->_mark['width']) ? $this->_mark['width'] : $water_x;
|
|
|
+ $height = isset($this->_mark['height']) ? $this->_mark['height'] : $water_y;
|
|
|
+
|
|
|
+ if (isset($this->_mark['width']) || isset($this->_mark['height'])) {
|
|
|
+ $water_w = $water_x/$water_y;
|
|
|
+ $water_h = $water_y/$water_x;
|
|
|
+
|
|
|
+ if ($water_x > $width) {
|
|
|
+ $dest_x = $width;
|
|
|
+ $dest_y = $width*$water_h;
|
|
|
+ } elseif ($height > 0 && $water_y > $height) {
|
|
|
+ $dest_x = $height*$water_w;
|
|
|
+ $dest_y = $height;
|
|
|
+ } else {
|
|
|
+ $dest_x = $water_x;
|
|
|
+ $dest_y = $water_y;
|
|
|
+ }
|
|
|
+
|
|
|
+ $water = $this->_gd_copy($water,$dest_x,$dest_y,$water_x,$water_y,0,0,false,1);
|
|
|
|
|
|
- $xy = $this->_get_mark($source_x, $source_y, $water_x, $water_y);
|
|
|
+ $xy = $this->_get_mark($dest_x, $dest_y, $dest_x, $dest_y);
|
|
|
+ $water_x = $dest_x;
|
|
|
+ $water_y = $dest_y;
|
|
|
+ } else {
|
|
|
+ $xy = $this->_get_mark($source_x, $source_y, $width, $height);
|
|
|
+ }
|
|
|
|
|
|
if ($xy[2] == false) {
|
|
|
$this->_gd_destroy($water);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- //$water = $this->_gd_copy($water, $water_x, $water_y, 0, 0, 0, 0, false);
|
|
|
$im = $this->_gd_copy($water, $water_x, $water_y, 0, 0, $xy[0], $xy[1], $this->_image);
|
|
|
|
|
|
imagejpeg($im, $this->_dest['mark']);
|
|
@@ -1121,10 +1143,35 @@ class Img
|
|
|
|
|
|
$source_x = $this->_image->getImageWidth();
|
|
|
$source_y = $this->_image->getImageHeight();
|
|
|
- $water_x = isset($this->_mark['width']) ? $this->_mark['width'] : $water->getImageWidth();
|
|
|
- $water_y = isset($this->_mark['height']) ? $this->_mark['height'] : $water->getImageHeight();
|
|
|
- $xy = $this->_get_mark($source_x, $source_y, $water_x, $water_y);
|
|
|
+ $water_x = $water->getImageWidth();
|
|
|
+ $water_y = $water->getImageHeight();
|
|
|
+
|
|
|
+ $width = isset($this->_mark['width']) ? $this->_mark['width'] : $water_x;
|
|
|
+ $height = isset($this->_mark['height']) ? $this->_mark['height'] : $water_y;
|
|
|
+
|
|
|
+ if (isset($this->_mark['width']) || isset($this->_mark['height'])) {
|
|
|
+ $water_w = $water_x/$water_y;
|
|
|
+ $water_h = $water_y/$water_x;
|
|
|
+
|
|
|
+ if ($water_x > $width) {
|
|
|
+ $dest_x = $width;
|
|
|
+ $dest_y = $width*$water_h;
|
|
|
+ } elseif ($height > 0 && $water_y > $height) {
|
|
|
+ $dest_x = $height*$water_w;
|
|
|
+ $dest_y = $height;
|
|
|
+ } else {
|
|
|
+ $dest_x = $water_x;
|
|
|
+ $dest_y = $water_y;
|
|
|
+ }
|
|
|
+
|
|
|
+ $water->thumbnailImage($dest_x, $dest_y);
|
|
|
|
|
|
+ $xy = $this->_get_mark($dest_x, $dest_y, $dest_x, $dest_y);
|
|
|
+ $water_x = $dest_x;
|
|
|
+ $water_y = $dest_y;
|
|
|
+ } else {
|
|
|
+ $xy = $this->_get_mark($source_x, $source_y, $width, $height);
|
|
|
+ }
|
|
|
|
|
|
$draw->composite($water->getImageCompose(), $xy[0], $xy[1], $water_x, $water_y, $water);
|
|
|
|