本文整理汇总了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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例6: Write
void Write(MagickWand wand, string file)
{
if(KEEP_FILES)
{
wand.WriteImage("wrapper_out" + Path.DirectorySeparatorChar + file, true);
}
}
示例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();
}