From f848bc171eb6b49132283d7c69b591fe75a31a2a Mon Sep 17 00:00:00 2001 From: "karthik.bashetty" Date: Wed, 9 Oct 2024 14:21:21 +0530 Subject: [PATCH] Support PDF files with magic byte in the header --- vips/foreign.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vips/foreign.go b/vips/foreign.go index 80f643b4..861f076d 100644 --- a/vips/foreign.go +++ b/vips/foreign.go @@ -154,14 +154,14 @@ func DetermineImageType(buf []byte) ImageType { return ImageTypeHEIF } else if isSVG(buf) { return ImageTypeSVG - } else if isPDF(buf) { - return ImageTypePDF } else if isBMP(buf) { return ImageTypeBMP } else if isJP2K(buf) { return ImageTypeJP2K } else if isJXL(buf) { return ImageTypeJXL + } else if isPDF(buf) { + return ImageTypePDF } else { return ImageTypeUnknown } @@ -240,7 +240,7 @@ func isSVG(buf []byte) bool { var pdf = []byte("\x25\x50\x44\x46") func isPDF(buf []byte) bool { - return bytes.HasPrefix(buf, pdf) + return bytes.Contains(buf[:1024], pdf) } var bmpHeader = []byte("BM")