11
Views
5
Comments
[Smart Image Utils] Error in rotate function
smart-image-utils
Service icon
Forge asset by Aureliano Pinheiro
Application Type
Service

Good day,

When trying to use your component, an error is thrown when trying to use the Rotate function. It occurs on both jpg- and png-images and of several file sizes.

================================================
System.ArgumentNullException: Value cannot be null.

Parameter name: encoder

   at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)

   at OutSystems.NssSmart_Image_Utils.CssSmart_Image_Utils.StreamToBinary(Bitmap bitmap, ImageCodecInfo Encoder, EncoderParameters Params, ImageFormat ImageFormat)

   at OutSystems.NssSmart_Image_Utils.CssSmart_Image_Utils.MssRotate_Image(Byte[] ssOriginalImage, Decimal ssDegrees, Byte[]& ssRotatedImage, String& ssErrorMessage)

================================================ 

It seems something is not mapped correctly, as both the binary and degrees input is in fact filled. Above error can also be reproduced on the Demo application of this component.

Can you take a look at what might go wrong?

Thank you in advance.

UserImage.jpg
Aravind GS

The error is caused by a null image encoder, not by your inputs.


Image.Save(stream, encoder, encoderParams) fails because encoder is null. This means the component is unable to resolve the correct JPEG/PNG encoder (a known issue in this Forge asset, confirmed since it also happens in the demo app).


Fix: handle the null encoder in the component code:


if (Encoder == null)

{

    bitmap.Save(stream, ImageFormat.Png); // fallback

}

else

{

    bitmap.Save(stream, Encoder, Params);

}


Or simpler (recommended):


bitmap.Save(stream, ImageFormat.Png);


Conclusion:

Not an input issue — it’s a bug in the Smart Image Utils component due to missing encoder resolution.

2023-04-13 07-10-08
Geertjan Jacobs

Thank you for your AI-generated answer...

2018-07-06 11-13-55
Nathan Hobbs


Component hasn't been updated for a year.

Why not ask to join the component team and apply the fix above?

Is a great way to learn and help the community.

2022-08-11 19-07-59
Aureliano Pinheiro

Hello Geertjan,

Thank you for your feedback, I’ll make sure to test your scenario and run a few tests after the fix, letting you know when the new version is uploaded so you can downloaded it.

Maybe I can make it before the weekend but can’t confirm it since I’m a little busy at the moment.

Best regards,

Aureliano Pinheiro

2018-07-06 11-13-55
Nathan Hobbs


Hi Aureliano,

Happy to help if needed.
Remember, a problem shared becomes somebody else problem!

Kind Regards,

Nathan


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.