简体   繁体   English

使用Python PIL打开图像

[英]opening images with Python PIL

I am using a sample NEF and expecting a 4288×2848 image, but get 160x120 with the code below. 我正在使用样本NEF并期待4288×2848的图像,但是使用下面的代码可获得160x120。 Is this as expected in that PIL doesn't support NEF? 这是因为PIL不支持NEF吗?

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

You're getting the JPEG thumbnail embedded in the NEF. 您将在NEF中嵌入JPEG缩略图。 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 ? 您是否检查了Python图像库的文档 I don't see the Nikon RAW format (NEF) in the list of supported image formats. 我在支持的图像格式列表中没有看到Nikon RAW格式(NEF)。 You'll need to find a library or application that explicitly supports this format, such as UFRaw . 您需要找到一个明确支持这种格式的库或应用程序,例如UFRaw

I know the question's old, but you can use rawpy nowadays: 我知道这个问题很旧,但是现在您可以使用rawpy

#!/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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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