From: b Date: Sun, 4 Dec 2022 23:46:33 +0000 (+0000) Subject: diff online X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=930d0d94f8d683ad9823e542b0a00d3a41c660e5;p=ott%2Fenhance diff online --- diff --git a/bluenh.1.htm b/bluenh.1.htm index 1c87660..12d07c6 100644 --- a/bluenh.1.htm +++ b/bluenh.1.htm @@ -2,18 +2,18 @@
parameter explanation picture

- a=, b=, c=,
- d=, e=, f=.
+ a=, b=, c=,
+ d=, e=, f=.
a < b < c

Enhance by URL
URL of image: - -
+ +

Enhance by file upload
Upload the image: - - + +
diff --git a/df.png b/df.png new file mode 100644 index 0000000..e43537e Binary files /dev/null and b/df.png differ diff --git a/diff-cgi.c b/diff-cgi.c new file mode 100644 index 0000000..2707359 --- /dev/null +++ b/diff-cgi.c @@ -0,0 +1,187 @@ +/* +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 . + +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#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; +} + + diff --git a/diff.1.htm b/diff.1.htm new file mode 100644 index 0000000..054500d --- /dev/null +++ b/diff.1.htm @@ -0,0 +1,17 @@ +

See the difference!

+
+ Enhance by URL
+ URL 1:
+ URL 2:
+
+ Enhance by file upload
+ File 1:
+ File 2:
+
+ Color A:
+ R=, G=, B=
+ Color B:
+ R=, G=, B=
+
+
+
\ No newline at end of file diff --git a/enhance-top.htm b/enhance-top.htm index df6f770..94172fa 100644 --- a/enhance-top.htm +++ b/enhance-top.htm @@ -2,7 +2,8 @@ ###HTML_TITLE; • Bicycles on the Moon - + + diff --git a/enhance.1.conf b/enhance.1.conf index 8dbf99f..4a138c7 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -1,6 +1,7 @@ # Enhance tools ScriptAlias /enhance/bluenh ###CONF_bluenh; +ScriptAlias /enhance/diff ###CONF_diff; ScriptAlias /enhance/nofading ###CONF_nofading; ScriptAlias /enhance/reveal ###CONF_reveal; @@ -9,9 +10,9 @@ ScriptAlias /enhance/reveal ###CONF_reveal; # 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 diff --git a/makefile b/makefile index 1af611e..6fe3179 100644 --- a/makefile +++ b/makefile @@ -107,22 +107,26 @@ npb_ong1.h\ npb_403.h\ nh.h\ nf.h\ -rvl.h +rvl.h\ +df.h CGI=\ bluenh-cgi\ nofading-cgi\ -reveal-cgi +reveal-cgi\ +diff-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ -reveal.htm +reveal.htm\ +diff.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ -reveal.1.htm +reveal.1.htm\ +diff.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/makefile.1.mak b/makefile.1.mak index 58ce7ab..914f0de 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -107,22 +107,26 @@ npb_ong1.h\ npb_403.h\ nh.h\ nf.h\ -rvl.h +rvl.h\ +df.h CGI=\ bluenh-cgi\ nofading-cgi\ -reveal-cgi +reveal-cgi\ +diff-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ -reveal.htm +reveal.htm\ +diff.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ -reveal.1.htm +reveal.1.htm\ +diff.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/online-core.1.h b/online-core.1.h index 6b8f870..46e935b 100644 --- a/online-core.1.h +++ b/online-core.1.h @@ -33,6 +33,7 @@ Requires cgilib (http://www.infodrom.org/projects/cgilib/) // ###C_TEMP_PATH: #define TEMP_PATH "/botm/tmp/enhance" // ###C_BLUENH_PATH: #define NPB_PATH "/botm/bin/bluenh" +// ###C_DIFF_PATH: #define DIFF_PATH "/botm/bin/diff" // ###C_NOFADING_PATH: #define NOFADING_PATH "/botm/bin/nofading" // ###C_NPB_PATH: #define NPB_PATH "/botm/bin/npb" // ###C_REVEAL_PATH: #define REVEAL_PATH "/botm/bin/reveal" diff --git a/settings-release.txt b/settings-release.txt index 2350af8..eed7ff2 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -14,6 +14,7 @@ configure: /botm/bin/config/configure.pl useragent: ENHANCE!ment tool (http://1190.bicyclesonthemoon.info/enhance) title_bluenh: ENHANCE! +title_diff: See the difference! title_enhance: ENHANCE! title_nofading: No fading! title_reveal: Reveal hidden detail! diff --git a/settings.txt b/settings.txt index 202c4ec..a2294a6 100644 --- a/settings.txt +++ b/settings.txt @@ -21,6 +21,8 @@ _C_DEFINE_STR: #define $0 "@_ESCAPE($1)" _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) @@ -35,6 +37,7 @@ HTML_TITLE = @_HTML_TITLE() 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 @@ -70,6 +73,7 @@ C_RM_PATH = @_C_DEFINE_STR(RM_PATH, $rm) 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)