System.NullReferenceException when DataStreamSupporter.Save

I am getting System.NullReferenceException when I resizing and saving PNG.

Logs

11:57:16.0890 [Mik.Workstream.DocumentPreview.Converters.DocumentPreviewManager(L:126)] ERROR (TID:8) Unkown error occurred when Convert. Previewer: "Aspose.Imaging", Path: "C:\MIK.Smart.Solutions\Storage\Disk_FU_Workstream\Temp\Files (Preview-Working)\5ec05fc723054cd09b88c620918520e0\5ec05fc723054cd09b88c620918520e0_temp" => "C:\MIK.Smart.Solutions\Storage\Disk_FU_Workstream\Temp\Files (Preview-Working)\5ec05fc723054cd09b88c620918520e0\5ec05fc723054cd09b88c620918520e0", MimeType: "image/png", Scrambling: False
System.NullReferenceException: Object reference not set to an instance of an object.
   at: #=zXj5pXJbOf6EFOffbkmmKQpzv9DV2kKwagWdcb953EbkMEGrqSIAxPgs=.#=zsV6QMJo=(Int32[] #=z1khxbqlxufSU)
   at: #=zc26Ob2NM2lAy0TmUgz9c8czQbVWabp0kNboOlywY6zm7vhtz6A==.Process(Rectangle #=zQ8wmkIotPFEkDe2wRw==, Int32[] #=z1khxbqlxufSU, Point #=z7fc5RhE=, Point #=zG2PDlns=)
   at: #=zOKJ439TYz0Rh5JtOHWZTRHYpAlzxIqRcghsp8tcndlfe_jIrfA==.Process(Rectangle #=zQ8wmkIotPFEkDe2wRw==, Int32[] #=z1khxbqlxufSU, Point #=z7fc5RhE=, Point #=zG2PDlns=)
   at: #=zOebiutuZuHiRj_usU_GukPbZggasB09FrKZDBcwEyM_o.#=z9iNnRgBxNTdm(IPartialArgb32PixelLoader #=zY4Dh$sZF28Xz, Rectangle #=zGqWfTRFeTyeo, IEnumerable #=z1khxbqlxufSU)
   at: #=zpa$V5QOKpdhBcmes_j1dSmt1T_jm5$PrWtLOR_n1HgLn.#=z6zzI6ecGUUUc4FFUTQ==(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zY4Dh$sZF28Xz)
   at: #=zpa$V5QOKpdhBcmes_j1dSmt1T_jm5$PrWtLOR_n1HgLn.#=ztWspzdaLKykf0Fu7YQ==(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zY4Dh$sZF28Xz)
   at: #=zpa$V5QOKpdhBcmes_j1dSmt1T_jm5$PrWtLOR_n1HgLn.#=zNKV6tGilKhiT.LoadPartialArgb32Pixels(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zUdXP$UvvGKxz)
   at: #=zviio2U_d7cDXBwgZ2c0UAv0XH_YnSFE$Tg==.#=zNf224bk=(Rectangle #=zzkynPKfs0vSO)
   at: #=zbfMJlE5VlJB3YxTf7MeN7yAH__Sy.#=zWoi7p3Eu3ODc(#=zL5ozDYSby3KRKA1oyIFVtZZsfGKWudB4OA== #=zQHAPBRM5SIi_, IList`1 #=z996nFiiHf2CP, #=zndQJpZy2r$90bYLa6Sth4b93vhO_vp$959Pk6VY= #=z_Tg_69Ioy2w9)
   at: #=zbfMJlE5VlJB3YxTf7MeN7yAH__Sy.#=zNf224bk=(Rectangle #=zzkynPKfs0vSO, #=zL5ozDYSby3KRKA1oyIFVtZZsfGKWudB4OA== #=zQHAPBRM5SIi_, #=zWz2J2cM= #=zvBQ0O9k=, Int32 #=zqNlinfqtpZWX, Int32 #=z6dYoN4LvIkZE, #=zndQJpZy2r$90bYLa6Sth4b93vhO_vp$959Pk6VY= #=z_Tg_69Ioy2w9)
   at: #=ztJ1W_u8IkSip$q05k3elKQF1htC7IK8w4_MWMIWzYBuy.LoadPartialArgb32Pixels(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zUdXP$UvvGKxz)
   at: #=zviio2U_d7cDXBwgZ2c0UAv0XH_YnSFE$Tg==.#=zNf224bk=(Rectangle #=zzkynPKfs0vSO)
   at: #=zbfMJlE5VlJB3YxTf7MeN7yAH__Sy.#=zWoi7p3Eu3ODc(#=zL5ozDYSby3KRKA1oyIFVtZZsfGKWudB4OA== #=zQHAPBRM5SIi_, IList`1 #=z996nFiiHf2CP, #=zndQJpZy2r$90bYLa6Sth4b93vhO_vp$959Pk6VY= #=z_Tg_69Ioy2w9)
   at: #=zbfMJlE5VlJB3YxTf7MeN7yAH__Sy.#=zNf224bk=(Rectangle #=zzkynPKfs0vSO, #=zL5ozDYSby3KRKA1oyIFVtZZsfGKWudB4OA== #=zQHAPBRM5SIi_, #=zWz2J2cM= #=zvBQ0O9k=, Int32 #=zqNlinfqtpZWX, Int32 #=z6dYoN4LvIkZE, #=zndQJpZy2r$90bYLa6Sth4b93vhO_vp$959Pk6VY= #=z_Tg_69Ioy2w9)
   at: #=zHhI_kX9IBZO4$uovOuM1wWotsZ73fM8mcTThvfoSK_Ko.#=zmBowU2vsFQcpsawb617X0ec=(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zUdXP$UvvGKxz)
   at: Aspose.Imaging.RasterImage.#=zD$iybvUWkxvD(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zSZCpa6ezzqEi, Boolean #=zw8zRkg8nAo2QJnJVtA==)
   at: Aspose.Imaging.RasterImage.#=zmBowU2vsFQcpsawb617X0ec=(Rectangle #=zMa45z44=, IPartialArgb32PixelLoader #=zUdXP$UvvGKxz, Boolean #=zw8zRkg8nAo2QJnJVtA==)
   at: #=zjmMJ3IsjLkmhQ4rJUGxIXSp$fDp5TKL279sKr9WYe1cu.#=zuq_Y9fKesbLZ(Stream #=z3s4ENio=, RasterImage #=zqzh7SZ8=, #=z16ynA2fdYMU8eL71fzgkp0fIEBreqP4ej4mKTsDk9tnx #=zKBDbSrqgrtER, Rectangle #=zfrjPEfa1PoNd, Boolean #=zPLdLOYe_2xpj638nfA==)
   at: #=zjmMJ3IsjLkmhQ4rJUGxIXSp$fDp5TKL279sKr9WYe1cu.#=zwf1nYVYs4E7x(Stream #=z3s4ENio=, RasterImage #=zqzh7SZ8=, PngOptions #=zFLP$sXkimEw7, Rectangle #=zfrjPEfa1PoNd, Boolean #=zPLdLOYe_2xpj638nfA==, String #=zCqoHZsFRHL9J)
   at: Aspose.Imaging.FileFormats.Png.PngImage.SaveData(Stream stream)
   at: Aspose.Imaging.DataStreamSupporter.Save(Stream stream)
   at: Aspose.Imaging.DataStreamSupporter.Save(String filePath, Boolean overWrite)
   at: Mik.Workstream.DocumentPreview.Converters.AsposeImagePreviewConverter.Convert(String sourcePath, String destPath, DocumentPreviewArgs args) File D:\Miksystem\Workstream\servers\Mik.Workstream.DocumentPreview\Converters\AsposeImagePreviewConverter.cs:Line 46
   at: Mik.Workstream.DocumentPreview.Converters.DocumentPreviewManager.Convert(String previewer, String sourcePath, String destPath, DocumentPreviewArgs args, Boolean scramble) File D:\Miksystem\Workstream\servers\Mik.Workstream.DocumentPreview\Converters\DocumentPreviewManager.cs:Line 126

Herer is my codes:

public bool Convert(string sourcePath, string destPath, DocumentPreviewArgs args)
{
	using (var image = Image.Load(sourcePath))
	{
		if (image.Width > image.Height)
		{
			if (image.Width > MaxWidth)
			{
				image.ResizeWidthProportionally(MaxWidth);
			}
		}
		else if (image.Width < image.Height)
		{
			if (image.Height > MaxHeight)
			{
				image.ResizeHeightProportionally(MaxHeight);
			}
		}

		image.Save(destPath, true);
	}

	return true;
}

Problem PNG file:
IMG_0035.PNG.jpg (104.5 KB)

This error also occurs on the Aspose.ImagingResize test page.

@miksystem , Your error log related to png file, but you attached jpg file, can you please attach correct file? Did you write error to aspose app related forum to check if it is app related error?

Thanks to reply.

I uploaded the PNG file, but it seems that the attachment is automatically converted to JPG.
Here is original file:

And I’ve searched on other forums, including one here, but I couldn’t find the answer I wanted.

@miksystem
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-6741

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

The issues you have found earlier (filed as IMAGINGNET-6741) have been fixed in this update. This message was posted using Bugs notification tool by samer.el-khatib