public static void Run()
        {
            // ExStart:ConvertWMFToWebp
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing WMF image
            using (Image image = Image.Load(dataDir + "input.wmf"))
            {
                // Calculate new Webp image height
                double k = (image.Width * 1.00) / image.Height;

                // Create an instance of EmfRasterizationOptions class and set different properties
                EmfRasterizationOptions emfRasterization = new EmfRasterizationOptions
                {
                    BackgroundColor = Color.WhiteSmoke,
                    PageWidth = 400,
                    PageHeight = (int)Math.Round(400 / k),
                    BorderX = 5,
                    BorderY = 10
                };

                // Create an instance of WebPOptions class and provide rasterization option
                ImageOptionsBase imageOptions = new WebPOptions();
                imageOptions.VectorRasterizationOptions = emfRasterization;

                // Call the save method, provide output path and WebPOptions to convert the WMF file to Webp and save the output
                image.Save(dataDir + "ConvertWMFToWebp_out.webp", imageOptions);
            }
            // ExEnd:ConvertWMFToWebp
        }
        public static void Run()
        {
            // ExStart:ConvertWMFToWebp
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an existing WMF image
            using (Image image = Image.Load(dataDir + "input.wmf"))
            {
                // Calculate new Webp image height
                double k = (image.Width * 1.00) / image.Height;

                // Create an instance of EmfRasterizationOptions class and set different properties
                EmfRasterizationOptions emfRasterization = new EmfRasterizationOptions
                {
                    BackgroundColor = Color.WhiteSmoke,
                    PageWidth       = 400,
                    PageHeight      = (int)Math.Round(400 / k),
                    BorderX         = 5,
                    BorderY         = 10
                };

                // Create an instance of WebPOptions class and provide rasterization option
                ImageOptionsBase imageOptions = new WebPOptions();
                imageOptions.VectorRasterizationOptions = emfRasterization;

                // Call the save method, provide output path and WebPOptions to convert the WMF file to Webp and save the output
                image.Save(dataDir + "ConvertWMFToWebp_out.webp", imageOptions);
            }
            // ExEnd:ConvertWMFToWebp
        }
        public static void Run()
        {
            //ExStart:ExportToWebP
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WebPImages();

            // Create an instance of image class.
            using (Image image = Image.Load(dataDir + "SampleImage1.bmp"))
            {
                // Create an instance of WebPOptions class and set properties
                WebPOptions options = new WebPOptions();
                options.Quality  = 50;
                options.Lossless = false;
                image.Save(dataDir + "ExportToWebP_out.webp", options);
            }
            //ExEnd:ExportToWebP
        }
        public static void Run()
        {
            // ExStart:ExportToWebP
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WebPImages();

            // Create an instance of image class.
            using (Image image = Image.Load(dataDir + "SampleImage1.bmp"))
            {
                // Create an instance of WebPOptions class and set properties
                WebPOptions options = new WebPOptions();
                options.Quality = 50;
                options.Lossless = false;
                image.Save(dataDir+ "ExportToWebP_out.webp", options);
            }
            // ExEnd:ExportToWebP
        }
        public static void Run()
        {
            // ExStart:CreatingWebPImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WebPImages();

            // Create an instance of WebPOptions class and set properties
            WebPOptions imageOptions = new WebPOptions();
            imageOptions.Lossless = true;
            imageOptions.Source = new FileCreateSource(dataDir + "CreatingWebPImage_out.webp", false);

            // Create an instance of image class by using WebOptions instance that you have just created.
            using (Image image = Image.Create(imageOptions, 500, 500))
            {
                image.Save();
            }
            // ExEnd:CreatingWebPImage
        }
Пример #6
0
        public static void Run()
        {
            //ExStart:CreatingWebPImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WebPImages();

            // Create an instance of WebPOptions class and set properties
            WebPOptions imageOptions = new WebPOptions();

            imageOptions.Lossless = true;
            imageOptions.Source   = new FileCreateSource(dataDir + "CreatingWebPImage_out.webp", false);

            // Create an instance of image class by using WebOptions instance that you have just created.
            using (Image image = Image.Create(imageOptions, 500, 500))
            {
                image.Save();
            }
            //ExEnd:CreatingWebPImage
        }
Пример #7
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_WebPImages();

            Console.WriteLine("Running example OptimizationStrategyInWebP");

            var imageOptions = new WebPOptions();

            imageOptions.Source = new FileCreateSource("created.webp", false);

            imageOptions.BufferSizeHint = 50;

            using (Image image = Image.Create(imageOptions, 1000, 1000))
            {
                // Do something with the created image
                image.Save();
            }

            Console.WriteLine("Finished example OptimizationStrategyInWebP");
        }
        public static void Run()
        {
            // ExStart:CreatingWebPImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WebPImages();

            // Create an instance of WebPOptions class
            WebPOptions imageOptions = new WebPOptions();

            // Set LossLess property
            imageOptions.Lossless = true;

            // Set Source property with the path and image file name where you want to create the WebP image.
            imageOptions.Source = new Sources.FileCreateSource(dataDir + "CreatingWebPImage_out.webp", false);

            // Create an instance of image class by using WebOptions instance that you have just created.
            using (Image image = Image.Create(imageOptions, 500, 500))
            {
                // Save the image.
                image.Save();
            }
            // ExEnd:CreatingWebPImage
        }