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 9b7e960
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 9b7e960

Please sign in to comment.