本文整理汇总了C#中MagickImage.Strip方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Strip方法的具体用法?C# MagickImage.Strip怎么用?C# MagickImage.Strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagickImage
的用法示例。
在下文中一共展示了MagickImage.Strip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoLosslessCompress
private void DoLosslessCompress(FileInfo file)
{
using (MagickImage image = new MagickImage(file))
{
CheckFormat(image);
image.Strip();
image.SetDefine(MagickFormat.Png, "exclude-chunks", "all");
image.SetDefine(MagickFormat.Png, "include-chunks", "tRNS,gAMA");
CheckTransparency(image);
Collection<FileInfo> tempFiles = new Collection<FileInfo>();
try
{
FileInfo bestFile = null;
foreach (int quality in GetQualityList())
{
FileInfo tempFile = new FileInfo(Path.GetTempFileName());
tempFiles.Add(tempFile);
image.Quality = quality;
image.Write(tempFile);
tempFile.Refresh();
if (bestFile == null || bestFile.Length > tempFile.Length)
bestFile = tempFile;
else
tempFile.Delete();
}
if (bestFile.Length < file.Length)
bestFile.CopyTo(file.FullName, true);
}
finally
{
foreach (FileInfo tempFile in tempFiles)
{
if (tempFile.Exists)
tempFile.Delete();
}
}
}
}
示例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.Get8BimProfile());
emptyImage.AddProfile(profile);
profile = emptyImage.Get8BimProfile();
TestProfile(profile);
}
}
}
示例3: DoLosslessCompress
private static void DoLosslessCompress(FileInfo file, MagickImage image)
{
CheckFormat(image);
image.Strip();
FileInfo tempFile = new FileInfo(Path.GetTempFileName());
try
{
image.Settings.Interlace = Interlace.NoInterlace;
image.Write(tempFile);
if (tempFile.Length < file.Length)
tempFile.CopyTo(file.FullName, true);
}
finally
{
FileHelper.Delete(tempFile);
}
}