简体   繁体   中英

Convert a RAW image to TIFF in python but keep the metadata

I tried converting a raw image to tiff, but I want it to keep the metadata. This is the code I was using earlier:

import rawpy, imageio, os
with rawpy.imread(path) as raw:
   rgb = raw.postprocess()
imageio.imsave('default.tiff', rgb)

If you are interested in, and actively using EXIF data, you will almost certainly need exiftool installed on your machine - a Perl script by Phil Harvey. That being the case, it is probably easiest to do your image processing with rawpy as you are already to produce a TIFF file, then use exiftool to copy forward the EXIF data from your raw file.

So, in concrete terms, if your raw file is Nikon.nef you would open that and do your rawpy image processing to make Nikon.tif , then shell out (or use the Python binding) and run:

exiftool -TagsFromFile Nikon.nef Nikon.tif

which will transfer the EXIF data from your raw file to your TIFF file.

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