thumbnail in imagemagick

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
laleh
Posts: 3
Joined: 2019-07-14T10:54:10-07:00
Authentication code: 1152

thumbnail in imagemagick

Post 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);
                    }
                }
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: thumbnail in imagemagick

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
laleh
Posts: 3
Joined: 2019-07-14T10:54:10-07:00
Authentication code: 1152

Re: thumbnail in imagemagick

Post by laleh »

Yes , I want to do thumbnail for image . but image.thumbnail() is not defined.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: thumbnail in imagemagick

Post by dlemstra »

It is "Thumbnail" not "thumbnail".
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply