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 » 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);
                    }
                }

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: thumbnail in imagemagick

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.
.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 » 2019-09-01T00:39:28-07:00

Yes , I want to do thumbnail for image . but image.thumbnail() is not defined.

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: thumbnail in imagemagick

Post by dlemstra » 2019-09-01T05:23:36-07:00

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

Post Reply