Skip to content

Instantly share code, notes, and snippets.

@dbast
Last active December 30, 2015 02:09
Show Gist options
  • Save dbast/7760407 to your computer and use it in GitHub Desktop.
Save dbast/7760407 to your computer and use it in GitHub Desktop.
uniform_exposure.py tiff patch (--out-depth=16)
--- uniform_exposure.py 2013-12-02 22:12:21.000000000 +0100
+++ uniform_exposure_patched2.py 2013-12-02 23:27:51.000000000 +0100
@@ -44,6 +44,9 @@
# for the final output (set to None for disabling, try around 128 for flicker-free video/timelapse)
target_median = None
+# jpeg-quality of the final image, between 0 and 100
+jqual = 98
+
raw_dir = 'raw'
out_dir = 'jpg'
tmp_dir = 'tmp'
@@ -274,9 +277,9 @@
for k,f in enumerate(files):
r = os.path.join(raw_dir, f)
j = os.path.join(out_dir, change_ext(f, ".jpg"))
- jm = os.path.join(tmp_dir, change_ext(f, "-m.jpg"))
- jh = os.path.join(tmp_dir, change_ext(f, "-h.jpg"))
- js = os.path.join(tmp_dir, change_ext(f, "-s.jpg"))
+ jm = os.path.join(tmp_dir, change_ext(f, "-m.tif"))
+ jh = os.path.join(tmp_dir, change_ext(f, "-h.tif"))
+ js = os.path.join(tmp_dir, change_ext(f, "-s.tif"))
ufr = change_ext(r, ".ufraw")
lev = change_ext(r, ".LEV")
@@ -346,7 +349,7 @@
shrink = 1 if fullsize == True else (2 if fullsize == False else fullsize)
jpegs = [jm]
print "(midtones)", ; sys.stdout.flush()
- cmd = 'ufraw-batch --out-type=jpg --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, ecm, r, jm, shrink)
+ cmd = 'ufraw-batch --out-type=tiff --out-depth=16 --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, ecm, r, jm, shrink)
run(cmd)
if needs_highlight_recovery:
@@ -354,8 +357,8 @@
print "(highlights", ; sys.stdout.flush()
for ji,e in enumerate(ech):
if ji > 0: print "\b.", ; sys.stdout.flush()
- jp = change_ext(jh, "%d.jpg" % ji)
- cmd = 'ufraw-batch --out-type=jpg --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, e, r, jp, shrink)
+ jp = change_ext(jh, "%d.tif" % ji)
+ cmd = 'ufraw-batch --out-type=tiff --out-depth=16 --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, e, r, jp, shrink)
run(cmd)
jpegs.append(jp)
print "\b)", ; sys.stdout.flush()
@@ -365,8 +368,8 @@
print "(shadows", ; sys.stdout.flush()
for ji,e in enumerate(ecs):
if ji > 0: print "\b.", ; sys.stdout.flush()
- jp = change_ext(js, "%d.jpg" % ji)
- cmd = 'ufraw-batch --out-type=jpg --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, e, r, jp, shrink)
+ jp = change_ext(js, "%d.tif" % ji)
+ cmd = 'ufraw-batch --out-type=tiff --out-depth=16 --overwrite %s --exposure=%s "%s" --output="%s" --shrink=%d' % (ufraw_options, e, r, jp, shrink)
run(cmd)
jpegs.append(jp)
print "\b)", ; sys.stdout.flush()
@@ -374,12 +377,12 @@
if needs_highlight_recovery or needs_shadow_recovery:
# blend highlights and shadows
print "(enfuse)", ; sys.stdout.flush()
- cmd = 'enfuse --gray-projector=value --saturation-weight=0 --exposure-sigma=0.3 -o "%s" %s' % (j, " ".join(['"%s"' % ji for ji in jpegs]))
+ cmd = 'enfuse --gray-projector=value --saturation-weight=0 --exposure-sigma=0.3 --compression %s -o "%s" %s' % (jqual, j, " ".join(['"%s"' % ji for ji in jpegs]))
run(cmd)
else:
# nothing to blend
- print "(copy)", ; sys.stdout.flush()
- shutil.copy(jm, j)
+ print "(convert)", ; sys.stdout.flush()
+ run("convert --quality %s %s %s" % (jqual, jm, j))
if target_median:
gamma_correction(j, target_median)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment