Are JpegEncoder and other format encoders considered to be reusable for multiple images? #1711
-
If yesThere's a bug at least in jpeg:
ImageSharp/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs Lines 66 to 83 in 9baba86 Steps to reproduce: using var img_grayscale = Image.Load();
using var img_colored = Image.Load();
JpegEncoder encoder = new JpegEncoder { };
img_grayscale.SaveAsJpeg("path", encoder); // encoder is now grascale
img_colored.SaveAsJpeg("path", encoder); // saved as grayscale If noCurrent tests for jpeg assumes encoder can be used multiple times: ImageSharp/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs Lines 178 to 222 in 9baba86 While this currently does not break anything it gives false (or not) promise of being reusable through tests while not being so. Not sure if it wasn't expected so opened a discussion instead of an issue. Question/Proposal: state explicitly in the docs if they are reusable or not and fix reusable usage for all encoders in tests. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@br3aker good catch! I think this is a bug, encoder/decoder state should not be altered by encoding. We can implement an equivalent logic in |
Beta Was this translation helpful? Give feedback.
@br3aker good catch! I think this is a bug, encoder/decoder state should not be altered by encoding. We can implement an equivalent logic in
JpegEncoderCore
instead.