Skip to content

Commit

Permalink
Support PDF files with magic byte in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-bashetty committed Oct 9, 2024
1 parent d925c83 commit f848bc1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vips/foreign.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f848bc1

Please sign in to comment.