Adding new ImageFormats to ImageSharp in Umbraco
# help-with-other
s
Following up on https://discord.com/channels/869656431308189746/1242801621394788402/1242801621394788402, I've managed to create a new decoder for PDF files in ImageSharp, based on PdfLibCore. It works in my console app when testing, converting pdfs to jpgs. Now I need to get it working in Umbraco. I've tried adding
Copy code
var config = Configuration.Default.Clone();
    config.Configure(new PdfConfigurationModule());
into an IComposer - but that didn't do anything. Also tried adding a notificationhandler listening for the ApplicationStarted notification, so I could inject the Configuration object into that, and then Configure my ConfigurationModule. No luck either. Anyone know what else I can do? You can see my source code here: https://github.com/skttl/ImageSharpCommunity.Format.Pdf I intend to release it on nuget, just need to get it working 🙂
m
I've used the approach here https://github.com/umbraco/Umbraco-CMS/discussions/11938#discussioncomment-2654842 to register IImageWebProcessors.
Copy code
public class OverlayWebProcessorComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IImageWebProcessor, OverlayWebProcessor>());
    }
}
not sure it's of any use...
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<SixLabors.ImageSharp.Formats.IImageFormat, PdfFormat>());
??
s
Seems like my take is actually working, but then something inside the decoder breaks (although it doesn't break in my console app).
Fixed it - nuget package coming 🙂 https://github.com/skttl/ImageSharpCommunity.Formats.Pdf
12 Views