Actually I want to set some Exif Tag values in JPG Image.
but when i used below code :
Error:
but when i used below code :
string imgPath="TestImage.jpg";
using (MagickImage image = new MagickImage(imgPath))
{
ExifProfile exifProfile = image.GetExifProfile();
//if (exifProfile == null)
//{
// MessageBox.Show("null");
//}
exifProfile.SetValue(ExifTag.Make, "ABCD");
exifProfile.SetValue(ExifTag.Model, "000");
exifProfile.SetValue(ExifTag.Software, "XYZ");
image.AddProfile(exifProfile);
image.Write(imgPath);
image.Dispose();
}
and got the error on " exifProfile.SetValue(ExifTag.Make, "ABCD");"Error:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=MagickAPITest
StackTrace:
at MagickAPITest.PersonalSetting.ApplyAllSetting() in D:\Projects\Visual Studio 2015\Projects\MagickAPITest\MagickAPITest\PersonalSetting.cs:line 45
at MagickAPITest.Form1.button3_Click(Object sender, EventArgs e) in D:\Projects\Visual Studio 2015\Projects\MagickAPITest\MagickAPITest\Form1.cs:line 66
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at MagickAPITest.Program.Main() in D:\Projects\Visual Studio 2015\Projects\MagickAPITest\MagickAPITest\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: