PYTHON   44

nef2exr.py

Guest on 10th August 2021 05:03:04 PM

  1. #!/usr/bin/env python import os import sys from vop import * import OpenEXR import Imath dc = os.popen("dcraw -c -4 \"%s\"" % sys.argv[1], "r") dc.readline() (xs,ys) = [int(x) for x in dc.readline().split()] dc.readline()
  2.  out = OpenEXR.OutputFile(sys.argv[2],
  3. OpenEXR.Header(xs, ys)) for y in range(0, ys): # Read a line of interleaved RGB 16-bit big-endian samples raw = dc.read(xs * 3 * 2)
  4.  # Extract every sixth byte into six arrays sixth = [ array(raw[n:len(raw):6]) for n in range(6) ] # Reconstruct seperate R,G,B channels red = sixth[0] * 256 + sixth[1] grn = sixth[2] * 256 + sixth[3] blu = sixth[4] * 256 + sixth[5]
  5. # Write out the line to the EXR file out.writePixels({'R': red.toraw(), 'G' : grn.toraw(), 'B' : blu.toraw()}, 1) out.close()

Raw Paste


Login or Register to edit or fork this paste. It's free.