Add Support for more file types: .NEF, .MOV, .HEIC, .M4A#129
Add Support for more file types: .NEF, .MOV, .HEIC, .M4A#129Log45 wants to merge 3 commits intoComputerScienceHouse:developfrom
Conversation
mxmeinhold
left a comment
There was a problem hiding this comment.
always exciting to see more support, I gave a pretty light review, but most of this seems pretty boiler plate and I haven't looked at the gallery boiler plate in a long time, so I don't have strong opinions
in terms of the blurry ones, could the UI give a notice so that nobody is confuzzled?
gallery/file_modules/__init__.py
Outdated
| print("entering parse_file_info") | ||
| ext = os.path.splitext(file_path)[-1].lower() | ||
| # .nef is a RAW file | ||
| if ext == ".nef": # .nef is a special case, magic reads it as .tiff, but it is not processed correctly by the tiff module |
There was a problem hiding this comment.
is there any header info the file gives us rather than relying on extensions? Extensions are brittle and icky imo
There was a problem hiding this comment.
valid, I can look into that but don't know anything about file headers, will see if I can make something work
There was a problem hiding this comment.
I think the issue is that NEF files use a tiff header, and that's why I looked at the extension. This is mostly a problem with the magic library because it's not really built to support RAW files, so it sees the header and assumes tiff.
After some googling, it looks like there might be some other libraries to example specifically tiff files, so I might be able to add that and have it differentiate
There was a problem hiding this comment.
Per wikipedia,
if you can pull the TIFF header then the NEF should have a TIFF Tag 259
(0103 hex) value of (8799 hex). Does magick expose that directly? Been a
while since I tried to mess with this
There was a problem hiding this comment.
I'm not sure if magic exposes that, right now I'm testing out using rawpy to check if it is a RAW file, and then changing the mime type from there, but that might cause all RAW files to be considered NEF and either break something or accidentally support all RAW 💀, will push changes for review after I'm able to test it
There was a problem hiding this comment.
I couldn't run the actual app cause I can't connect to the VPN rn, but I tested it with a .TIFF, .NEF, and .cr3 file, and this was the output (it works in this case), I'm gonna push my fix with the rawpy code and updated requirements
entering parse_file_info
image/x-nikon-nef
DSC_0614.NEF
BASE CONSTRUCTOR
('image/x-nikon-nef', <gallery.file_modules.nef.NEFFile object at 0xffff5c388050>)
entering parse_file_info
image/tiff
file_example_TIFF_5MB.tiff
BASE CONSTRUCTOR
('image/tiff', <gallery.file_modules.tiff.TIFFFile object at 0xffff5c388050>)
entering parse_file_info
application/octet-stream
Canon-eos-r-raw-00001.cr3
('application/octet-stream', None)…wpy instead of by extensions
Create file modules for .NEF, .MOV, .HEIC, .M4A files
Introduces new library requirements to properly render RAW (.NEF) files and HEIC files with HDR data (see requirements.txt, nef.py, heic.py, file_modules/init.py)
Proof of it working can be seen on gallery/dev in the
file-type-testfolder. The only issue remaining is that .NEF files render really blurry, but when downloaded, they look normal