Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
laleh
Posts: 3 Joined: 2019-07-14T17:54:10+00:00
Authentication code: 1152
Post
by laleh » 2019-08-31T08:17:28+00:00
I want to make thumbnail a image but I have the following error
NullReferenceException: Object reference not set to an instance of an object.
I use this code :
Code: Select all
using (MagickImage image = new MagickImage(mainpath + media.Name))
{
ExifProfile profile = image.GetExifProfile();
using (MagickImage thumbnail = profile.CreateThumbnail())
{
// if (thumbnail != null)
thumbnail.Write(paththumb + media.Name);
}
}
dlemstra
Posts: 1570 Joined: 2013-05-04T22:28:54+00:00
Authentication code: 6789
Contact:
Post
by dlemstra » 2019-08-31T11:55:08+00:00
image.GetExifProfile() can return null so you also need check for that: profile?.CreateThumbnail(). And you probably want to do image.Thumbnail() instead.
laleh
Posts: 3 Joined: 2019-07-14T17:54:10+00:00
Authentication code: 1152
Post
by laleh » 2019-09-01T07:39:28+00:00
Yes , I want to do thumbnail for image . but image.thumbnail() is not defined.
dlemstra
Posts: 1570 Joined: 2013-05-04T22:28:54+00:00
Authentication code: 6789
Contact:
Post
by dlemstra » 2019-09-01T12:23:36+00:00
It is "Thumbnail" not "thumbnail".