php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67447 imagecrop() add a black line when cropping
Submitted: 2014-06-15 06:53 UTC Modified: 2015-06-29 00:06 UTC
Votes:37
Avg. Score:4.5 ± 0.9
Reproduced:35 of 35 (100.0%)
Same Version:24 (68.6%)
Same OS:20 (57.1%)
From: tonneaujeremy at gmail dot com Assigned:
Status: Closed Package: GD related
PHP Version: 5.6.10 OS: Windows and Debian 7
Private report: No CVE-ID:
 [2014-06-15 06:53 UTC] tonneaujeremy at gmail dot com
Description:
------------
I've create a script based on imagecrop() function to crop an image.
After testing I saw that a black line were added on the bottom of the cropped image.

The expected result sould be a white image (based on the example below) with 250px width and height.

Test script:
---------------
$image = imagecreatetruecolor(500, 500); 
imagefill($image, 0, 0, imagecolorallocate($images, 255, 255, 255));

$ressource = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
imagejpeg($ressource, 'test.jpg');


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-24 19:24 UTC] arsene dot bruno at gmail dot com
Hi Jeremy,

there is a little typo in your code (it should be $image instead of $images), but after correcting it I confirm that I experience the same problem. Here is the correct code to test:

$image = imagecreatetruecolor(500, 500); 
imagefill($image, 0, 0, imagecolorallocate($image, 255, 255, 255));

$ressource = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
imagejpeg($ressource, 'test.jpg');
 [2015-06-29 00:06 UTC] cmb@php.net
-PHP Version: 5.5.13 +PHP Version: 5.6.10
 [2015-06-29 00:06 UTC] cmb@php.net
PR php-src/1373 is supposed to solve the issue.
 [2015-07-12 21:20 UTC] cmb@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=891ff131efb7a6df37299f35a5110b9bae1b6738
Log: Fix #67447: imagecrop() adds a black line when cropping
 [2015-07-12 21:20 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2015-07-21 14:21 UTC] ab@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=891ff131efb7a6df37299f35a5110b9bae1b6738
Log: Fix #67447: imagecrop() adds a black line when cropping
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC