Title: Is it possible to read WebP images into a C# Bitmap object?
Tags: c#;.net;asp.net-core;webp
Question: I am using .NET Core 3.0 MVC app with a file upload for users. These files assumed to be an image, but for obvious reasons, I validate the image before saving it to the server.
Now I have ran into an issue, when a user tries to upload a JPEG image (which seems to be fine as he had to email it to me for further inspection) and this image seems to be a WebP image or was converted from a WebP Image.
The issue is that one of the check for each image is
using (var bitmap = new Bitmap(postedFile.OpenReadStream()))
This threw an exception "Parameter is not valid" and because of this, validation fails.
If I read the buffer of the uploaded IFromFile, it starts with RIFFڶ\0\0WEBPVP8
This is how I knew, this is not a normal image.
Any way to decode or validate this image as any other?
Comment: Do you actually need to read the image? WebP is not supported by `Bitmap`. [There are libraries which can](https://stackoverflow.com/q/7566426/215552), but if you don't actually need to manipulate the image, I suggest just looking at the `Content-Type` HTTP header.

Comment: I dont think `Content-Type` and `Header` would be enough to check if the file is valid. I check those libraries though. Thanks

Comment: From [here](https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/types-of-bitmaps?view=netframework-4.8), you can find the supported formats are BMP, GIF, EXIF, JPEG, PNG and TIFF.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:12/31/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c#><.net><asp.net-core><webp>', 'Title': 'Is it possible to read WebP images into a C# Bitmap object?', 'ViewCount': 2130, 'id': 59545316, 'user_AboutMe': '<p>Currently studying in a London University, but I will graduate next month. I am looking to start working preferably with <code>MVC</code> <code>C#</code>. Always trying to keep up with emerging technologies and very interested in drone technology.</p>\n', 'user_AccountId': 5496579.0, 'user_DisplayName': 'Sugafree', 'user_Reputation': 601.0, 'user_Views': 88.0, 'user_id': 4367493.0}}