tAdd reciprocity failure program - filmtools - various tools for photographic f… | |
git clone git://src.adamsgaard.dk/filmtools | |
Log | |
Files | |
Refs | |
--- | |
commit 3546ae81af5a877bae48e2e2592c504cebc0dc1a | |
parent 3e5d5e3b1968d4e4fabc24578adfa551d4331766 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 16 Jul 2020 22:09:51 +0200 | |
Add reciprocity failure program | |
Diffstat: | |
A reciprocity.1 | 50 +++++++++++++++++++++++++++++… | |
A reciprocity.c | 85 +++++++++++++++++++++++++++++… | |
2 files changed, 135 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/reciprocity.1 b/reciprocity.1 | |
t@@ -0,0 +1,50 @@ | |
+.Dd JULY 16, 2020 | |
+.Dt RECIPROCITY 1 | |
+.Os | |
+.Sh NAME | |
+.Nm reciprocity | |
+.Nd calculates compensated exposure time for film reciprocity failure | |
+.Sh SYNOPSIS | |
+.Nm | |
+.Ar film | |
+.Ar time | |
+.Sh DESCRIPTION | |
+Photographic films suffer from low-intensity reciprocity failure | |
+during long exposures (usually >1 s). This program returns the | |
+compensated exposure time. | |
+.Bl -tag -width Ds | |
+.It Ar film | |
+specifies the film type and can be one of the following: | |
+.Bl -bullet -compact | |
+.It | |
+panf | |
+.It | |
+fp4 | |
+.It | |
+hp5 | |
+.It | |
+delta100 | |
+.It | |
+delta400 | |
+.It | |
+delta3200 | |
+.It | |
+sfx | |
+.It | |
+xp2 | |
+.It | |
+acros100 | |
+.It | |
+tmx | |
+.It | |
+tmy | |
+.It | |
+tmz | |
+.It | |
+trix | |
+.El | |
+.It Ar time | |
+is metered exposure time in format MM:SS | |
+.El | |
+.Sh AUTHORS | |
+.An Anders Damsgaard Aq Mt [email protected] | |
diff --git a/reciprocity.c b/reciprocity.c | |
t@@ -0,0 +1,85 @@ | |
+#include <stdio.h> | |
+#include <unistd.h> | |
+#include <err.h> | |
+#include <math.h> | |
+#include <string.h> | |
+ | |
+#define LENGTH(X) (sizeof X / sizeof X[0]) | |
+ | |
+typedef struct { | |
+ const char *manufacturer; | |
+ const char *name; | |
+ double factor; | |
+ double exponent; | |
+} Film; | |
+ | |
+static const Film films[] = { | |
+ { "ilford", "panf", 1.00, 1.33 }, | |
+ { "ilford", "fp4", 1.00, 1.26 }, | |
+ { "ilford", "hp5", 1.00, 1.31 }, | |
+ { "ilford", "delta100", 1.00, 1.26 }, | |
+ { "ilford", "delta400", 1.00, 1.41 }, | |
+ { "ilford", "delta3200", 1.00, 1.33 }, | |
+ { "ilford", "sfx", 1.00, 1.43 }, | |
+ { "ilford", "xp2", 1.00, 1.31 }, | |
+ { "fujifilm", "acros100", 0.96, 1.02 }, | |
+ { "kodak", "tmx", 1.18, 1.13 }, | |
+ { "kodak", "tmy", 1.05, 1.22 }, | |
+ { "kodak", "tmz", 1.34, 1.20 }, | |
+ { "kodak", "trix", 2.41, 1.29 }, | |
+}; | |
+ | |
+char *argv0; | |
+ | |
+static void | |
+usage() | |
+{ | |
+ int i; | |
+ | |
+ printf("usage: %s film time\n", argv0); | |
+ puts("where time is metered exposure time in format MM:SS,"); | |
+ puts("and film is one of the following:"); | |
+ for (i = 0; i < LENGTH(films); i++) | |
+ printf(" %-12s (%s)\n", films[i].name, films[i].manufacture… | |
+} | |
+ | |
+int | |
+main(int argc, char **argv) | |
+{ | |
+ double exponent; | |
+ int i, min, sec, sec_equiv; | |
+ | |
+ argv0 = *argv; | |
+ | |
+#ifdef __OpenBSD__ | |
+ if (pledge("stdio", NULL) == -1) | |
+ errx(1, "pledge"); | |
+#endif | |
+ | |
+ if (argc != 3) { | |
+ usage(); | |
+ errx(1, "incorrect arguments"); | |
+ } | |
+ | |
+ for (i = 0;; i++) { | |
+ if (i == LENGTH(films)) | |
+ errx(3, "unknown film type"); | |
+ if (strncasecmp(argv[1], films[i].name, 10) == 0) { | |
+ exponent = films[i].exponent; | |
+ break; | |
+ } | |
+ } | |
+ | |
+ printf("exponent: %g\n", exponent); | |
+ | |
+ if (sscanf(argv[2], "%d:%d", &min, &sec) != 2) | |
+ errx(2, "could not parse time in MM:SS format"); | |
+ | |
+ sec_equiv = pow(min*60 + sec, exponent); | |
+ | |
+ printf("%d:%02d\n", | |
+ (int)(sec_equiv/60.0), | |
+ (int)(sec_equiv)%60); | |
+ | |
+ return 0; | |
+} |