It took me a little while that it was a faulty JPG (invalid markers) that made the Panel crash (Kirby 2.5.7)
get_resource_type() expects parameter 1 to be resource, null given
– this is the log in Debug mode. In non-Debug mode, the panel just freezes, so your’re unable to save / exit / delete the faulty files.
I am not sure if this qualifies as ‘bug’ (it’s the JPGs that are faulty after all), that’s why I am posting it here. But it would to be great – especially for clients – to get a warning, (e.g. “invalid file”), instead of the whole panel just crashing.
Thanks for your feedback. I just tested, and the files seem to work fine with imageoptim – however, I can’t open them with Photoshop (Error message). I’ve also tried running a mogrify command, and get the following errors:
mogrify: profile 'icc': 'CMYK': invalid ICC profile color space 'ardhamatsyendrasana.png' @ warning/png.c/MagickPNGWarningHandler/1709.
mogrify: Unknown Adobe color transform code 2 'janushirshasana-2.jpg' @ warning/jpeg.c/JPEGWarningHandler/365.
I probably won’t go through the hassle of setting up Simle Image locally, as it’s really just about 3 faulty images in my case; I just thought I’d report it to the forum, as the bug causes a nasty crash of the panel.
When I try to output these images with a frontend template, I’m basically getting the exact same error as in the panel:
Whoops\Exception\ErrorException thrown with message "get_resource_type() expects parameter 1 to be resource, null given"
#2 Whoops\Exception\ErrorException in /Users/ld/Documents/git/testsite.com/kirby/vendor/getkirby/toolkit/vendors/abeautifulsite/SimpleImage.php:57
#1 get_resource_type in /Users/ld/Documents/git/testsite.com/kirby/vendor/getkirby/toolkit/vendors/abeautifulsite/SimpleImage.php:57
#0 abeautifulsite\SimpleImage:__destruct in [internal]:0
– this is in Debug Mode; if I disable the Debug mode, all images are displayed, but the faulty ones are not resized, as opposed to other “non-faulty” JPGs.
As a work around, If you can get the image to open in a graphics program, save it as RGB and try again with Kirby. I see you tried Photoshop but give Gimp or Affinity Photo a try. ImageOptim seemed to like it, so maybe try the result of imageoptim in Kirby rather then the source file.
Ive had issues my self with CMYK images in general (not with Kirby, but in general the common libraries used by most CMS system can get a bit funny with CMYK images).
Feel free to send me your source file, i’m happy to have a mess with it.
I agree with @texnixe – I myself can find ways to fix a corrupted image, but that’s not an option for the client / editor, who thinks he “broke” the CMS. It’s not a big deal for those three images, I can convert them for the client; but it would be great to have a future proof fallback (e.g. an explcit error code “Invalid file” or “unable to process file”) if that happens again.
@anteante I was just googling around and found this plugin. It might fix your image on upload in the same way that ImageOptim was happy to do so. Ive got a hunch that it talks straight to GD, without simple image but i’m not sure. Worth a shot i guess. I think a minor tweak to it will have it save as RGB.
@anteante Could you please send me the faulty file for testing? I can’t reproduce this with a completely invalid file (in my case a PDF that I renamed to .jpg), so it looks like it needs to be a JPG that is basically valid but not completely valid.