Beispiel #1
0
        public IImageFormat DetectFormat(Stream stream)
        {
            var internalFormat = Image.DetectFormat(stream);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
Beispiel #2
0
        public async Task <IImageFormat> DetectFormatAsync(Stream stream)
        {
            var internalFormat = await Image.DetectFormatAsync(stream);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
Beispiel #3
0
        public IImageFormat FindFormatByExtension(string extension)
        {
            var internalFormat = FindInternalImageFormat(extension);

            if (internalFormat != null)
            {
                return(ImageSharpUtility.CreateFormat(internalFormat));
            }

            return(null);
        }
Beispiel #4
0
        public override IImageEncoder CreateEncoder()
        {
            if (QuantizationMethod != null || ColorTableMode != null)
            {
                return(new GifEncoder
                {
                    ColorTableMode = (SharpGifColorTableMode?)ColorTableMode,
                    Quantizer = ImageSharpUtility.CreateQuantizer(QuantizationMethod)
                });
            }

            return(base.CreateEncoder());
        }
Beispiel #5
0
        public override IImageEncoder CreateEncoder()
        {
            if (BitDepth != null ||
                ColorType != null ||
                CompressionLevel != null ||
                Gamma != null ||
                Threshold != null ||
                QuantizationMethod != null ||
                InterlaceMode != null ||
                ChunkFilter != null ||
                TransparentColorMode != null ||
                IgnoreMetadata)
            {
                var encoder = new PngEncoder
                {
                    BitDepth        = (SharpPngBitDepth?)BitDepth,
                    ColorType       = (SharpPngColorType?)ColorType,
                    Gamma           = Gamma,
                    InterlaceMethod = (SharpPngInterlaceMode?)InterlaceMode,
                    ChunkFilter     = (SharpPngChunkFilter?)ChunkFilter,
                    Quantizer       = ImageSharpUtility.CreateQuantizer(QuantizationMethod),
                    IgnoreMetadata  = IgnoreMetadata
                };

                if (TransparentColorMode != null)
                {
                    encoder.TransparentColorMode = (SharpPngTransparentColorMode)TransparentColorMode.Value;
                }

                if (CompressionLevel != null)
                {
                    encoder.CompressionLevel = (SharpPngCompressionLevel)CompressionLevel;
                }

                if (Threshold != null)
                {
                    encoder.Threshold = Threshold.Value;
                }

                return(encoder);
            }

            return(base.CreateEncoder());
        }
Beispiel #6
0
 public SharpImage(Image image, SharpFormat sharpFormat)
     : this(image, ImageSharpUtility.CreateFormat(sharpFormat))
 {
 }
Beispiel #7
0
 public SharpImageInfo(SixLabors.ImageSharp.IImageInfo info, SixLabors.ImageSharp.Formats.IImageFormat format)
 {
     _info   = info;
     _format = ImageSharpUtility.CreateFormat(format);
 }