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


C# MagickWand.ReadImage方法代码示例

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


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

        public Image(string filename)
        {
            this.filename = filename;

            using (MagickWand wand = new MagickWand()) {
                wand.ReadImage(filename);
                this.width = (int)wand.ImageWidth;
                this.height = (int)wand.ImageHeight;
            }
        }
开发者ID:codebutler,项目名称:quickthumbs,代码行数:10,代码来源:Image.cs

示例5: ProcessPhotoAsync

 public async Task<ProcessingResult> ProcessPhotoAsync(string filename)
 {
     var result = new ProcessingResult();
     var jpgName = Path.ChangeExtension(filename, ".jpg");
     var origPath = _pathHelper.GetSourceFilePath(filename);
     var srcPath = _pathHelper.GetScaledLocalPath(SourceTarget.ScaledPathSegment, filename);
     
     result.ExifData = await _exifReader.ReadExifDataAsync(origPath);
     
     // always keep the original in the source dir
     File.Move(origPath, srcPath);
     result.Source = new ProcessedPhoto { 
         Target = SourceTarget, 
         LocalFilePath = srcPath, 
         WebFilePath = _pathHelper.GetScaledWebFilePath(SourceTarget.ScaledPathSegment, filename)
     };
     
     using(var wand = new MagickWand())
     {
         if(_rawConverter.IsRawFile(srcPath))
         {
             result.RawConversionResult = await _rawConverter.ConvertAsync(srcPath);
             
             wand.ReadImage(result.RawConversionResult.OutputFile);
             File.Delete(result.RawConversionResult.OutputFile);
         } 
         else 
         {
             wand.ReadImage(srcPath);
         }
         
         result.Source.Height = wand.ImageHeight;
         result.Source.Width = wand.ImageWidth;
         
         wand.AutoOrientImage();
         wand.StripImage();
         
         using(var optWand = wand.Clone())
         {
             result.OptimizationResult = _optimizer.Optimize(optWand);
             
             // get the best compression quality for the optimized image
             // (best => smallest size for negligible quality loss)
             result.CompressionQuality = (short)_qualitySearcher.GetOptimalQuality(optWand);
             
             result.Xs = ProcessTarget(wand, optWand, result.CompressionQuality, XsTarget, jpgName);
             result.Sm = ProcessTarget(wand, optWand, result.CompressionQuality, SmTarget, jpgName);
             result.Md = ProcessTarget(wand, optWand, result.CompressionQuality, MdTarget, jpgName);
             result.Lg = ProcessTarget(wand, optWand, result.CompressionQuality, LgTarget, jpgName);
             result.Print = ProcessTarget(wand, optWand, result.CompressionQuality, PrintTarget, jpgName);
         }
     }
     
     return result;
 }
开发者ID:AerisG222,项目名称:SizePhotos,代码行数:55,代码来源:PhotoProcessor.cs

示例6: TestWrapperAndStringQueryFuncs

        public void TestWrapperAndStringQueryFuncs()
        {
            MagickWandEnvironment.Genesis();

            using(var mi = new MagickWand())
            {
                mi.ReadImage(TestHelper.TEST_FILE);

                var list = mi.GetImageProperties(string.Empty);

                Assert.True(list != null, "the list should not be null");
                Assert.True(list.Count > 0, "there should be more than 1 profile");

                foreach(var item in list)
                {
                    Console.WriteLine($"profile: {item}");
                }
            }

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


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