protected override FilterContext CreateFilterContext(ProcessingPipelineContext context)
        {
            IImageFormat targetFormat = null;

            if (context.ImageWizardOptions.UseAcceptHeader)
            {
                //try to use mime type from accept header
                targetFormat = ImageFormatHelper.FirstOrDefault(context.AcceptMimeTypes);
            }

            if (targetFormat == null)
            {
                //use mime type of the original image
                targetFormat = ImageFormatHelper.FirstOrDefault(context.Result.MimeType);
            }

            SKBitmap bitmap = SKBitmap.Decode(context.Result.Data);

            if (context.ImageWizardOptions.UseClintHints)
            {
                if (context.ClientHints.DPR != null)
                {
                    string method = $"dpr({context.ClientHints.DPR.Value.ToString("0.0", CultureInfo.InvariantCulture)})";

                    //url_filters.Insert(0, method);
                }
            }

            return(new SkiaSharpFilterContext(context, bitmap, targetFormat));
        }
Esempio n. 2
0
        protected override FilterContext CreateFilterContext(ProcessingPipelineContext context)
        {
            Image image = Image.Load(context.Result.Data);

            IImageFormat targetFormat = null;

            if (context.ImageWizardOptions.UseAcceptHeader)
            {
                targetFormat = ImageFormatHelper.FirstOrDefault(context.AcceptMimeTypes);
            }

            if (targetFormat == null)
            {
                targetFormat = ImageFormatHelper.FirstOrDefault(context.Result.MimeType);
            }

            return(new ImageSharpFilterContext(context, image, targetFormat));
        }
Esempio n. 3
0
        protected override FilterContext CreateFilterContext(ProcessingPipelineContext context)
        {
            IImageFormat targetFormat = null;

            if (context.ImageWizardOptions.UseAcceptHeader)
            {
                //try to use mime type from accept header
                targetFormat = ImageFormatHelper.FirstOrDefault(context.AcceptMimeTypes);
            }

            if (targetFormat == null)
            {
                //use mime type of the original image
                targetFormat = ImageFormatHelper.FirstOrDefault(context.Result.MimeType);
            }

            SKBitmap bitmap = SKBitmap.Decode(context.Result.Data);

            return(new SkiaSharpFilterContext(context, bitmap, targetFormat));
        }