System.Runtime.InteropServices.COMException at PhotoSauce.MagicScaler.WicPlanarCache.loadBuffer #118
-
Hey, I get an image byte array which I convert to stream and use in the BuildPipeline method. if (query.FileFormat == RequestFileFormat.Webp)
{
CodecManager.Configure(codecs => { codecs.UseLibwebp(); });
settings.TrySetEncoderFormat(ImageMimeTypes.Webp);
}
using var outputStream = new MemoryStream();
await Task.Run(() =>
{
Stream stream = new MemoryStream(bytes);
using var pipeline = MagicImageProcessor.BuildPipeline(stream, settings);
if (query.Blur.HasValue)
{
pipeline.AddTransform(new GaussianBlurTransform(radius: query.Blur.Value));
}
pipeline.WriteOutput(outputStream);
pipeline.Dispose();
});
var imageBytes = outputStream.ToArray();
await outputStream.DisposeAsync(); Do you have any idea what can be the problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The error code you have there is This isn't likely related to your error, but in your sample code, |
Beta Was this translation helpful? Give feedback.
The error code you have there is
WINCODEC_ERR_BADIMAGE
, indicating the Windows JPEG codec found invalid image data. The most likely cause is simply a corrupted image file, but you may have a concurrency issue somewhere else leading to a corrupted or truncated input stream. Without a full repro, that's the best guess I can make.This isn't likely related to your error, but in your sample code,
CodecManager.Configure()
is used incorrectly. That method should be called only once, during application startup. Each time that method is called, the list of codec plugins has to be rebuilt and replaced, which is very expensive to do for each WebP output you create.