Skip to content

SixLabors.ImageSharp.UnknownImageFormatException: Width or height cannot be 0 #1205

@americanslon

Description

@americanslon

Description

I am getting the above error on using (var image = Image.Load(inStream))

Steps to Reproduce

async Task Upload(IMatFileUploadEntry file)
    {
        if (file != null)
        {
            byte[] bytes;
            using (var inStream = new MemoryStream())
            {
                await file.WriteToStreamAsync(inStream);

                using (var outStream = new MemoryStream())
                using (var image = Image.Load(inStream))
                {
                    image.Mutate(x => x.Resize(new ResizeOptions
                    {
                        Size = new SixLabors.ImageSharp.Size(Settings.LOGO_LENGTH, Settings.LOGO_HEIGHT),
                        Mode = ResizeMode.Pad
                    }).BackgroundColor(new Color(new Rgba32(255, 255, 255, 1))));

                    image.SaveAsPng(outStream);

                    bytes = outStream.ToArray();
                    Item.Icon = Convert.ToBase64String(bytes);
                    Console.WriteLine(Item.Icon);
                }
            }
        }

System Configuration

Blazor WASM.
The image is coming from https://www.matblazor.com/FileUpload.

  • ImageSharp version: 1.0.0-beta0008
  • Environment (Operating system, version and so on): Win 10
  • .NET Framework version: netstandard 2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions