当前位置: 首页>>代码示例>>C#>>正文


C# MagickImage.Strip方法代码示例

本文整理汇总了C#中ImageMagick.MagickImage.Strip方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Strip方法的具体用法?C# MagickImage.Strip怎么用?C# MagickImage.Strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageMagick.MagickImage的用法示例。


在下文中一共展示了MagickImage.Strip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        private static void Process(int width, int height, MagickImage image, int? quality)
        {
            image.Strip();

            if (quality.HasValue)
            {
                image.Quality = quality.Value;
            }

            //模版的宽高比例
            var templateRate = (double)width / height;

            //原图片的宽高比例
            var nowRate = (double)image.Width / image.Height;

            if (templateRate < nowRate)
            {
                //以高为准缩放
                // Resize each image in the collection to a width of 200. When zero is specified for the height
                // the height will be calculated with the aspect ratio.
                image.Resize(0, height);
                image.ChopHorizontal(width, image.Width - width);
            }
            else
            {
                //以宽为准缩放
                image.Resize(width, 0);
                image.ChopVertical(height, image.Height - height);
            }
        }
开发者ID:yongfa365,项目名称:ImageResizer,代码行数:30,代码来源:Helper.cs

示例2: Test_ClippingPaths

    public void Test_ClippingPaths()
    {
      using (MagickImage image = new MagickImage(Files.EightBimTIF))
      {
        EightBimProfile profile = image.Get8BimProfile();
        TestProfile(profile);

        using (MagickImage emptyImage = new MagickImage(Files.EightBimTIF))
        {
          emptyImage.Strip();
          Assert.IsNull(emptyImage.GetIptcProfile());
          emptyImage.AddProfile(profile);

          profile = emptyImage.Get8BimProfile();
          TestProfile(profile);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:18,代码来源:EightBimProfileTests.cs

示例3: buttonRun_Click

        private void buttonRun_Click(object sender, EventArgs e)
        {
            double savings;
            string outputName;
            FileInfo before;
            FileInfo after;
            MagickImage mi;

            foreach (ListViewItem listedImage in listViewMain.Items)
            {
                // File size before shrinking
                before = new FileInfo(listedImage.Text);
                mi = new MagickImage(listedImage.Text);

                // Get the output file path
                if (Properties.Settings.Default.overwrite)
                {
                    outputName = listedImage.Text;
                }
                else if (Directory.Exists(Properties.Settings.Default.path)) {
                    outputName = Properties.Settings.Default.path + "\\" + before.Name;
                }
                else
                {
                    MessageBox.Show("Invalid output directory", "Error");
                    break;
                }

                // Remove picture metadata
                if (Properties.Settings.Default.strip)
                {
                    mi.Strip();
                }

                // Resize to max dimensions
                if (Properties.Settings.Default.resize)
                {
                    if (Properties.Settings.Default.units == 0)
                    {
                        mi.Resize(
                            Properties.Settings.Default.maxWidth,
                            Properties.Settings.Default.maxHeight
                        );
                    }
                    else if (Properties.Settings.Default.units == 1)
                    {
                        mi.Resize(
                            new Percentage(Properties.Settings.Default.maxWidth),
                            new Percentage(Properties.Settings.Default.maxHeight)
                        );
                    }
                }

                mi.Quality = Properties.Settings.Default.quality * (100 / 13);
                mi.Interlace = Interlace.Jpeg;

                try
                {
                    mi.Write(outputName);
                }
                catch (MagickBlobErrorException ex)
                {
                    MessageBox.Show("Unable to write file to specified path.\n" + ex.Message, "Error");
                    break;
                }

                // File size after shrinking;
                after = new FileInfo(outputName);

                // Calculate and display the savings
                savings = 1 - (double)after.Length / before.Length;
                listedImage.SubItems[columnSavings.Index].Text = savings.ToString("p1");
            }
        }
开发者ID:eberkund,项目名称:allshrink,代码行数:74,代码来源:FormMain.cs

示例4: ExecuteStrip

 private static void ExecuteStrip(MagickImage image)
 {
   image.Strip();
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:4,代码来源:MagickImage.cs


注:本文中的ImageMagick.MagickImage.Strip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。