Hi,
I'm having an issue when trying to manipulate a facebook image using imageprocessor web I get an "Input stream not a supported format" exception. Example url:
/remote.axd?https://external.xx.fbcdn.net/safe_image.php?d=AQDA9W98lWDqbw_J&url=https%3A%2F%2Fwww.facebook.com%2Fads%2Fimage%2F%3Fd%3DAQIUo-bMpMJ8HpStbTYWpoZ4VV5R8vuGRdKtUTwLnf5fEB84xPzsPsqyIAzQF3XNpGgKaMeg1fY1lg-oYGWcPNjX56ALRncQ95FDLDVijKu4LdMYROn_o1XfYU3SFY2Bv__Nt_eFGn8nBwNCnQUruSNj?width=640&height=640&mode=crop
I get the same error with all facebook cdn images I've tried. I have added domains to whitelist and it works with other remote images. Using imageprocessor.web version 4.6.4
Upgrade to the newly released 4.6.5, that correctly handles encoded urls and I've tested it against examples I've been given.
https://www.nuget.org/packages/ImageProcessor.Web/4.6.5
Let me know if you still have issues.
Thanks. I updated but still get the same error. Copy/Pasted the example path above into the browser. Do I need to urlencode some part of the path?
Please accept my apologies. I thought I'd managed to cover all potential urls with the fix for #478 but I was mistaken.
I've just pushed ImageProcessor .Web version 4.6.6 which I have successfully tested against your url.
This uses the value
<add url="external.xx.fbcdn.net/"/>
to security.config
Thank you for your perseverance, I really appreciate it.
No problem, thank you for the quick fix and also for a great job with ImageProcessor.
Now the URL in my first example works fine, but I'm very sorry to say there are more that don't work.. same error. A few examples:
/remote.axd?https://external.xx.fbcdn.net/safe_image.php?d=AQBgV2Q_yDUlNQKs&url=http%3A%2F%2Fresources.mynewsdesk.com%2Fimage%2Fupload%2Ft_open_graph_image%2Fdt1us8xdnvg0c89cvw7x.jpg?width=640&height=640&mode=crop
/remote.axd?https://external.xx.fbcdn.net/safe_image.php?d=AQDCcTPqv8CwPELI&url=http%3A%2F%2Fmedia.basetool.se%2FProductImage%2F232532%2F1005%2F3%2F383255%2F1024?width=640&height=640&mode=crop
/remote.axd?https://external.xx.fbcdn.net/safe_image.php?d=AQC1EQ3K-H1_Hzm5&url=https%3A%2F%2Fwww.facebook.com%2Fads%2Fimage%2F%3Fd%3DAQJXM8cUVeFoknqL1ybezGBvidYsVfL4LB0DdcNApWEfOCY1RajT0j29T60G44IZY7EEtG_K2hdJaXbTUh947Ci6Rn5gyYT_9YGv3yRC9etUbM0Sfrs-6XeVLiK5MqHqh5WY11V83lccne07v7zOzuZr?width=640&height=640&mode=crop
What's the error message? What generates these urls because they are mental.
To be honest this all seems back to front to me. Why move the burden of processing from Facebooks millions of servers to yours?
These image urls are generated when pulling data from the facebook graph api. The reason for resizing images locally is that the facebook proxy doesn't officially (or inofficially?) support requesting images in custom sizes.
Perhaps I could resolve this easier by writing my own ImageService and parse the strange urls myself?
Edit: Exception is "Input stream not a supported format" like before
Ok... That all makes sense. Thanks!
What we need to do is extract the url parsing code from the HttpModule into its own static class. That way we can unit test it properly. Unfortunately I'm going to be away for a couple of weeks far away from computers so I won't be able to do anything.
I'll reopen this issue and if you have the opportunity to open a PR that would be very much appreciated.
After some research it turns out this is not an issue with url parsing. Facebook returns a redirect response to "http://www.facebook.com/unsuportedbrowser" which ofcourse causes an "Input stream not a supported format" exception. The strange thing is that facebook does not always return this response. If you load the remote image url in your browser first and then request it with imageprocessor it works! But understanding the inner workings of facebook is not this issues goal.
I've made a pullrequest for adding a new settings called Useragent to the remoteimageservice. It's not perfect since you might want different useragents for different hosts. https://github.com/JimBobSquarePants/ImageProcessor/pull/490
Wow! That's really interesting to discover, thanks for investigating further.
I'll have a look at your PR when I'm back on a computer (been in Africa the last two weeks) and look to get it merged. What default useragent string did you use?
Ok, great. I've just used the one from my current browser. http://www.useragentstring.com/
Fixed and released