|
47 | 47 | * @method void copyMergeGray(Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH, $opacity)
|
48 | 48 | * @method void copyResampled(Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH)
|
49 | 49 | * @method void copyResized(Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH)
|
| 50 | + * @method Image cropAuto(int $mode = -1, float $threshold = .5, int $color = -1) |
50 | 51 | * @method void dashedLine($x1, $y1, $x2, $y2, $color)
|
51 | 52 | * @method void ellipse($cx, $cy, $w, $h, $color)
|
52 | 53 | * @method void fill($x, $y, $color)
|
|
56 | 57 | * @method void filledRectangle($x1, $y1, $x2, $y2, $color)
|
57 | 58 | * @method void fillToBorder($x, $y, $border, $color)
|
58 | 59 | * @method void filter($filtertype)
|
| 60 | + * @method void flip(int $mode) |
59 | 61 | * @method array ftText($size, $angle, $x, $y, $col, string $fontFile, string $text, array $extrainfo = NULL)
|
60 | 62 | * @method void gammaCorrect(float $inputgamma, float $outputgamma)
|
61 | 63 | * @method int interlace($interlace = NULL)
|
62 | 64 | * @method bool isTrueColor()
|
63 | 65 | * @method void layerEffect($effect)
|
64 | 66 | * @method void line($x1, $y1, $x2, $y2, $color)
|
65 | 67 | * @method void paletteCopy(Image $source)
|
| 68 | + * @method void paletteToTrueColor() |
66 | 69 | * @method void polygon(array $points, $numPoints, $color)
|
67 | 70 | * @method array psText(string $text, $font, $size, $color, $backgroundColor, $x, $y, $space = NULL, $tightness = NULL, float $angle = NULL, $antialiasSteps = NULL)
|
68 | 71 | * @method void rectangle($x1, $y1, $x2, $y2, $col)
|
69 | 72 | * @method Image rotate(float $angle, $backgroundColor)
|
70 | 73 | * @method void saveAlpha(bool $saveflag)
|
| 74 | + * @method Image scale(int $newWidth, int $newHeight = -1, int $mode = IMG_BILINEAR_FIXED) |
71 | 75 | * @method void setBrush(Image $brush)
|
72 | 76 | * @method void setPixel($x, $y, $color)
|
73 | 77 | * @method void setStyle(array $style)
|
@@ -297,14 +301,8 @@ public function resize($width, $height, $flags = self::FIT)
|
297 | 301 | $this->image = $newImage;
|
298 | 302 | }
|
299 | 303 |
|
300 |
| - if ($width < 0 || $height < 0) { // flip is processed in two steps for better quality |
301 |
| - $newImage = static::fromBlank($newWidth, $newHeight, self::RGB(0, 0, 0, 127))->getImageResource(); |
302 |
| - imagecopyresampled( |
303 |
| - $newImage, $this->image, |
304 |
| - 0, 0, $width < 0 ? $newWidth - 1 : 0, $height < 0 ? $newHeight - 1 : 0, |
305 |
| - $newWidth, $newHeight, $width < 0 ? -$newWidth : $newWidth, $height < 0 ? -$newHeight : $newHeight |
306 |
| - ); |
307 |
| - $this->image = $newImage; |
| 304 | + if ($width < 0 || $height < 0) { |
| 305 | + imageflip($this->image, $width < 0 ? ($height < 0 ? IMG_FLIP_BOTH : IMG_FLIP_HORIZONTAL) : IMG_FLIP_VERTICAL); |
308 | 306 | }
|
309 | 307 | return $this;
|
310 | 308 | }
|
@@ -386,10 +384,9 @@ public static function calculateSize($srcWidth, $srcHeight, $newWidth, $newHeigh
|
386 | 384 | */
|
387 | 385 | public function crop($left, $top, $width, $height)
|
388 | 386 | {
|
389 |
| - list($left, $top, $width, $height) = static::calculateCutout($this->getWidth(), $this->getHeight(), $left, $top, $width, $height); |
390 |
| - $newImage = static::fromBlank($width, $height, self::RGB(0, 0, 0, 127))->getImageResource(); |
391 |
| - imagecopy($newImage, $this->image, 0, 0, $left, $top, $width, $height); |
392 |
| - $this->image = $newImage; |
| 387 | + list($rect['x'], $rect['y'], $rect['width'], $rect['height']) |
| 388 | + = static::calculateCutout($this->getWidth(), $this->getHeight(), $left, $top, $width, $height); |
| 389 | + $this->image = imagecrop($this->image, $rect); |
393 | 390 | return $this;
|
394 | 391 | }
|
395 | 392 |
|
|
0 commit comments