Page 1 of 1

thumbnail in imagemagick

Posted: 2019-08-31T01:17:28-07:00
by laleh
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);
                    }
                }

Re: thumbnail in imagemagick

Posted: 2019-08-31T04:55:08-07:00
by dlemstra
image.GetExifProfile() can return null so you also need check for that: profile?.CreateThumbnail(). And you probably want to do image.Thumbnail() instead.

Re: thumbnail in imagemagick

Posted: 2019-09-01T00:39:28-07:00
by laleh
Yes , I want to do thumbnail for image . but image.thumbnail() is not defined.

Re: thumbnail in imagemagick

Posted: 2019-09-01T05:23:36-07:00
by dlemstra
It is "Thumbnail" not "thumbnail".