本文整理汇总了C#中ImageMagick.MagickImage.AddProfile方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.AddProfile方法的具体用法?C# MagickImage.AddProfile怎么用?C# MagickImage.AddProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.AddProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_IptcProfile
public void Test_IptcProfile()
{
using (MagickImage input = new MagickImage(Files.MagickNETIconPNG))
{
IptcProfile profile = input.GetIptcProfile();
Assert.IsNull(profile);
profile = new IptcProfile();
profile.SetValue(IptcTag.Headline, "Magick.NET");
profile.SetValue(IptcTag.CopyrightNotice, "Copyright.NET");
input.AddProfile(profile);
using (MemoryStream memStream = new MemoryStream())
{
input.Format = MagickFormat.Tiff;
input.Write(memStream);
memStream.Position = 0;
using (MagickImage output = new MagickImage(memStream))
{
profile = output.GetIptcProfile();
Assert.IsNotNull(profile);
TestValue(profile, IptcTag.Headline, "Magick.NET");
TestValue(profile, IptcTag.CopyrightNotice, "Copyright.NET");
}
}
}
}
示例2: Test_FromIXPathNavigable
public void Test_FromIXPathNavigable()
{
using (MagickImage image = new MagickImage(Files.InvitationTif))
{
XmpProfile profile = image.GetXmpProfile();
Assert.IsNotNull(profile);
IXPathNavigable doc = profile.ToIXPathNavigable();
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
XmpProfile.FromIXPathNavigable(null);
});
XmpProfile newProfile = XmpProfile.FromIXPathNavigable(doc);
image.AddProfile(newProfile);
doc = profile.ToIXPathNavigable();
TestIXPathNavigable(doc);
profile = image.GetXmpProfile();
Assert.IsNotNull(profile);
doc = profile.ToIXPathNavigable();
TestIXPathNavigable(doc);
Assert.AreEqual(profile, newProfile);
}
}
示例3: WriteExif
//public PhotoInfo ReadExif2(string name)
//{
// PhotoInfo info = new PhotoInfo() { FileName = name };
// using (MagickImage image = new MagickImage(name))
// {
// ExifProfile profile = image.GetExifProfile();
// ExifValue value = profile.GetValue(ExifTag.DateTimeDigitized);
// if (value.Value == null)
// throw new Exception("Неудалось считать дату и время файла");
// info.DateTimeDigitized = (DateTime)value.Value;
// value = profile.GetValue(ExifTag.Model);
// info.Model = (string)value.Value;
// if (info.Model == null)
// info.Model = "Неизвестная модель";
// }
// return info;
//}
public static void WriteExif(PhotoInfo info, int? quality)
{
// Для моего телефона не работает метод image.AddProfile. Т.к. для моего телефона дату менять ненадо, то пропускаем.
if (info.Model.ToUpper().Contains("HUAWEI P7-L10"))
return;
using (MagickImage image = new MagickImage(info.FileName))
{
if (quality != null && quality < image.Quality)
image.Quality = quality.Value;
ExifProfile profile = image.GetExifProfile();
if (profile == null)
profile = new ExifProfile();
profile.SetValue(ExifTag.DateTimeDigitized, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));
profile.SetValue(ExifTag.DateTime, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));
profile.SetValue(ExifTag.DateTimeOriginal, info.DateTimeDigitized.ToString(DATE_TIME_FORMAT));
//try
//{
image.AddProfile(profile, true);
image.Write(info.FileName);
//}
//catch (Exception exc)
//{
//}
}
}
示例4: Test_ICM
public void Test_ICM()
{
using (MagickImage image = new MagickImage(Files.SnakewarePNG))
{
ColorProfile profile = image.GetColorProfile();
Assert.IsNull(profile);
image.AddProfile(new ImageProfile("icm", ColorProfile.SRGB.ToByteArray()));
TestProfile(image.GetColorProfile(), "icm");
}
}
示例5: Test_Info
public void Test_Info()
{
using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
{
image.AddProfile(ColorProfile.USWebCoatedSWOP);
Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:description"));
Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:manufacturer"));
Assert.AreEqual("U.S. Web Coated (SWOP) v2", image.GetAttribute("icc:model"));
Assert.AreEqual("Copyright 2000 Adobe Systems, Inc.", image.GetAttribute("icc:copyright"));
}
}
示例6: ConvertCmykToRgb
public static void ConvertCmykToRgb()
{
// Uses sRGB.icm, eps/pdf produce better result when you set this before loading.
MagickReadSettings settings = new MagickReadSettings();
settings.ColorSpace = ColorSpace.sRGB;
// Create empty image
using (MagickImage image = new MagickImage())
{
// Reads the eps image, the specified settings tell Ghostscript to create an sRGB image
image.Read(SampleFiles.SnakewareEps, settings);
// Save image as tiff
image.Write(SampleFiles.OutputDirectory + "Snakeware.tiff");
}
// Read image from file
using (MagickImage image = new MagickImage(SampleFiles.SnakewareJpg))
{
// First add a CMYK profile if your image does not contain a color profile.
image.AddProfile(ColorProfile.USWebCoatedSWOP);
// Adding the second profile will transform the colorspace from CMYK to RGB
image.AddProfile(ColorProfile.SRGB);
// Save image as png
image.Write(SampleFiles.OutputDirectory + "Snakeware.png");
}
// Read image from file
using (MagickImage image = new MagickImage(SampleFiles.SnakewareJpg))
{
// First add a CMYK profile if your image does not contain a color profile.
image.AddProfile(ColorProfile.USWebCoatedSWOP);
// Adding the second profile will transform the colorspace from your custom icc profile
image.AddProfile(new ColorProfile(SampleFiles.YourProfileIcc));
// Save image as tiff
image.Write(SampleFiles.OutputDirectory + "Snakeware.tiff");
}
}
示例7: 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);
}
}
}
示例8: Test_Fraction
public void Test_Fraction()
{
using (MemoryStream memStream = new MemoryStream())
{
double exposureTime = 1.0 / 1600;
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.ExposureTime, exposureTime);
image.AddProfile(profile);
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
ExifValue value = profile.GetValue(ExifTag.ExposureTime);
Assert.IsNotNull(value);
Assert.AreNotEqual(exposureTime, value.Value);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.ExposureTime, exposureTime);
profile.BestPrecision = true;
image.AddProfile(profile);
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
ExifValue value = profile.GetValue(ExifTag.ExposureTime);
TestValue(value, exposureTime);
}
}
}
示例9: Test_WithImage
public void Test_WithImage()
{
using (MagickImage image = new MagickImage())
{
image.AddProfile(ColorProfile.USWebCoatedSWOP);
ExceptionAssert.Throws<MagickCacheErrorException>(delegate ()
{
image.ColorSpace = ColorSpace.CMYK;
});
image.Read(Files.SnakewarePNG);
ColorProfile profile = image.GetColorProfile();
Assert.IsNull(profile);
image.AddProfile(ColorProfile.SRGB);
TestProfile(image.GetColorProfile(), "icc");
}
}
示例10: ExecuteAddProfile
private void ExecuteAddProfile(XmlElement element, MagickImage image)
{
Hashtable arguments = new Hashtable();
foreach (XmlAttribute attribute in element.Attributes)
{
arguments[attribute.Name] = Variables.GetValue<Boolean>(attribute);
}
foreach (XmlElement elem in element.SelectNodes("*"))
{
arguments[elem.Name] = CreateProfile(elem);
}
if (OnlyContains(arguments, "profile"))
image.AddProfile((ImageProfile)arguments["profile"]);
else if (OnlyContains(arguments, "profile", "overwriteExisting"))
image.AddProfile((ImageProfile)arguments["profile"], (Boolean)arguments["overwriteExisting"]);
else
throw new ArgumentException("Invalid argument combination for 'addProfile', allowed combinations are: [profile] [profile, overwriteExisting]");
}
示例11: Test_Values
public void Test_Values()
{
using (MagickImage image = new MagickImage(Files.EightBimTIF))
{
EightBimProfile profile = image.Get8BimProfile();
TestProfileValues(profile);
using (MagickImage emptyImage = new MagickImage(Files.ImageMagickJPG))
{
Assert.IsNull(emptyImage.Get8BimProfile());
emptyImage.AddProfile(profile);
profile = emptyImage.Get8BimProfile();
TestProfileValues(profile);
}
}
}
示例12: Test_Constructor
public void Test_Constructor()
{
using (MemoryStream memStream = new MemoryStream())
{
using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNull(profile);
profile = new ExifProfile();
profile.SetValue(ExifTag.Copyright, "Dirk Lemstra");
image.AddProfile(profile);
profile = image.GetExifProfile();
Assert.IsNotNull(profile);
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
Assert.AreEqual(1, profile.Values.Count());
ExifValue value = profile.Values.FirstOrDefault(val => val.Tag == ExifTag.Copyright);
TestValue(value, "Dirk Lemstra");
}
}
}
示例13: Test_SetValue
public void Test_SetValue()
{
double[] latitude = new double[] { 12.3, 4.56, 789.0 };
using (MemoryStream memStream = new MemoryStream())
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.Software, "Magick.NET");
ExifValue value = profile.GetValue(ExifTag.Software);
TestValue(value, "Magick.NET");
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
value.Value = 15;
});
profile.SetValue(ExifTag.ShutterSpeedValue, 75.55);
value = profile.GetValue(ExifTag.ShutterSpeedValue);
TestValue(value, 75.55);
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
value.Value = 75;
});
profile.SetValue(ExifTag.XResolution, 150.0);
value = profile.GetValue(ExifTag.XResolution);
TestValue(value, 150.0);
ExceptionAssert.Throws<ArgumentException>(delegate ()
{
value.Value = "Magick.NET";
});
image.Density = new PointD(72);
value = profile.GetValue(ExifTag.XResolution);
TestValue(value, 150.0);
value = profile.GetValue(ExifTag.ReferenceBlackWhite);
Assert.IsNotNull(value);
profile.SetValue(ExifTag.ReferenceBlackWhite, null);
value = profile.GetValue(ExifTag.ReferenceBlackWhite);
TestValue(value, (string)null);
profile.SetValue(ExifTag.GPSLatitude, latitude);
value = profile.GetValue(ExifTag.GPSLatitude);
TestValue(value, latitude);
image.AddProfile(profile);
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
Assert.AreEqual(43, profile.Values.Count());
ExifValue value = profile.GetValue(ExifTag.Software);
TestValue(value, "Magick.NET");
value = profile.GetValue(ExifTag.ShutterSpeedValue);
TestValue(value, 75.55);
value = profile.GetValue(ExifTag.XResolution);
TestValue(value, 72.0);
value = profile.GetValue(ExifTag.ReferenceBlackWhite);
Assert.IsNull(value);
value = profile.GetValue(ExifTag.GPSLatitude);
TestValue(value, latitude);
profile.Parts = ExifParts.ExifTags;
image.AddProfile(profile);
memStream.Position = 0;
image.Write(memStream);
}
memStream.Position = 0;
using (MagickImage image = new MagickImage(memStream))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
Assert.AreEqual(24, profile.Values.Count());
//.........这里部分代码省略.........
示例14: Test_Values
public void Test_Values()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
TestProfile(profile);
using (MagickImage emptyImage = new MagickImage(Files.ImageMagickJPG))
{
Assert.IsNull(emptyImage.GetExifProfile());
emptyImage.AddProfile(profile);
profile = emptyImage.GetExifProfile();
TestProfile(profile);
}
}
}
示例15: Test_Infinity
public void Test_Infinity()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity));
image.AddProfile(profile);
profile = image.GetExifProfile();
ExifValue value = profile.GetValue(ExifTag.ExposureBiasValue);
Assert.IsNotNull(value);
Assert.AreEqual(double.PositiveInfinity, ((SignedRational)value.Value).ToDouble());
profile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity));
image.AddProfile(profile);
profile = image.GetExifProfile();
value = profile.GetValue(ExifTag.ExposureBiasValue);
Assert.IsNotNull(value);
Assert.AreEqual(double.NegativeInfinity, ((SignedRational)value.Value).ToDouble());
profile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity));
image.AddProfile(profile);
profile = image.GetExifProfile();
value = profile.GetValue(ExifTag.FlashEnergy);
Assert.IsNotNull(value);
Assert.AreEqual(double.PositiveInfinity, ((Rational)value.Value).ToDouble());
}
}