Skip to content

Commit

Permalink
add jxr support #155 (#312)
Browse files Browse the repository at this point in the history
* add jxr support

* test passing

* changes suggest

* Fix small typo in comment

Co-authored-by: Gabriel Vasile <gabriel.vasile@email.com>
  • Loading branch information
dijotmathews and gabriel-vasile committed Sep 3, 2022
1 parent e7130b0 commit a86966a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/magic/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var (
Hdr = prefix([]byte("#?RADIANCE\n"))
// Xpm matches X PixMap image data.
Xpm = prefix([]byte{0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A, 0x2F})
// Jxr matches Microsoft HD JXR photo file.
Jxr = prefix([]byte{0x49, 0x49, 0xBC, 0x01})
)

func jpeg2k(sig []byte) Detector {
Expand Down
1 change: 1 addition & 0 deletions mimetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var files = map[string]string{
"jpg.jpg": "image/jpeg",
"jpm.jpm": "image/jpm",
"jxl.jxl": "image/jxl",
"jxr.jxr": "image/jxr",
"xpm.xpm": "image/x-xpixmap",
"js.js": "application/javascript",
"json.json": "application/json",
Expand Down
3 changes: 2 additions & 1 deletion supported_mimes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 171 Supported MIME types
## 172 Supported MIME types
This file is automatically generated when running tests. Do not edit manually.

Extension | MIME type | Aliases
Expand Down Expand Up @@ -139,6 +139,7 @@ Extension | MIME type | Aliases
**.glb** | model/gltf-binary | -
**.avif** | image/avif | -
**.cab** | application/x-installshield | -
**.jxr** | image/jxr | image/vnd.ms-photo
**.txt** | text/plain | -
**.html** | text/html | -
**.svg** | image/svg+xml | -
Expand Down
Binary file added testdata/jxr.jxr
Binary file not shown.
3 changes: 2 additions & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var root = newMIME("application/octet-stream", "",
gzip, class, swf, crx, ttf, woff, woff2, otf, ttc, eot, wasm, shx, dbf, dcm, rar,
djvu, mobi, lit, bpg, sqlite3, dwg, nes, lnk, macho, qcp, icns, heic,
heicSeq, heif, heifSeq, hdr, mrc, mdb, accdb, zstd, cab, rpm, xz, lzip,
torrent, cpio, tzif, xcf, pat, gbr, glb, avif, cabIS,
torrent, cpio, tzif, xcf, pat, gbr, glb, avif, cabIS, jxr,
// Keep text last because it is the slowest check
text,
)
Expand Down Expand Up @@ -255,4 +255,5 @@ var (
gbr = newMIME("image/x-gimp-gbr", ".gbr", magic.Gbr)
xfdf = newMIME("application/vnd.adobe.xfdf", ".xfdf", magic.Xfdf)
glb = newMIME("model/gltf-binary", ".glb", magic.Glb)
jxr = newMIME("image/jxr", ".jxr", magic.Jxr).alias("image/vnd.ms-photo")
)

0 comments on commit a86966a

Please sign in to comment.