I'm trying to use this example of Magick.NET library to read Exif information from an Image, but at the moment that I try to iterate the Exif values I get an unhandled error:
An unhandled exception of type 'System.ArgumentException' occurred in Magick.NET-AnyCPU.dll
Additional information: La matriz de origen no es suficientemente larga. Compruebe srcIndex, la longitud y los límites inferiores de la matriz.
(In English: The source Array is not long enough. Check srcIndex, length and lower bounds of the array)
This is the code that I'm using:
Using img As New MagickImage("C:\Jpeg With Exif.jpg")
' Retrieve the Exif Information (if any)
Dim ExifData As ExifProfile = img.GetExifProfile()
' This instruction throws the same unhandled exception that the 'For' below.
' MsgBox(ExifData.Values.Count)
Select Case ExifData Is Nothing
Case True ' Zero Exif values found.
MessageBox.Show("The image does not contains Exif information", "Image Information",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Case Else ' At least 1 Exif value found.
' StringBuilder to format the Exif entries.
Dim sb As New System.Text.StringBuilder
' Iterate the Exif values.
For Each Value As ExifValue In ExifData.Values
' ******
' Here throws the unhandled exception.
' Even if the For block is empty of instructions.
' ******
With sb
.AppendLine(String.Format("{0}({1}): {2}",
Value.Tag,
Value.DataType,
Value.ToString()))
End With '/ sb
Next Value
MessageBox.Show(sb.ToString, "Exif Image Information",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select '/ ExifData Is Nothing
End Using '/ img As New MagickImage
Then this is a bug, or I'm doing something wrong?
Note: I previously added Exif information with the ExifTool program using this command:
.\exiftool.exe -artist="value" "c:\Test.jpg"
Here is the image that I've tried to examine: http://www.mediafire.com/?42kvy8hhu4mgpz7
You have discovered a bug in Magick.NET. Your image contains invalid sizes that where not correctly checked. This will be fixed in Magick.NET 6.8.9.401.
As also pointed out in the comments you can also report problems / ask questions here: https://magick.codeplex.com/discussions. I will reply to all questions asked there.
With a build that includes a fix for this problem I was able to extract the following values:
XResolution: 1
YResolution: 1
ResolutionUnit: 1
Artist: Phil Harvey
YCbCrPositioning: 1
Copyright: 2011 Phil Harvey