<form method="post" action="/enhance/bluenh" enctype='multipart/form-data'>
<img src="param.png" alt="parameter explanation picture"><br>
<br>
- a=<input type="text" name="a" value= "0">, b=<input type="text" name="b" value= "34">, c=<input type="text" name="c" value= "41">,<br>
- d=<input type="text" name="d" value= "0">, e=<input type="text" name="e" value= "40">, f=<input type="text" name="f" value="255">.<br>
+ a=<input class="pt" type="text" name="a" value= "0">, b=<input class="pt" type="text" name="b" value= "34">, c=<input class="pt" type="text" name="c" value= "41">,<br>
+ d=<input class="pt" type="text" name="d" value= "0">, e=<input class="pt" type="text" name="e" value= "40">, f=<input class="pt" type="text" name="f" value="255">.<br>
a < b < c<br>
<br>
Enhance by URL<br>
URL of image:
- <input type="text" name="inpix">
- <input type="submit" value="ENHANCE!"><br>
+ <input class="pt" type="text" name="inpix">
+ <input class="pk" type="submit" value="ENHANCE!"><br>
<br>
Enhance by file upload<br>
Upload the image:
- <input type="file" name="inpix2">
- <input type="submit" value="ENHANCE!">
+ <input class="pt" type="file" name="inpix2">
+ <input class="pk" type="submit" value="ENHANCE!">
</form>
--- /dev/null
+/*
+diff-cgi.c
+The online interface for the differential tool
+04.12.2022
+
+Copyright (C) 2022 Balthasar SzczepaĆski
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Requires cgilib (http://www.infodrom.org/projects/cgilib/)
+*/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <cgi.h>
+
+#include "online-core.h"
+#include "df.h"
+
+#define RA 0x00
+#define GA 0x57
+#define BA 0xAF
+#define RB 0xBB
+#define GB 0x66
+#define BB 0x22
+
+int diff (
+ char *inpix0, char *inpix1, char *outpix,
+ uint_fast8_t ra, uint_fast8_t ga, uint_fast8_t ba,
+ uint_fast8_t rb, uint_fast8_t gb, uint_fast8_t bb
+);
+
+int main (int argc, char *argv[])
+{
+ s_cgi *cgi;
+ char in0_tmp[256];
+ char in1_tmp[256];
+ char out_tmp[256];
+ char *in0_path;
+ char *in1_path;
+ char *t;
+ uint_fast8_t ra, ga, ba, rb, gb, bb;
+
+ int r=0;
+ int r1=0;
+ int r2=0;
+ int r3=0;
+ int r4=0;
+
+ do {
+ make_tmp_path(in0_tmp, 256, 0, "");
+ make_tmp_path(in1_tmp, 256, 1, "");
+ make_tmp_path(out_tmp, 256, 2, ".png");
+
+ cgi=cgiInit();
+
+ r = get_file(cgi,"inpixf0", in0_tmp, &in0_path);
+ if (r)
+ r = get_file(cgi,"inpix0", in0_tmp, &in0_path);
+ if (r)
+ break;
+
+ r = get_file(cgi,"inpixf1", in1_tmp, &in1_path);
+ if (r)
+ r = get_file(cgi,"inpix1", in1_tmp, &in1_path);
+ if (r)
+ break;
+
+ t = cgiGetValue(cgi, "ra");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &ra);
+ else
+ ra = RA;
+
+ t = cgiGetValue(cgi, "ga");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &ga);
+ else
+ ga = GA;
+
+ t = cgiGetValue(cgi, "ba");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &ba);
+ else
+ ba = BA;
+
+ t = cgiGetValue(cgi, "rb");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &rb);
+ else
+ rb = RB;
+
+ t = cgiGetValue(cgi, "gb");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &gb);
+ else
+ gb = GB;
+
+ t = cgiGetValue(cgi, "bb");
+ if (t != NULL)
+ sscanf(t,"%"SCNuFAST8, &bb);
+ else
+ bb = BB;
+
+ r = diff(in0_path, in1_path, out_tmp, ra, ga, ba, rb, gb, bb);
+ if (r)
+ break;
+
+ r1 = send_file(out_tmp, "image/png", 0);
+ } while (0);
+ if (r)
+ {
+ r1 = send_data(df, df_size, "image/png", 500);
+ }
+ r2 = rm(in0_tmp);
+ r3 = rm(in1_tmp);
+ r4 = rm(out_tmp);
+ if (r)
+ return r;
+ if (r1)
+ return r1;
+ if (r2)
+ return r2;
+ if (r3)
+ return r3;
+ if (r4)
+ return r4;
+ return 0;
+}
+
+int diff (
+ char *inpix0, char *inpix1, char *outpix,
+ uint_fast8_t ra, uint_fast8_t ga, uint_fast8_t ba,
+ uint_fast8_t rb, uint_fast8_t gb, uint_fast8_t bb
+)
+{
+ char s_ra[4];
+ char s_ga[4];
+ char s_ba[4];
+ char s_rb[4];
+ char s_gb[4];
+ char s_bb[4];
+
+ pid_t sub;
+ int r;
+
+ snprintf(s_ra, 4, "%"SCNuFAST8, ra);
+ snprintf(s_ga, 4, "%"SCNuFAST8, ga);
+ snprintf(s_ba, 4, "%"SCNuFAST8, ba);
+ snprintf(s_rb, 4, "%"SCNuFAST8, rb);
+ snprintf(s_gb, 4, "%"SCNuFAST8, gb);
+ snprintf(s_bb, 4, "%"SCNuFAST8, bb);
+
+ sub = fork();
+ if (sub == 0)
+ {
+ r = execl(
+ DIFF_PATH, DIFF_PATH,
+ inpix0, inpix1, outpix,
+ s_ra, s_ga, s_ba,
+ s_rb, s_gb, s_bb,
+ (char *)0
+ );
+ exit(r);
+ }
+ waitpid(sub, &r, 0);
+ return r;
+}
+
+
# Enhance tools
ScriptAlias /enhance/bluenh ###CONF_bluenh;
+ScriptAlias /enhance/diff ###CONF_diff;
ScriptAlias /enhance/nofading ###CONF_nofading;
ScriptAlias /enhance/reveal ###CONF_reveal;
</Directory>
# legacy redirections
-#Redirect permanent /pro http://bicyclesonthemoon.info/git-projects/?p=ott/enhance
-#Redirect permanent /pro/npb/npb.htm /enhance/npb.htm
-#Redirect permanent /pro/npb/403.htm /enhance/403.htm
-#Redirect permanent /pro/bluenh/bluenh.htm /enhance/bluenh.htm
-#Redirect permanent /pro/nofading/nofading.htm /enhance/nofading.htm
-#Redirect permanent /pro/nofading/insertframe.htm /enhance/pal.htm
\ No newline at end of file
+Redirect permanent /pro/npb/npb.htm /enhance/npb.htm
+Redirect permanent /pro/npb/403.htm /enhance/403.htm
+Redirect permanent /pro/bluenh/bluenh.htm /enhance/bluenh.htm
+Redirect permanent /pro/nofading/nofading.htm /enhance/nofading.htm
+Redirect permanent /pro/nofading/insertframe.htm /enhance/pal.htm
+Redirect permanent /pro http://bicyclesonthemoon.info/git-projects/?p=ott/enhance&
\ No newline at end of file
_bin_bluenh_path = @_PATH($bin_path, bluenh)
_bin_bluenh_cgi_path = @_PATH($bin_path, bluenh-cgi)
+_bin_diff_path = @_PATH($bin_path, diff)
+_bin_diff_cgi_path = @_PATH($bin_path, diff-cgi)
_bin_nofading_path = @_PATH($bin_path, nofading)
_bin_nofading_cgi_path = @_PATH($bin_path, nofading-cgi)
_bin_npb_path = @_PATH($bin_path, npb)
CONF_bin = $bin_path
CONF_bluenh = $_bin_bluenh_cgi_path
+CONF_diff = $_bin_diff_cgi_path
CONF_nofading = $_bin_nofading_cgi_path
CONF_reveal = $_bin_reveal_cgi_path
C_TEMP_PATH = @_C_DEFINE_STR(TEMP_PATH, $tmp_path)
C_BLUENH_PATH = @_C_DEFINE_STR(BLUENH_PATH, $_bin_bluenh_path)
+C_DIFF_PATH = @_C_DEFINE_STR(DIFF_PATH, $_bin_diff_path)
C_NOFADING_PATH = @_C_DEFINE_STR(NOFADING_PATH, $_bin_nofading_path)
C_NPB_PATH = @_C_DEFINE_STR(NPB_PATH, $_bin_npb_path)
C_REVEAL_PATH = @_C_DEFINE_STR(REVEAL_PATH, $_bin_reveal_path)