本文整理汇总了C#中ImageMagick.MagickImage.GetExifProfile方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.GetExifProfile方法的具体用法?C# MagickImage.GetExifProfile怎么用?C# MagickImage.GetExifProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.GetExifProfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
{
var conf = new RotateTransformViewModel(configData);
// Read from file
using (MagickImage image = new MagickImage(infile))
{
image.BackgroundColor = new MagickColor(Color.Black);
if (conf.AutoRotate)
{
ExifProfile profile = image.GetExifProfile();
image.AutoOrient();
profile.SetValue(ExifTag.Orientation, (UInt16)0);
}
if (conf.Angle > 0)
image.Rotate(conf.Angle);
if(conf.FlipHorizontal)
image.Flop();
if (conf.FlipVertical)
image.Flip();
image.Format = MagickFormat.Jpeg;
// Save the result
image.Write(dest);
}
return dest;
}
示例2: 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");
}
}
}
示例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: GetExifValue
private static ExifValue GetExifValue()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
return profile.Values.First();
}
}
示例5: Test_SkipProfiles
public void Test_SkipProfiles()
{
MagickReadSettings settings = new MagickReadSettings()
{
Defines = new PngReadDefines()
{
SkipProfiles = ProfileTypes.Xmp | ProfileTypes.Exif
}
};
using (MagickImage image = new MagickImage())
{
image.Read(Files.FujiFilmFinePixS1ProPNG);
Assert.IsNotNull(image.GetExifProfile());
Assert.IsNotNull(image.GetXmpProfile());
image.Read(Files.FujiFilmFinePixS1ProPNG, settings);
Assert.IsNull(image.GetExifProfile());
Assert.IsNull(image.GetXmpProfile());
Assert.AreEqual("Exif,Xmp", image.Settings.GetDefine("profile:skip"));
}
}
示例6: CreateThumbnailFromExifData
public static void CreateThumbnailFromExifData()
{
// Read image from file
using (MagickImage image = new MagickImage(SampleFiles.FujiFilmFinePixS1ProJpg))
{
// Retrieve the exif information
ExifProfile profile = image.GetExifProfile();
// Create thumbnail from exif information
using (MagickImage thumbnail = profile.CreateThumbnail())
{
// Check if exif profile contains thumbnail and save it
if (thumbnail != null)
thumbnail.Write(SampleFiles.OutputDirectory + "FujiFilmFinePixS1Pro.thumb.jpg");
}
}
}
示例7: ReadExifData
public static void ReadExifData()
{
// Read image from file
using (MagickImage image = new MagickImage(SampleFiles.FujiFilmFinePixS1ProJpg))
{
// Retrieve the exif information
ExifProfile profile = image.GetExifProfile();
// Check if image contains an exif profile
if (profile == null)
Console.WriteLine("Image does not contain exif information.");
else
{
// Write all values to the console
foreach (ExifValue value in profile.Values)
{
Console.WriteLine("{0}({1}): {2}", value.Tag, value.DataType, value.ToString());
}
}
}
}
示例8: MediaInfo
public MediaInfo(MagickImage image)
{
ColorSpace = image.ColorSpace;
Comment = image.Comment;
FileName = image.FileName;
FileSize = image.FileSize;
MagickFormat = image.Format;
foreach (ExifValue exifValue in image.GetExifProfile().Values)
{
if (exifValue.Tag == ExifTag.DateTimeOriginal)
{
//YYYY:MM:DD HH:MM:SS
//DateTime dtresult;
//IFormatProvider formatp = d;
//DateTime.TryParse(exifValue.Value.ToString(), formatp, DateTimeStyles.None, out dtresult);
ImageDate = DateTaken(exifValue.Value.ToString());
}
}
Height = image.Height;
Width = image.Width;
ResolutionX = image.ResolutionX;
ResolutionY = image.ResolutionY;
}
示例9: 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);
}
}
}
示例10: Test_Thumbnail
public void Test_Thumbnail()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
Assert.IsNotNull(profile);
using (MagickImage thumbnail = profile.CreateThumbnail())
{
Assert.IsNotNull(thumbnail);
Assert.AreEqual(128, thumbnail.Width);
Assert.AreEqual(85, thumbnail.Height);
Assert.AreEqual(MagickFormat.Jpeg, thumbnail.Format);
}
}
}
示例11: 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());
//.........这里部分代码省略.........
示例12: Test_Infinity
public void Test_Infinity()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.ExposureBiasValue, double.PositiveInfinity);
image.AddProfile(profile);
profile = image.GetExifProfile();
ExifValue value = profile.GetValue(ExifTag.ExposureBiasValue);
Assert.IsNotNull(value);
Assert.IsTrue(double.PositiveInfinity.Equals(value.Value));
profile.SetValue(ExifTag.ExposureBiasValue, double.NegativeInfinity);
image.AddProfile(profile);
profile = image.GetExifProfile();
value = profile.GetValue(ExifTag.ExposureBiasValue);
Assert.IsNotNull(value);
Assert.IsTrue(double.NegativeInfinity.Equals(value.Value));
profile.SetValue(ExifTag.FlashEnergy, double.NegativeInfinity);
image.AddProfile(profile);
profile = image.GetExifProfile();
value = profile.GetValue(ExifTag.FlashEnergy);
Assert.IsNotNull(value);
Assert.IsTrue(double.PositiveInfinity.Equals(value.Value));
}
}
示例13: 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);
}
}
}
示例14: Test_AutoOrient
public void Test_AutoOrient()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProPNG))
{
Assert.AreEqual(600, image.Width);
Assert.AreEqual(400, image.Height);
Assert.AreEqual(OrientationType.TopLeft, image.Orientation);
ExifProfile profile = image.GetExifProfile();
profile.SetValue(ExifTag.Orientation, (ushort)6);
image.AddProfile(profile);
using (MemoryStream memStream = new MemoryStream())
{
image.Write(memStream);
memStream.Position = 0;
image.Read(memStream);
Assert.AreEqual(600, image.Width);
Assert.AreEqual(400, image.Height);
Assert.AreEqual(OrientationType.RightTop, image.Orientation);
image.AutoOrient();
Assert.AreEqual(400, image.Width);
Assert.AreEqual(600, image.Height);
Assert.AreEqual(OrientationType.TopLeft, image.Orientation);
}
}
}
示例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());
}
}