This project has moved and is read-only. For the latest updates, please go here.

Write Value in null ExifProfile

Apr 1, 2016 at 5:46 AM
Could you please help me? How can I write value in null ExifProfile.
I am using latest version Magick.NET and trying to write ExifTag values in jpg file.
Apr 2, 2016 at 12:31 AM
I don't understand what you are asking. What do you mean by null ExifProfile?
Apr 11, 2016 at 8:32 AM
Edited Apr 11, 2016 at 8:46 AM
Actually I want to set some Exif Tag values in JPG Image.
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");

and got the error on " exifProfile.SetValue(ExifTag.Make, "ABCD"); "

System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
       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()
Apr 13, 2016 at 9:59 PM
It is possible that your call to GetExifProfile returns null. When that happens you should create a new ExifProfile.
Apr 16, 2016 at 5:04 AM
Edited Apr 16, 2016 at 5:05 AM
Thank you so much ! now I solved my problem..