php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69182 imagecropauto function not properly documented
Submitted: 2015-03-04 12:07 UTC Modified: 2016-07-11 17:56 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: omid dot khodatars at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 5.5.22 OS: windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 16 = ?
Subscribe to this entry?

 
 [2015-03-04 12:07 UTC] omid dot khodatars at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.imagecropauto
---


Test script:
---------------
here is the code

$ini_filename = 'img.png';
$im = imagecreatefrompng($ini_filename );
$to_crop_array = array('x' =>310 , 'y' => 0, 'width' => 573, 'height'=> 500);
$thumb_im = imagecropauto($im ,IMG_CROP_WHITE , .5 ,-1 );
// $thumb_im = imagecrop($im, $to_crop_array);
imagepng($thumb_im, 'imgOut.png', 9);

and here is the error 
Warning: imagepng() expects parameter 1 to be resource, boolean given in ... on line 9
it is working fine with imagecrop() by the way.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-11 16:30 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: *General Issues +Package: GD related -Assigned To: +Assigned To: cmb
 [2016-07-11 16:30 UTC] cmb@php.net
Apparently, in your case imagecropauto() returns false. I can't
reproduce this behavior, however (tested with PHP 5.5.20 and
5.6.15 on Windows). If you still experience this problem on recent
PHP versions, please provide the image (img.png) you've used.

BTW: the $threshhold and $color arguments are needed only if
$mode==IMG_CROP_THRESHOLD.
 [2016-07-11 16:46 UTC] cmb@php.net
-Summary: imagecropauto function not working +Summary: imagecropauto function not properly documented -Status: Feedback +Status: Verified
 [2016-07-11 16:46 UTC] cmb@php.net
I've found that imagecropauto() returns FALSE, if there is nothing
to crop, e.g.:

    <?php
    $im = imagecreatetruecolor(100, 100);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 99, 99, $black);
    $thumb = imagecropauto($im ,IMG_CROP_WHITE);
    var_dump($thumb);

outputs

    bool(false)

I assume that was the case for your img.png, so I'm changing to
documentation bug.
 [2016-07-11 17:54 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339649
Log: Fix #69182: imagecropauto function not properly documented
 [2016-07-11 17:56 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

And special thanks to jordie at jordie dot org for his note, which
was rather helpful for the documentation.
 [2016-07-11 17:56 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=794c8b585afe78f9d4c15d7e02bfb6a8bfc64fa8
Log: Fix #69182: imagecropauto function not properly documented
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC