Unknown/unhandled image type

Unknown/unhandled image type

by Alireza Meshkin Mehr -
Number of replies: 16
I'm making badges in Moodle 2.8 and inside Moodle everything is OK. But when I'm trying to upload those badges into my backpack, I receive the error "Unknown/unhandled image type"  . I've made badges through my practice course in learn.moodle.net and it was completely working. Could anyone help me please ? smile
Average of ratings: -
In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -
Any answers ?!
In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

What type of image file is it? I googled and found this error message occurs with certain SVG file types when you try to upload them.

In reply to Mary Cooch

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -

It's PNG. I think something happens after issuing the badge. Because even windows explorer couldn't view the image then. The error message also seems to have problem with the image itself. 

In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

So to go through step by step (more for badges experts than for me!):

  1. You made a badge on your practice course and it is a PNG
  2. You awarded it to yourself?
  3. You then went to My profile>Badges, connected to an external backpack 
  4. And then...?
In reply to Mary Cooch

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -

And while it was trying to transfer the badge (or in case of manual uploading of the badge) to the backpack, I received the error "Unknown/unhandled image type"  . It seems that Moodle has done something to the image file so it is now unrecognizable in both Mozilla backpack and the Windows explorer itself! 


In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
How did you download your badge from Learn Moodle? Did you click the download link or did you right-click on the badge?
In reply to Mary Cooch

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -

Of course I downloaded it.

In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

What do you mean by "unrecognisable in Windows explorer"? The reason I asked about the method of downloading is that badges work fine when you click the "download" button but some people (not you smile ) mistakenly think it is OK to right-click the badge and do "Save as..." and download the badge image that way - which doesn't work properly.  I downloaded your badge image and it displays fine for me outside of Learn Moodle on my desktop so that is why I am asking about "unrecognisable in Windows explorer". I also hope some more knowledgeable backpack experts come along to help you, as this is not an area I am familiar with ;)

In reply to Mary Cooch

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -
Dear Mary, I really thank you for your kind and supporting replies. It's highly appreciated. First, I have to state that the badge that I have created in my practice course was working properly. As I mentioned in my first post, the problem occurred while making badges with my own Moodle site which I set up for more practicing with Moodle . 

By "Not recognizable with Windows explorer", I mean that I can't view the badge on my computer (e.g. by windows picture viewer etc.) . I think it shows that there should be something wrong with the process of making that badge within Moodle. 

I attached the badge here if it could help. 

Thanks again

In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Ah I see - I misunderstood you blush So you are not able to upload badges from your own Moodle site,  nothing to do with Learn Moodle. Can you add png images in other places on your own Moodle? We shall have to wait for others here because I am out of ideas in this area, with which I am  not familiar. It's true I can't open your png badge here either. 

In reply to Mary Cooch

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -
 Yes Mary, I can add PNG images to that Moodle site. Thank you very much for the support. Hope someone would help.   


Attachment 330.png
In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Simon Coggins -

I took a look at that file in a hex editor and instead of containing an image it contains the HTML of a webpage, including this error:

Warning: readfile(http://titwo.co/elearning/moodle/pluginfile.php?forcedownload=1&file=%2F5%2Fbadges%2Fuserbadge%2F10%2F55f4ab46cdbd929eb447de35d8ebef50ac30c264): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in D:\HostingSpaces\titwo.co\titwo.co\wwwroot\elearning\moodle\badges\badge.php on line 44

so there is definitely something going wrong with the badge creation process. I'm not sure at this stage whether it is a (windows specific?) badges bug, server permissions issue or something else.

Hopefully Yuliya (the component lead for Badges) will have some time in the next couple of days to take a look. At the very least it looks like the error handling could do with some improvement to explain that something went wrong rather than generating a bad badge file.

It would probably make sense to file a bug and include a copy of the badge in the Moodle tracker.

Simon

In reply to Simon Coggins

Re: Unknown/unhandled image type

by Simon Coggins -

Ok, so interestingly, when I tried to access the URL in the error above it worked:

http://titwo.co/elearning/moodle/pluginfile.php?forcedownload=1&file=%2F5%2Fbadges%2Fuserbadge%2F10%2F55f4ab46cdbd929eb447de35d8ebef50ac30c264

The file is there and the url being accessed is correct.

Therefore it seems to be most likely to be due to a server configuration issue causing readfile() to fail on urls. You should check the 'allow_url_fopen' setting in your php.ini file. It needs to be enabled for that call to work.

I must confess I'm a bit surprised that an external url is being passed to readfile like that. It seems like it would be better to generate a file system path.

Either way I still think it would pay to report this as a bug as some code changes are most likely required.

Simon


In reply to Simon Coggins

Re: Unknown/unhandled image type

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Simon,
the bug already exists in the Tracker: MDL-47085.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: Unknown/unhandled image type

by Alireza Meshkin Mehr -
Dear Simon &  Matteo, 

I checked the bug report on Tracker. It seems that they have fixed the issue, am I right ? I'm not that much familiar with server and network things and I'm wondering if you could help me with what I should do to solve the problem on my installed version. It'd be highly appreciated if you explain the steps to take, in a clearer way. 

Thanks in advance


In reply to Alireza Meshkin Mehr

Re: Unknown/unhandled image type

by Simon Coggins -

Hi,

It's not fixed quite yet, Yuliya created a patch today and it is currently working through Moodle's review and testing process. Hopefully the fix will be included in the next Moodle point release.

As for your next steps the best thing would be to wait until the next point release (due around Mid-march I think) and then upgrade your site.

Alternatively if you can't wait or are running an unsupported version you could ask your system administrator to apply the patch for this specific issue from the bug. If you are going to do that I'd probably wait until the review and testing process has finished in case any changes are needed.

Simon


Average of ratings: Useful (1)