From 35cfa21aecb2cb736630a7bbdc2a5551dd46f3c1 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 4 Dec 2022 22:08:39 +0000 Subject: [PATCH] nofading online --- bluenh-cgi.c | 66 ++++++++++------ enhance-bottom.htm | 4 +- enhance.1.conf | 11 ++- makefile | 14 ++-- makefile.1.mak | 14 ++-- nofading-cgi.c | 174 ++++++++++++++++++++++++++++++++++--------- nofading.1.htm | 28 ++----- nofading.c | 4 +- online-core.1.h | 5 +- settings-release.txt | 1 + settings.txt | 20 +++-- 11 files changed, 238 insertions(+), 103 deletions(-) diff --git a/bluenh-cgi.c b/bluenh-cgi.c index 08d41e5..aa431db 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -1,5 +1,5 @@ /* -bluenh-cgi.c is autogenerated from bluenh-cgi.1.c +bluenh-cgi.c Online interface for npb 04.12.2022 @@ -26,13 +26,19 @@ Requires cgilib (http://www.infodrom.org/projects/cgilib/) #include #include #include +#include +#include #include #include "online-core.h" #include "nh.h" -int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f); +int bluenh ( + char *inpix, char *outpix, + uint_fast8_t a, uint_fast8_t b, uint_fast8_t c, + uint_fast8_t d, uint_fast8_t e, uint_fast8_t f +); int main (int argc, char *argv[]) { @@ -41,7 +47,7 @@ int main (int argc, char *argv[]) char out_tmp[256]; char *in_path; char *t; - unsigned a, b, c, d, e, f; + uint_fast8_t a, b, c, d, e, f; int r=0; int r1=0; @@ -54,43 +60,45 @@ int main (int argc, char *argv[]) cgi=cgiInit(); - r = get_file(cgi,"inpix", in_tmp, &in_path); + r = get_file(cgi,"inpix2", in_tmp, &in_path); + if (r) + r = get_file(cgi,"inpix", in_tmp, &in_path); if (r) break; t = cgiGetValue(cgi, "a"); if (t != NULL) - sscanf(t,"%u",&a); + sscanf(t,"%"SCNuFAST8, &a); else a = 0; t = cgiGetValue(cgi, "b"); if (t != NULL) - sscanf(t,"%u",&b); + sscanf(t,"%"SCNuFAST8, &b); else b = 0; t = cgiGetValue(cgi, "c"); if (t != NULL) - sscanf(t,"%u",&c); + sscanf(t,"%"SCNuFAST8, &c); else c = 0; t = cgiGetValue(cgi, "d"); if (t != NULL) - sscanf(t,"%u",&d); + sscanf(t,"%"SCNuFAST8, &d); else d = 0; t = cgiGetValue(cgi, "e"); if (t != NULL) - sscanf(t,"%u",&e); + sscanf(t,"%"SCNuFAST8, &e); else e = 0; t = cgiGetValue(cgi, "f"); if (t != NULL) - sscanf(t,"%u",&f); + sscanf(t,"%"SCNuFAST8, &f); else f = 0; @@ -117,29 +125,39 @@ int main (int argc, char *argv[]) return 0; } -int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f) +int bluenh ( + char *inpix, char *outpix, + uint_fast8_t a, uint_fast8_t b, uint_fast8_t c, + uint_fast8_t d, uint_fast8_t e, uint_fast8_t f +) { - char ca[4]; - char cb[4]; - char cc[4]; - char cd[4]; - char ce[4]; - char cf[4]; + char s_a[4]; + char s_b[4]; + char s_c[4]; + char s_d[4]; + char s_e[4]; + char s_f[4]; pid_t sub; int r; - snprintf(ca, 4, "%u", a); - snprintf(cb, 4, "%u", b); - snprintf(cc, 4, "%u", c); - snprintf(cd, 4, "%u", d); - snprintf(ce, 4, "%u", e); - snprintf(cf, 4, "%u", f); + snprintf(s_a, 4, "%"SCNuFAST8, a); + snprintf(s_b, 4, "%"SCNuFAST8, b); + snprintf(s_c, 4, "%"SCNuFAST8, c); + snprintf(s_d, 4, "%"SCNuFAST8, d); + snprintf(s_e, 4, "%"SCNuFAST8, e); + snprintf(s_f, 4, "%"SCNuFAST8, f); sub = fork(); if (sub == 0) { - r = execl(BLUENH_PATH, BLUENH_PATH, inpix, outpix, ca, cb, cc, cd, ce, cf, (char *)0); + r = execl( + BLUENH_PATH, BLUENH_PATH, + inpix, outpix, + s_a, s_b, s_c, + s_d, s_e, s_f, + (char *)0 + ); exit(r); } waitpid(sub, &r, 0); diff --git a/enhance-bottom.htm b/enhance-bottom.htm index 2b9e22c..9fca815 100644 --- a/enhance-bottom.htm +++ b/enhance-bottom.htm @@ -1,5 +1,5 @@
-
- Source code available at http://bicyclesonthemoon.info/git-projects/?p=ott/enhance. + Source code available at http://bicyclesonthemoon.info/git-projects/?p=ott/enhance.
+ Licensed under AGPL 3. diff --git a/enhance.1.conf b/enhance.1.conf index dc7b2cf..47f21d2 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -1,7 +1,16 @@ # Enhance tools -ScriptAlias /enhance/bluenh ###CONF_bluenh; +ScriptAlias /enhance/bluenh ###CONF_bluenh; +ScriptAlias /enhance/nofading ###CONF_nofading; Require all granted + +# 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 diff --git a/makefile b/makefile index 5d6ad88..9998d0d 100644 --- a/makefile +++ b/makefile @@ -105,16 +105,20 @@ npb1.h\ npb2.h\ npb_ong1.h\ npb_403.h\ -nh.h +nh.h\ +nf.h CGI=\ -bluenh-cgi +bluenh-cgi\ +nofading-cgi HTM_CGI=\ -bluenh.htm +bluenh.htm\ +nofading.htm HTM_CGI_1=\ -bluenh.1.htm +bluenh.1.htm\ +nofading.1.htm\ # keep these 2 lists in the same order!: @@ -177,7 +181,7 @@ f2h: f2h.c $(CC) $(CF) -o f2h f2h.c $(HTM_CGI): %.htm: enhance-top.htm enhance-bottom.htm %.1.htm $(CONFIGFILE) - $(CAT) enhance-top.htm $*.1.htm enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_$* $(CONFIGFILE) > bluenh.htm + $(CAT) enhance-top.htm $*.1.htm enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_$* $(CONFIGFILE) > $*.htm index.htm: enhance-top.htm enhance-bottom.htm $(HTM_CGI_1) $(CONFIGFILE) $(CAT) enhance-top.htm $(HTM_CGI_1) enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_enhance $(CONFIGFILE) > index.htm diff --git a/makefile.1.mak b/makefile.1.mak index 3ea26f6..b54178c 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -105,16 +105,20 @@ npb1.h\ npb2.h\ npb_ong1.h\ npb_403.h\ -nh.h +nh.h\ +nf.h CGI=\ -bluenh-cgi +bluenh-cgi\ +nofading-cgi HTM_CGI=\ -bluenh.htm +bluenh.htm\ +nofading.htm HTM_CGI_1=\ -bluenh.1.htm +bluenh.1.htm\ +nofading.1.htm\ # keep these 2 lists in the same order!: @@ -177,7 +181,7 @@ f2h: f2h.c $(CC) $(CF) -o f2h f2h.c $(HTM_CGI): %.htm: enhance-top.htm enhance-bottom.htm %.1.htm $(CONFIGFILE) - $(CAT) enhance-top.htm $*.1.htm enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_$* $(CONFIGFILE) > bluenh.htm + $(CAT) enhance-top.htm $*.1.htm enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_$* $(CONFIGFILE) > $*.htm index.htm: enhance-top.htm enhance-bottom.htm $(HTM_CGI_1) $(CONFIGFILE) $(CAT) enhance-top.htm $(HTM_CGI_1) enhance-bottom.htm | $(CONFIGURE) _HTML_TITLE=\$$title_enhance $(CONFIGFILE) > index.htm diff --git a/nofading-cgi.c b/nofading-cgi.c index 2c20885..5b4f065 100644 --- a/nofading-cgi.c +++ b/nofading-cgi.c @@ -1,37 +1,141 @@ -// nofadingd.cpp -// The online interface for the fading enhancement tool -// 04.03.2015 -// -// Copyright (C) 2015 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/) -// line 146 of cgi.h must be changed from: -// extern } -// to: -// } - -by balthasar_s - Fri Jun 12, 2015 6:59 am UTC - - Forum: Individual XKCD Comic Threads - Topic: 1190: "Time" - Replies: 93408 - Views: 10895653 +/* +nofading-cgi.c +The online interface for the fading enhancement tool +04.12.2022 +Copyright (C) 2015, 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 "nf.h" + +int nofading ( + char *inpix, char *outpix, + uint_fast32_t border, + uint_fast8_t individual_channels, + uint_fast8_t enhance_alpha, + uint_fast8_t remove_alpha +); + +int main (int argc, char *argv[]) +{ + s_cgi *cgi; + char in_tmp[256]; + char out_tmp[256]; + char *in_path; + char *t; + uint_fast32_t border; + uint_fast8_t individual_channels, enhance_alpha, remove_alpha; + + int r=0; + int r1=0; + int r2=0; + int r3=0; + + do { + make_tmp_path(in_tmp, 256, 0, ""); + make_tmp_path(out_tmp, 256, 1, ".png"); + + cgi=cgiInit(); + + r = get_file(cgi,"inpix", in_tmp, &in_path); + if (r) + break; + + individual_channels = (cgiGetValue(cgi, "c")!=NULL) ? 0 : 1; + enhance_alpha = (cgiGetValue(cgi, "a")!=NULL) ? 1 : 0; + remove_alpha = (cgiGetValue(cgi, "n")!=NULL) ? 1 : 0; + + t = cgiGetValue(cgi, "f"); + if (t != NULL) + sscanf(t,"%"SCNuFAST32, &border); + else + border = 0; + + r = nofading( + in_path, out_tmp, + border, + individual_channels, enhance_alpha, remove_alpha + ); + if (r) + break; + r1 = send_file(out_tmp, "image/png", 0); + } while (0); + if (r) + { + r1 = send_data(nf, nf_size, "image/png", 500); + } + r2 = rm(in_tmp); + r3 = rm(out_tmp); + if (r) + return r; + if (r1) + return r1; + if (r2) + return r2; + if (r3) + return r3; + return 0; +} + +int nofading ( + char *inpix, char *outpix, + uint_fast32_t border, + uint_fast8_t individual_channels, + uint_fast8_t enhance_alpha, + uint_fast8_t remove_alpha +) +{ + char s_border[11]; + pid_t sub; + int r; + + snprintf(s_border, 11, "%"PRIuFAST32, border); + + sub = fork(); + if (sub == 0) + { + r = execl( + NOFADING_PATH, NOFADING_PATH, + individual_channels ? "-c" : "-0", + enhance_alpha ? "-a" : "-0", + remove_alpha ? "-n" : "-0", + inpix, outpix, + s_border, + (char *)0 + ); + exit(r); + } + waitpid(sub, &r, 0); + return r; +} + +/* #include @@ -145,4 +249,6 @@ void mustard(int mustard) fclose(pix); } exit(mustard); -} \ No newline at end of file +} + +*/ \ No newline at end of file diff --git a/nofading.1.htm b/nofading.1.htm index e770989..9326bc9 100644 --- a/nofading.1.htm +++ b/nofading.1.htm @@ -1,36 +1,24 @@ - - - - No fading! • Bicycles on the Moon - - - - - - 1190.bicyclesonthemoon.info

No fading!

-
+ Enhance by URL
URL of image: border width:
- ignore color-fading + ignore color-fading + remove alpha + enhance alpha

-
+ Enhance by file upload
Upload the image: border width:
- ignore color-fading + ignore color-fading + remove alpha + enhance alpha
-
- Source code available at http://1190.bicyclesonthemoon.info/pro/nofading.
- Livensed under AGPL 3. - - - diff --git a/nofading.c b/nofading.c index acd888f..f3048ba 100644 --- a/nofading.c +++ b/nofading.c @@ -1,7 +1,7 @@ /* nofading.c The tool to remove fading from an image -29.11.2022 +04.12.2022 Copyright (C) 2015, 2022 Balthasar Szczepański @@ -90,7 +90,7 @@ int subtool_nofading (int argc, char **argv, int argi, char **err) {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; - char short_options[] = "acfh"; + char short_options[] = "acfh0"; int opt; int r; diff --git a/online-core.1.h b/online-core.1.h index eb15e33..71fecfc 100644 --- a/online-core.1.h +++ b/online-core.1.h @@ -32,8 +32,9 @@ 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_NPB_PATH: #define NPB_PATH "/botm/bin/npb" +// ###C_BLUENH_PATH: #define NPB_PATH "/botm/bin/bluenh" +// ###C_NOFADING_PATH: #define NOFADING_PATH "/botm/bin/nofading" +// ###C_NPB_PATH: #define NPB_PATH "/botm/bin/npb" int cp (char *src, char *dst); int wget (char *url, char *dst); diff --git a/settings-release.txt b/settings-release.txt index 9af4347..57b49c1 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_enhance: ENHANCE! +title_nofading: No fading! title_bluenh: ENHANCE! bin_path: /botm/bin/enhance diff --git a/settings.txt b/settings.txt index 85ad2fa..56e70fb 100644 --- a/settings.txt +++ b/settings.txt @@ -19,18 +19,21 @@ _C_DEFINE_STR: #define $0 "@_ESCAPE($1)" # _C_INCLUDE_STR: #include "@_ESCAPE($0)" -_bin_bluenh_path = @_PATH($bin_path, bluenh) -_bin_bluenh_cgi_path = @_PATH($bin_path, bluenh-cgi) -_bin_npb_path = @_PATH($bin_path, npb) -_bin_npb_cgi_path = @_PATH($bin_path, npb-cgi) +_bin_bluenh_path = @_PATH($bin_path, bluenh) +_bin_bluenh_cgi_path = @_PATH($bin_path, bluenh-cgi) +_bin_nofading_path = @_PATH($bin_path, nofading) +_bin_nofading_cgi_path = @_PATH($bin_path, nofading-cgi) +_bin_npb_path = @_PATH($bin_path, npb) +_bin_npb_cgi_path = @_PATH($bin_path, npb-cgi) _conf_path = @_PATH($conf_path, $name\.conf) HTML_TITLE = @_HTML_TITLE() -CONF_bin = $bin_path -CONF_bluenh = $_bin_bluenh_cgi_path +CONF_bin = $bin_path +CONF_bluenh = $_bin_bluenh_cgi_path +CONF_nofading = $_bin_nofading_cgi_path MAKE_CONFIGURE = CONFIGURE = $configure @@ -63,5 +66,6 @@ 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_NPB_PATH = @_C_DEFINE_STR(NPB_PATH, $_bin_npb_path) +C_BLUENH_PATH = @_C_DEFINE_STR(BLUENH_PATH, $_bin_bluenh_path) +C_NOFADING_PATH = @_C_DEFINE_STR(NOFADING_PATH, $_bin_nofading_path) +C_NPB_PATH = @_C_DEFINE_STR(NPB_PATH, $_bin_npb_path) -- 2.30.2