简体   繁体   中英

opening images with Python PIL

I am using a sample NEF and expecting a 4288×2848 image, but get 160x120 with the code below. Is this as expected in that PIL doesn't support NEF?

from PIL import Image
image="./blah.nef"
im=Image.open(image)
im.size

You're getting the JPEG thumbnail embedded in the NEF. It's pretty cool that it got far enough into the file to find the thumbnail.

Did you check the Python Image Library's documentation ? I don't see the Nikon RAW format (NEF) in the list of supported image formats. You'll need to find a library or application that explicitly supports this format, such as UFRaw .

I know the question's old, but you can use rawpy nowadays:

#!/usr/bin/env python3

import rawpy
import imageio

with rawpy.imread('blah.nef') as raw:
    rgb = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)

# Extract individual bands for fun
R = rgb[:,:,0]
G = rgb[:,:,1]
B = rgb[:,:,2]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM