Skip to content

Commit 6bb21e4

Browse files
committed
Update jpeg equality
1 parent 254aa39 commit 6bb21e4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/camera/camera_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ func verifyImageEquality(t *testing.T, img1, img2 image.Image) {
298298
func verifyDecodedImage(t *testing.T, imgBytes []byte, mimeType string, originalImg image.Image) {
299299
t.Helper()
300300
test.That(t, len(imgBytes), test.ShouldBeGreaterThan, 0)
301+
302+
// For JPEG, compare the raw bytes after encoding the original image
303+
if mimeType == rutils.MimeTypeJPEG {
304+
expectedBytes, err := rimage.EncodeImage(context.Background(), originalImg, mimeType)
305+
test.That(t, err, test.ShouldBeNil)
306+
test.That(t, imgBytes, test.ShouldResemble, expectedBytes)
307+
return
308+
}
309+
310+
// For other formats, compare the decoded images
301311
decodedImg, err := rimage.DecodeImage(context.Background(), imgBytes, mimeType)
302312
test.That(t, err, test.ShouldBeNil)
303313
verifyImageEquality(t, decodedImg, originalImg)

0 commit comments

Comments
 (0)