简体   繁体   中英

Using rawpy to convert multiple raw .NEF Images to TIFF

I have been searching through this forum but cannot find a relevant answer to my problem. I have only found solutions for single file conversions.

I want to convert a directory of Nikon RAW images (.NEF) into TIFF (.tiff). This can be achieved with the rawpy plugin apparently. I am not well versed in python and have done my best. You will probably find my script laughable :)

I'd like to ideally be able to paste the directory path into the command line and have it convert everything for me, into 16-bit tiffs.

import rawpy
import imageio

paths = 'C:\Users\Jake\Desktop\Exposuretests\Darks'

for i in paths:
    with rawpy.imread(paths) as raw:
        rgb = raw.postprocess()
imageio.imsave(paths + '.tiff', rgb)

Thanks all in advance for any help. I am sure this is quite simple for those versed in python!

You can do it very simply without having to write any Python or loops if you use ImageMagick which is installed on most Linux distros and is available for macOS and Windows.

In Terminal, simply type:

magick mogrify -format tif *NEF

I imagine you already fixed this, but there are a few typos:

import rawpy
import imageio

paths = 'C:\Users\Jake\Desktop\Exposuretests\Darks'

for i in paths:
    with rawpy.imread(paths) as raw:
        rgb = raw.postprocess()
    imageio.imsave(paths + '\file_' + i + '.tiff', rgb)

Might do the trick.

Steve

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