Skip to content

Add Support for more file types: .NEF, .MOV, .HEIC, .M4A#129

Open
Log45 wants to merge 3 commits intoComputerScienceHouse:developfrom
Log45:develop
Open

Add Support for more file types: .NEF, .MOV, .HEIC, .M4A#129
Log45 wants to merge 3 commits intoComputerScienceHouse:developfrom
Log45:develop

Conversation

@Log45
Copy link

@Log45 Log45 commented Feb 12, 2026

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-test folder. The only issue remaining is that .NEF files render really blurry, but when downloaded, they look normal

Copy link
Contributor

@mxmeinhold mxmeinhold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any header info the file gives us rather than relying on extensions? Extensions are brittle and icky imo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid, I can look into that but don't know anything about file headers, will see if I can make something work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@mxmeinhold mxmeinhold mentioned this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants