365
//https://github.com/JimBobSquarePants/ImageProcessor/blob/6092da59e9aa4975e564002ef3c782a8f6bf3384/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/WebPFormat.cs
1
using System;
2
using System.Net;
3
using System.Collections.Generic;
4
using System.IO;
5
using System.Drawing;
6
using System.Linq;
7
using System.Diagnostics;
8
9
public class Program
10
{
11
//https://stackoverflow.com/questions/111345/getting-image-dimensions-without-reading-the-entire-file/60667939#60667939
12
//DecodeWebP reads only lossless :(
13
14
//My version improves DecodeWebP to read all webp formats, lossy, lossless and extended!
15
//https://metadataconsulting.blogspot.com/2020/09/CSharp-dotNET-How-to-get-Animation-Alpha-EXIF-ICC-flags-from-header-of-WebP-image-file-partially-loaded-file.html
16
17
internal static class ImageHelper
18
{
19
const string errorMessage = "Could not recognise image format.";
20
21
private static Dictionary<byte[], Func<BinaryReader, Size>> imageFormatDecoders = new Dictionary<byte[], Func<BinaryReader, Size>>()
22
{
23
{ new byte[] { 0x42, 0x4D }, DecodeBitmap },
24
{ new byte[] { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }, DecodeGif },
Cached Result