I am using a series of imagecache_actions which work and then adding a final step whichis a Custom Action. I tried different image* functions on the $image object and none had any effect. So I sent a printout of the $image (and $image_context) to watchdog to see what I had:

stdClass::__set_state(array( 'source' => 'public://dbd10734089_361846880653185_905949197324848334_n.jpg', 'info' => array ( 'width' => 500, 'height' => 500, 'extension' => 'png', 'mime_type' => 'image/png', 'file_size' => 23551, ), 'toolkit' => 'gd', 'resource' => NULL, ))

Problem seems to be that $image->resource == NULL. I am expecting it to be a GD image resource which can be passed around to other GD functions, finally returning TRUE from the function.

Comments

tomotomo created an issue. See original summary.

tomotomo’s picture

I also tried a new style with only one action, the Custom Action. Still no resource, but at least it's not due to some other action interfering.

dman’s picture

yes, the $resource should be a handle on a GD object.
I can't tell what could have made this happen for you, but my first suspicion is a corrupt or unreadable image. The data says the system thinks your png was exactly 500 px square - does that seem correct?
Have you tried with other (smaller) images like jpegs?

fietserwin’s picture

- Are you using PHP5.5? If so, issue #2215369: Various bugs with PHP 5.5 imagerotate(), including when incorrect color indices are passed in might have gotten into your way.
- Can you try to call the custom action as first effect and see if you have a valid resoucv on that moment?
- Can you remove the custom action and see if you get image derivatives as expected.

tomotomo’s picture

- Are you using PHP5.5? If so, issue #2215369: PHP 5.5 imagerotate() fails when incorrect color indices are passed in might have gotten into your way.

This is on PHP 5.6. But I'm not using any kind of rotate actions anyways.

- Can you try to call the custom action as first effect and see if you have a valid resoucv on that moment?

I tried it as the only action but it did not change anything.

- Can you remove the custom action and see if you get image derivatives as expected.

Other actions alone work fine.

fietserwin’s picture

Category: Bug report » Support request
Priority: Major » Normal

I tested it locally wit this style:

a:3:{s:4:"name";s:12:"test-2629310";s:5:"label";s:12:"test-2629310";s:7:"effects";a:1:{i:261;a:3:{s:4:"name";s:24:"imagecache_customactions";s:4:"data";a:1:{s:3:"php";s:188:"watchdog('image styles', 'Image: ' . print_r($image, TRUE), NULL, WATCHDOG_DEBUG);
watchdog('image styles', 'Context: ' . print_r($image_context, TRUE), NULL, WATCHDOG_DEBUG);
return TRUE;";}s:6:"weight";s:1:"1";}}}

And this is what I see in the watchdog:
Image: stdClass Object ( [source] => modules/image/sample.png [info] => Array ( [width] => 800 [height] => 600 [extension] => png [mime_type] => image/png [file_size] => 168110 ) [toolkit] => gd [resource] => Resource id #395 )

Context: Array ( [effect_data] => Array ( [php] => watchdog('image styles', 'Image: ' . print_r($image, TRUE), NULL, WATCHDOG_DEBUG); watchdog('image styles', 'Context: ' . print_r($image_context, TRUE), NULL, WATCHDOG_DEBUG); return TRUE; ) [managed_file] => [referring_entities] => Array ( ) [entity] => [image_field] => )

So with the sample image it works. then I tested it with a normal image and that gave comparable results, so that also works.

Thus, the image must come as NULL into the effect, making it a possible problem in your installation, not an error in this module. I guess that the error is in opening the image. Try to debug that part of Drupal (function image_gd_load).

fietserwin’s picture

Status: Active » Closed (cannot reproduce)

I guess this has been solved by now. Feel free to reopen if not, adding any additional info possible.