Open TIFF image: SixLabors.ImageSharp.UnknownImageFormatException
Hi @ststeiger ! Help me please! When i try to open TIFF image i get exception: SixLabors.ImageSharp.UnknownImageFormatException
Exception:
SixLabors.ImageSharp.UnknownImageFormatException: Image cannot be loaded. Available decoders:\r\n - PNG : PngDecoder\r\n - BMP : BmpDecoder\r\n - TGA : TgaDecoder\r\n - GIF : GifDecoder\r\n - JPEG : JpegDecoder\r\n\r\n at SixLabors.ImageSharp.Image.Load[TPixel](Configuration configuration, Stream stream, IImageFormat& format)\r\n at SixLabors.ImageSharp.Image.Load[TPixel](Stream stream, IImageFormat& format)\r\n at PdfSharpCore.Utils.ImageSharpImageSource
1.FromStreamImpl(String name, Func1 imageStream, Nullable1 quality)\r\n at MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes.ImageSource.FromStream(String name, Func1 imageStream, Nullable1 quality)\r\n at PdfSharpCore.Drawing.XImage..ctor(Func1 stream)\r\n at PdfSharpCore.Drawing.XImage.FromStream(Func`1 stream)\r\n at PdfConverter.Core.Services.ImgConverter.Convert(Byte[] content)
using (var imageStream = new MemoryStream(content))
using (var pdfStream = new MemoryStream())
{
var doc = new PdfDocument();
XImage image = XImage.FromStream(() => imageStream); // -->throw Exception
PdfPage page = doc.AddPage();
XGraphics xGraphics = XGraphics.FromPdfPage(page);
page.Width = image.PixelWidth;
page.Height = image.PixelHeight;
xGraphics.DrawImage(image, 0, 0, image.PixelWidth, image.PixelHeight);
doc.Save(pdfStream, false);
var resultBase64 = System.Convert.ToBase64String(pdfStream.ToArray());
stopwatch.Stop();
result = new Result()
{
ConvertedDocument = resultBase64,
PagesCount = doc.PageCount,
ServerTiming = stopwatch.ElapsedMilliseconds,
};
}
I think ImageSharp doesn't support TIFF. See https://github.com/SixLabors/ImageSharp/issues/12
There's a TIFF-encoder and decoder for ImageSharp : https://github.com/ChrisVanDijk/ImageSharp-Tiff
I think ImageSharp doesn't support TIFF. See SixLabors/ImageSharp#12
There's a TIFF-encoder and decoder for ImageSharp : https://github.com/ChrisVanDijk/ImageSharp-Tiff
thx. you helped me a lot
I think ImageSharp doesn't support TIFF. See SixLabors/ImageSharp#12
There's a TIFF-encoder and decoder for ImageSharp : https://github.com/ChrisVanDijk/ImageSharp-Tiff
Apparently ImageSharp now has support for Tiff images according to that issue but I still get the same exception as OP. PdfSharpCore 1.3.13