|
@@ -607,13 +607,40 @@ class Img
|
|
|
foreach ($array as $k => $v) {
|
|
|
$this->_dest['crop'][$k] = $this->getName('_' . $v . '_crop.jpg', $k);
|
|
|
if ($this->_setup == true || !file_exists($this->_dest['crop'][$k])) {
|
|
|
- $offset = explode('_',$v);
|
|
|
$x = 0;
|
|
|
$y = 0;
|
|
|
+
|
|
|
+ $offset = explode('_',$v);
|
|
|
+ if (isset($this->_dropSize[$k]) && $this->_dropSize[$k]) {
|
|
|
+ $offset[0] += $this->_dropSize[$k];
|
|
|
+ $offset[1] += $this->_dropSize[$k];
|
|
|
+ }
|
|
|
+
|
|
|
if ($this->_position) {
|
|
|
+ # 加入根据百分比计算裁图
|
|
|
+ if ($this->_position[0] <= 0) {
|
|
|
+ $this->_position[0] = $source_x/2 - $offset[0]/2;
|
|
|
+ } elseif (strstr($this->_position[0], '%')) {
|
|
|
+ $this->_position[0] = $source_x * intval(str_replace('%', '', $this->_position[0]))/100;
|
|
|
+ }
|
|
|
+ if ($this->_position[1] <= 0) {
|
|
|
+ $this->_position[1] = $source_y/2 - $offset[1]/2;
|
|
|
+ } elseif (strstr($this->_position[1], '%')) {
|
|
|
+ $this->_position[1] = $source_y * intval(str_replace('%', '', $this->_position[1]))/100;
|
|
|
+ }
|
|
|
$x = $this->_position[0];
|
|
|
$y = $this->_position[1];
|
|
|
+ } else {
|
|
|
+ $x = $source_x/2 - $offset[0]/2;
|
|
|
+ $y = $source_y/2 - $offset[1]/2;
|
|
|
+ }
|
|
|
+ if ($x < 0) {
|
|
|
+ $x = 0;
|
|
|
}
|
|
|
+ if ($y < 0) {
|
|
|
+ $y = 0;
|
|
|
+ }
|
|
|
+
|
|
|
$im = $this->_gd_copy($this->_image,$offset[0],$offset[1],$offset[0],$offset[1],$x,$y);
|
|
|
|
|
|
imagejpeg($im, $this->_dest['crop'][$k]);
|