From 2d3da1db6dc6d52905f55dca74856dc103739ae1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 3 Jan 2023 10:27:31 +0530 Subject: [PATCH] Dont scan all pixels of JPEG images when EXIF rotated to check for opacity --- tools/cmd/icat/native.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/cmd/icat/native.go b/tools/cmd/icat/native.go index 854aa2924..009d0db9e 100644 --- a/tools/cmd/icat/native.go +++ b/tools/cmd/icat/native.go @@ -28,7 +28,13 @@ func resize_frame(imgd *image_data, img image.Image) (image.Image, image.Rectang } func add_frame(imgd *image_data, img image.Image) *image_frame { - is_opaque := images.IsOpaque(img) + is_opaque := false + if imgd.format_uppercase == "JPEG" { + // special cased because EXIF orientation could have already changed this image to an NRGBA making IsOpaque() very slow + is_opaque = true + } else { + is_opaque = images.IsOpaque(img) + } b := img.Bounds() if imgd.scaled_frac.x != 0 { img, b = resize_frame(imgd, img)