1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-01-17 19:18:15 +01:00

CImage::resize now crops using imagecopy without resamling.

This commit is contained in:
Mikael Roos 2014-12-15 09:41:11 +01:00
parent 2dbe33bd8e
commit 61e0473f47
3 changed files with 44 additions and 2 deletions

View File

@ -1302,8 +1302,8 @@ class CImage
// Do as crop, take only part of image
$this->log("Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}");
$img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);
//imgcopy
imagecopyresampled($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height'], $this->crop['width'], $this->crop['height']);
//imagecopyresampled($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height'], $this->crop['width'], $this->crop['height']);
imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);
$this->image = $img;
$this->width = $this->crop['width'];
$this->height = $this->crop['height'];

View File

@ -280,6 +280,7 @@ Revision history
v0.6.x (latest)
* Minor change in `CImage::resize()`, crop now does imagecopy without resamling.
* Correcting internal details for save-as and response json which indicated wrong colors. Fix #62.
* Fixed fill-to-fit that failed when using aspect-ratio. Fix #52.
* JSON returns correct values for resulting image. Fix #58.

View File

@ -0,0 +1,41 @@
<?php
// Include config for all testcases
include __DIR__ . "/config.php";
// The title of the test case
$title = "Testing option crop";
// Provide a short description of the testcase.
$description = "Cropping parts of image";
// Use these images in the test
$images = array(
'kodim04.png',
);
// For each image, apply these testcases
$nc = "&nc"; //null; //&nc';
$testcase = array(
$nc . '&w=300',
$nc . '&w=300&crop=0,0,0,0',
$nc . '&crop=300,200,0,0',
$nc . '&crop=300,200,left,top',
$nc . '&crop=300,200,right,top',
$nc . '&crop=300,200,right,bottom',
$nc . '&crop=300,200,left,bottom',
$nc . '&crop=300,200,center,center',
$nc . '&crop=200,220,190,300',
);
// Apply testcases and present results
include __DIR__ . "/template.php";