1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-03 22:57:43 +02:00

allow negative values for crop width & height

This commit is contained in:
Mikael Roos
2013-10-15 01:20:58 +02:00
parent d7b6f7e25d
commit e886c86f72
2 changed files with 4 additions and 3 deletions

View File

@@ -495,8 +495,8 @@ EOD;
$height = $this->height;
if($this->crop) {
$width = $this->crop['width'] = $this->crop['width'] == 0 ? $this->width : $this->crop['width'];
$height = $this->crop['height'] = $this->crop['height'] == 0 ? $this->height : $this->crop['height'];
$width = $this->crop['width'] = $this->crop['width'] <= 0 ? $this->width + $this->crop['width'] : $this->crop['width'];
$height = $this->crop['height'] = $this->crop['height'] <= 0 ? $this->height + $this->crop['height'] : $this->crop['height'];
if($this->crop['start_x'] == 'left') {
$this->crop['start_x'] = 0;

View File

@@ -60,7 +60,7 @@ Usage
| `nr, no-ratio, stretch` | Do *not* keep aspect ratio when resizing using both width & height constraints. Results in stretching the image, if needed, to fit in the resulting box. |
| `cf, crop-to-fit` | Set together with both `h` & `w` to make the image fit into dimensions, and crop out the rest of the image. |
| `a, area` | Define the area of the image to work with. Set `area=10,10,10,10` (top,right,bottom,left) to crop out the 10% of the outermost area. It works like an offset to define which part of the image you want to process. Its an alternative to use `crop`. |
| `c, crop` | Crops an area from the original image, set width, height, start_x and start_y to define the area to crop, for example `crop=100,100,10,10` (`crop=width,height,start_x,start_y`). Left top corner is 0, 0. You can use left, right or center when setting start_x. You may use top, bottom or center when setting start_y. |
| `c, crop` | Crops an area from the original image, set width, height, start_x and start_y to define the area to crop, for example `crop=100,100,10,10` (`crop=width,height,start_x,start_y`). Left top corner is 0, 0. You can use left, right or center when setting start_x. You may use top, bottom or center when setting start_y. Use 0 for width or height to get the width/height of the original image. Use negative values for width/height to get original width/height minus selected value. |
| `q, quality` | Quality affects lossy compression and file size for JPEG images by setting the quality between 1-100, default is 60. Quality has no effect on PNG or GIF. |
| `d, deflate` | For PNG images it defines the compression algorithm, values can be 1-9, default is defined by PHP GD. Quality has no effect on JPEG or GIF. |
| `sharpen` | Appy a filter that sharpens the image. |
@@ -90,6 +90,7 @@ v0.4.x (latest)
* Added `htmlentities()` to verbose output.
* Fixed support for jpeg, not only jpg.
* Fixed crop whole image by setting crop=0,0,0,0
* Use negative values for crop width & height to base calulation on original width/height and withdraw selected amount.
v0.4 (2013-10-08)