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-14T10:54:10-07:00
Authentication code: 1152
Post
by laleh » 2019-08-31T01:17:28-07: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-04T15:28:54-07:00
Authentication code: 6789
Contact:
Post
by dlemstra » 2019-08-31T04:55:08-07: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-14T10:54:10-07:00
Authentication code: 1152
Post
by laleh » 2019-09-01T00:39:28-07:00
Yes , I want to do thumbnail for image . but image.thumbnail() is not defined.
dlemstra
Posts: 1570 Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:
Post
by dlemstra » 2019-09-01T05:23:36-07:00
It is "Thumbnail" not "thumbnail".