From 930d0d94f8d683ad9823e542b0a00d3a41c660e5 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 4 Dec 2022 23:46:33 +0000 Subject: [PATCH] diff online --- bluenh.1.htm | 12 +-- df.png | Bin 0 -> 3000 bytes diff-cgi.c | 187 +++++++++++++++++++++++++++++++++++++++++++ diff.1.htm | 17 ++++ enhance-top.htm | 3 +- enhance.1.conf | 13 +-- makefile | 12 ++- makefile.1.mak | 12 ++- online-core.1.h | 1 + settings-release.txt | 1 + settings.txt | 4 + 11 files changed, 241 insertions(+), 21 deletions(-) create mode 100644 df.png create mode 100644 diff-cgi.c create mode 100644 diff.1.htm 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 0000000000000000000000000000000000000000..e43537ee934505e404715fe5e19a36a1d0ae8163 GIT binary patch literal 3000 zcmb7`cQhN07RMu0?M>~y)o6o+nnBboY8FMU*4{K~mYSioq-JfkH=$^Z3aW`v+Nu$y zcJR}x7Ln(?^ZtD2yz~CJ_n!OjcbxM{voJSgq~oOn004|exAmBm*3puFp6Xh5e9TpCtt_2O1t_TZN^8bGDyxd_mQ_FwVse4716gm(ZG%rnYkA^4H75!}wY3xJ}(CdGOJ$!o+dn*SNVTb?ZcRx5FJvg00<0%6-zG z=sqbbONnf)LXqC(;8TU}oi16wa8tH~qWTj=<1oh%`V(|MhEXNk^3Ag`^w(c>FX3hZ z&SPXtJ4z>VZ*+Xe!7bCZJYvUFsrYE$9dU;|E50qha4yI!4&%1=Dh;Z%_rSotKsc8E z(yPw!hvGX5(NiQY%#4JJ&w%zQMiBMx$DJz*8gWc;rD7(xh0Mv;x5_;R?rldou(-aF zcx{@@G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!TdZ)SUh8nJZyemb0K_LC_+8|MCFt!jt;V%FxBI=MWI*1c7)7(6uYw zd9JAa#HHsgw=6kic+>vAVv2i4ogz^}U$Eo-)wZ4mmPkIx34Bii?)^YOO9&c5Cfl9q;zrVyx85@@rb!DL#qiHdO>vynSR3y7hUtQZ&8)g!SYqH_^=Hg7mB;bzUTu1h5kO-Oow<$7qba`%sCq+E{QykDn zc>H3W9VH?uQ|1|HwzS4Zm^b`hzN%&vwedBrM938x-Ra3n^uc|zv; zb6ylDCpUC#o&|i3M{}s`D(&uJ>x(Vk^`nnLG;X0gxQEZ@-*~)y3N7arqsg9`n&u}a zkK_b4k2_X+R%LrS*Up%$oWE|W)D&SMUZuAy+c?3*V;p0jdp{|R{$5jK{Ik?bl-Rnz z?h+LCGL3z~>#V!Q5c3|D!vQSUqDHy?*!4*m(1+$vO+ykx6`}A7&;w%1R>d*hD7OQ% v&6bu{)S>VtSeCV!{(t!T-zb-NG>$?MZ)08`ApG-^$N@$M=K9T0*TjDTZ%3M6 literal 0 HcmV?d00001 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) -- 2.30.2