Escribí una biblioteca pure-python recientemente llamada rawphoto
para procesar imágenes en bruto en python. Actualmente solo es compatible con los archivos Canon CR2 (próximamente agregaré formatos Nikon). También está en PyPi. Puede ser útil para usted si está accediendo a archivos CR2.
Ejemplo de extraer el JPEG previsualización de la imagen:
from rawphoto.cr2 import Cr2
blob = Cr2(filename="somefile.CR2").get_quarter_size_rgb()
# Do something with the JPEG here... eg. save it:
with open("output.jpeg", 'wb' as f:
f.write(blob)
o, utilizando la clase genérica Raw
que envolver cualquier tipo de archivo en bruto como añado más:
from rawphoto.raw import Raw
# The API here will probably change before the 1.0 release.
blob = Raw(filename="somefile.CR2").fhandle.get_quarter_size_rgb()
# Do something with the JPEG here... eg. save it:
with open("output.jpeg", 'wb' as f:
f.write(blob)
EDITAR: Esto ha sido reemplazado por rawkit, enlaces de libraw basados en ctypes. RawKit funcionará mucho mejor y deberías usarlo en su lugar (rawphoto ahora va a estar en desuso y solo se usa como una herramienta educativa).
PIL no hace RAW (al menos, no CR2 o DCR). – Seth