Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.5

Bug #18249 expects parameter 2 to be resource, null given
Submitted: 2011-02-08 00:51 UTC
From: hm2k Assigned:
Status: Open Package: Image_Transform (version 0.9.3)
PHP Version: 5.3.4 OS: CentOS
Roadmaps: (Not assigned)    
Subscription  


 [2011-02-08 00:51 UTC] hm2k (James Wade)
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

Comments

 [2011-02-08 17:06 UTC] hm2k (James Wade)
-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-08 18:24 UTC] hm2k (James Wade)
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 20:09 UTC] hm2k (James Wade)
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 21:22 UTC] hm2k (James Wade)
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.