FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18249&edit=1

ID: 18249
Updated by: hm2k@php.net
Reported By: hm2k at php dot net
Summary: expects parameter 2 to be resource, null given
Status: Open
Type: Bug
Package: Image_Transform
-Operating System:
+Operating System: CentOS
Package Version: 0.9.3
-PHP Version: Irrelevant
+PHP Version: 5.3.4
Roadmap Versions:
New Comment:

-Operating System:
+Operating System: CentOS
-PHP Version: Irrelevant
+PHP Version: 5.3.4
I also tried the SVN version which doesn't install at all.

However, I will open a separate bug for that.


Previous Comments:
------------------------------------------------------------------------

[2011-02-07 19:51:20] hm2k

Description:
------------
When script is called on certain images, errors occur.

Error checking should be improved so that the functions in the
package calling imagecopyresampled() and imagecopyresized()
check for potential problems and return a (descriptive) error
before the function is called.

Test script:
---------------
<?php
$file=tempnam('','media');

$q='http://www.hpi.co.uk/images/test/15635_0_0.9955380731532122_ORIG.jpg';
@copy($q,$file);
require_once 'Image/Transform.php';
$i =& Image_Transform::factory('');
$i->load($file);
$i->setOption('quality','100');
$i->setOption('scaleMethod','smooth');
$i->fit($width,$height);
$i->save($file,'jpeg');
?>

Expected result:
----------------
[picture]

Actual result:
--------------
Warning: imagecopyresampled() expects parameter 2 to be
resource, null given in
/usr/share/pear/Image/Transform/Driver/GD.php on line 403
Warning: imagecopyresized() expects parameter 2 to be
resource, null given in
/usr/share/pear/Image/Transform/Driver/GD.php on line 406

------------------------------------------------------------------------

Search Discussions

  • Hm2k at Feb 8, 2011 at 12:21 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18249&edit=1

    ID: 18249
    Updated by: hm2k@php.net
    Reported By: hm2k at php dot net
    Summary: expects parameter 2 to be resource, null given
    Status: Open
    Type: Bug
    Package: Image_Transform
    Operating System: CentOS
    Package Version: 0.9.3
    PHP Version: 5.3.4
    Roadmap Versions:
    New Comment:

    After cweiske fixed the bug in packages.xml on the SVN I was able to
    install and test
    the SVN.

    There was no change, the errors are persistent.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-02-08 12:06:12] hm2k

    -Operating System:
    +Operating System: CentOS
    -PHP Version: Irrelevant
    +PHP Version: 5.3.4
    I also tried the SVN version which doesn't install at all.

    However, I will open a separate bug for that.

    ------------------------------------------------------------------------

    [2011-02-07 19:51:20] hm2k

    Description:
    ------------
    When script is called on certain images, errors occur.

    Error checking should be improved so that the functions in the
    package calling imagecopyresampled() and imagecopyresized()
    check for potential problems and return a (descriptive) error
    before the function is called.

    Test script:
    ---------------
    <?php
    $file=tempnam('','media');

    $q='http://www.hpi.co.uk/images/test/15635_0_0.9955380731532122_ORIG.jpg';
    @copy($q,$file);
    require_once 'Image/Transform.php';
    $i =& Image_Transform::factory('');
    $i->load($file);
    $i->setOption('quality','100');
    $i->setOption('scaleMethod','smooth');
    $i->fit($width,$height);
    $i->save($file,'jpeg');
    ?>

    Expected result:
    ----------------
    [picture]

    Actual result:
    --------------
    Warning: imagecopyresampled() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 403
    Warning: imagecopyresized() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 406

    ------------------------------------------------------------------------
  • Hm2k at Feb 8, 2011 at 2:06 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18249&edit=1

    ID: 18249
    Updated by: hm2k@php.net
    Reported By: hm2k at php dot net
    Summary: expects parameter 2 to be resource, null given
    Status: Open
    Type: Bug
    Package: Image_Transform
    Operating System: CentOS
    Package Version: 0.9.3
    PHP Version: 5.3.4
    Roadmap Versions:
    New Comment:

    After some further investigating I have discovered that the image is
    actually a BMP.

    <?php
    $path='http://www.hpi.co.uk/images/test/';
    $file='15635_0_0.9955380731532122_ORIG.jpg';
    $size = getimagesize($path.$file);
    echo $size['mime']; //returns image/x-ms-bmp
    echo $size[2]; //returns 6
    ?>

    It seems that Image_Transforms is unable to handle BMPs, which is likely
    to be
    down to the driver.

    imagecopyresampled() and imagecopyresized() are GD functions, so one
    would
    assume that the problem is in the GD library or another library is
    required when
    handling BMP files.

    There is an article on giving BMP support to GD here:
    http://www.phpro.org/examples/Convert-BMP-to-JPG.html

    This should be incorporated.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-02-08 13:24:21] hm2k

    After cweiske fixed the bug in packages.xml on the SVN I was able to
    install and test
    the SVN.

    There was no change, the errors are persistent.

    ------------------------------------------------------------------------

    [2011-02-08 12:06:12] hm2k

    -Operating System:
    +Operating System: CentOS
    -PHP Version: Irrelevant
    +PHP Version: 5.3.4
    I also tried the SVN version which doesn't install at all.

    However, I will open a separate bug for that.

    ------------------------------------------------------------------------

    [2011-02-07 19:51:20] hm2k

    Description:
    ------------
    When script is called on certain images, errors occur.

    Error checking should be improved so that the functions in the
    package calling imagecopyresampled() and imagecopyresized()
    check for potential problems and return a (descriptive) error
    before the function is called.

    Test script:
    ---------------
    <?php
    $file=tempnam('','media');

    $q='http://www.hpi.co.uk/images/test/15635_0_0.9955380731532122_ORIG.jpg';
    @copy($q,$file);
    require_once 'Image/Transform.php';
    $i =& Image_Transform::factory('');
    $i->load($file);
    $i->setOption('quality','100');
    $i->setOption('scaleMethod','smooth');
    $i->fit($width,$height);
    $i->save($file,'jpeg');
    ?>

    Expected result:
    ----------------
    [picture]

    Actual result:
    --------------
    Warning: imagecopyresampled() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 403
    Warning: imagecopyresized() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 406

    ------------------------------------------------------------------------
  • Hm2k at Feb 8, 2011 at 3:20 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18249&edit=1

    ID: 18249
    Updated by: hm2k@php.net
    Reported By: hm2k at php dot net
    Summary: expects parameter 2 to be resource, null given
    Status: Open
    Type: Bug
    Package: Image_Transform
    Operating System: CentOS
    Package Version: 0.9.3
    PHP Version: 5.3.4
    Roadmap Versions:
    New Comment:

    I had a go at improving the imagecreatefrombmp and bmp2gd functions,
    here's the
    result:

    http://hm2k.googlecode.com/svn/trunk/code/php/functions/imagecreatefrombmp.php

    All you need to do now is handle them.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-02-08 15:09:12] hm2k

    After some further investigating I have discovered that the image is
    actually a BMP.

    <?php
    $path='http://www.hpi.co.uk/images/test/';
    $file='15635_0_0.9955380731532122_ORIG.jpg';
    $size = getimagesize($path.$file);
    echo $size['mime']; //returns image/x-ms-bmp
    echo $size[2]; //returns 6
    ?>

    It seems that Image_Transforms is unable to handle BMPs, which is likely
    to be
    down to the driver.

    imagecopyresampled() and imagecopyresized() are GD functions, so one
    would
    assume that the problem is in the GD library or another library is
    required when
    handling BMP files.

    There is an article on giving BMP support to GD here:
    http://www.phpro.org/examples/Convert-BMP-to-JPG.html

    This should be incorporated.

    ------------------------------------------------------------------------

    [2011-02-08 13:24:21] hm2k

    After cweiske fixed the bug in packages.xml on the SVN I was able to
    install and test
    the SVN.

    There was no change, the errors are persistent.

    ------------------------------------------------------------------------

    [2011-02-08 12:06:12] hm2k

    -Operating System:
    +Operating System: CentOS
    -PHP Version: Irrelevant
    +PHP Version: 5.3.4
    I also tried the SVN version which doesn't install at all.

    However, I will open a separate bug for that.

    ------------------------------------------------------------------------

    [2011-02-07 19:51:20] hm2k

    Description:
    ------------
    When script is called on certain images, errors occur.

    Error checking should be improved so that the functions in the
    package calling imagecopyresampled() and imagecopyresized()
    check for potential problems and return a (descriptive) error
    before the function is called.

    Test script:
    ---------------
    <?php
    $file=tempnam('','media');

    $q='http://www.hpi.co.uk/images/test/15635_0_0.9955380731532122_ORIG.jpg';
    @copy($q,$file);
    require_once 'Image/Transform.php';
    $i =& Image_Transform::factory('');
    $i->load($file);
    $i->setOption('quality','100');
    $i->setOption('scaleMethod','smooth');
    $i->fit($width,$height);
    $i->save($file,'jpeg');
    ?>

    Expected result:
    ----------------
    [picture]

    Actual result:
    --------------
    Warning: imagecopyresampled() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 403
    Warning: imagecopyresized() expects parameter 2 to be
    resource, null given in
    /usr/share/pear/Image/Transform/Driver/GD.php on line 406

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedFeb 8, '11 at 11:03a
activeFeb 8, '11 at 3:20p
posts4
users1
websitepear.php.net

1 user in discussion

Hm2k: 4 posts

People

Translate

site design / logo © 2021 Grokbase