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


C# MagickWand.WriteImage方法代码示例

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


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

示例1: ProcessPhotoAsync

        public async Task<ProcessingResult> ProcessPhotoAsync(string filename)
        {
            using(var wand = new MagickWand())
            {
                var srcFile = _pathHelper.GetSourceFilePath(filename);

                if(_rawConverter.IsRawFile(srcFile))
                {
                    var conversionResult = await _rawConverter.ConvertAsync(srcFile);
                    
                    wand.ReadImage(conversionResult.OutputFile);
                    File.Delete(conversionResult.OutputFile);
                } 
                else 
                {
                    wand.ReadImage(srcFile);
                }
                
                wand.AutoOrientImage();
                wand.AutoLevelImage();
                wand.StripImage();
                
                var path = Path.Combine(Path.GetDirectoryName(srcFile), "review", $"{Path.GetFileNameWithoutExtension(filename)}.jpg");

                wand.WriteImage(path, true);
            }
            
            return null;
        }
开发者ID:AerisG222,项目名称:SizePhotos,代码行数:29,代码来源:FastReviewPhotoProcessor.cs

示例2: Resize

        public void Resize()
        {
            var file = "test3.jpg";

            MagickWandEnvironment.Genesis();

            using(var mw = new MagickWand())
            {
                mw.ReadImage("test.jpg");
                mw.ResizeImage(120, 100, FilterTypes.LanczosFilter, 1);
                mw.WriteImage(file, true);

                Assert.True(File.Exists(file), "scaled image not created");
            }

            using(var mw = new MagickWand(file))
            {
                Assert.True(mw.ImageWidth == 120, "width does not match the expected size");
                Assert.True(mw.ImageHeight == 100, "height does not match the expected size");
            }

            File.Delete(file);

            MagickWandEnvironment.Terminus();
        }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:25,代码来源:WrapperTests.cs

示例3: SaveResizedImage

 public void SaveResizedImage(int newWidth, string outPath)
 {
     CreateDirectoryForFile(outPath);
      using (MagickWand wand = new MagickWand()) {
         wand.ReadImage(filename);
         wand.TransformImage("", newWidth.ToString());
         wand.WriteImage (outPath);
     }
 }
开发者ID:codebutler,项目名称:quickthumbs,代码行数:9,代码来源:Image.cs

示例4: GetOptimalQuality

        public uint GetOptimalQuality(MagickWand wand)
        {
            var tmp = $"{Path.GetTempFileName()}.jpg";

            try
            {
                using(var tmpWand = wand.Clone())
                {
                    tmpWand.CompressionQuality = MAX_QUALITY;
                    wand.WriteImage(tmp, true);
                }

                var opts = new ImgminOptions
                {
                    ErrorThreshold = 0.08
                };

                var imgmin = new Imgmin(opts);
                var result = imgmin.Minify(tmp, tmp);

                if(!_quiet)
                {
                    Console.WriteLine(result.StandardOutput);
                }

                // the following has not been reliable, so figure out the
                // quality based on opening the tmp file.
                //return Convert.ToUInt32(result.StatsAfter.Quality);

                using(var qualWand = new MagickWand(tmp))
                {
                    return qualWand.ImageCompressionQuality;
                }
            }
            finally
            {
                File.Delete(tmp);
            }
        }
开发者ID:AerisG222,项目名称:SizePhotos,代码行数:39,代码来源:QualitySearcher.cs

示例5: WriteImage

 void WriteImage(string test, string filename, string[] args, MagickWand wand)
 {
     var dir = Path.Combine("contrast_tests", test);
     var file = $"{Path.GetFileNameWithoutExtension(filename)}_{string.Join("_", args)}{Path.GetExtension(filename)}";
     var fullPath = Path.Combine(dir, file);
     
     Directory.CreateDirectory(dir);
     wand.WriteImage(fullPath, true);
 }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:9,代码来源:ContrastTests.cs

示例6: Write

 void Write(MagickWand wand, string file)
 {
     if(KEEP_FILES)
     {
         wand.WriteImage("wrapper_out" + Path.DirectorySeparatorChar + file, true);
     }
 }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:7,代码来源:WrapperTests.cs

示例7: StreamTest

 public void StreamTest()
 {
     MagickWandEnvironment.Genesis();
     
     using(var wand = new MagickWand(TestHelper.TEST_FILE))
     using(var ms = new MemoryStream())
     {
         wand.WriteImage(ms);
         
         var streamfile = "streamtest.jpg";
         
         using(var fs = new FileStream(streamfile, FileMode.CreateNew))
         {
             ms.CopyTo(fs);
             fs.Flush();
         }
         
         Assert.True(File.Exists(streamfile));
         
         using(var newWand = new MagickWand(streamfile))
         {
             Assert.True(wand.ImageHeight == newWand.ImageHeight);
             Assert.True(wand.ImageWidth == newWand.ImageWidth);
         }
         
         File.Delete(streamfile);
     }
     
     MagickWandEnvironment.Terminus();
 }
开发者ID:AerisG222,项目名称:NMagickWand,代码行数:30,代码来源:WrapperTests.cs


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