/*
-bluenh-cgi.c is autogenerated from bluenh-cgi.1.c
+bluenh-cgi.c
Online interface for npb
04.12.2022
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
+#include <stdint.h>
+#include <inttypes.h>
#include <cgi.h>
#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[])
{
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;
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;
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);
<br>
- <br>
- Source code available at <a href="http://bicyclesonthemoon.info/git-projects/?p=ott/enhance">http://bicyclesonthemoon.info/git-projects/?p=ott/enhance</a>.
+ Source code available at <a href="http://bicyclesonthemoon.info/git-projects/?p=ott/enhance">http://bicyclesonthemoon.info/git-projects/?p=ott/enhance</a>.<br>
+ Licensed under <a href="/a/agpl.txt">AGPL 3</a>.
</body>
</html>
# Enhance tools
-ScriptAlias /enhance/bluenh ###CONF_bluenh;
+ScriptAlias /enhance/bluenh ###CONF_bluenh;
+ScriptAlias /enhance/nofading ###CONF_nofading;
<Directory ###CONF_bin;>
Require all granted
</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
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!:
$(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
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!:
$(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
-// 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 <http://www.gnu.org/licenses/>.
-//
-
-// 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 <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 "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 <cgi.h>
fclose(pix);
}
exit(mustard);
-}
\ No newline at end of file
+}
+
+*/
\ No newline at end of file
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
-<html lang="pl">
- <head>
- <title>No fading! • Bicycles on the Moon</title>
- <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
- <link rel="stylesheet" href="/css/botm.css">
- <link rel="icon" type="image/png" href="/img/favicon.png"/>
- </head>
- <body>
- <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.info" border="0"></a>
<h1>No fading!</h1>
- <form method="post" action="/cgi/nofading/nofadingd">
+ <form method="post" action="/enhance/nofading">
Enhance by URL<br>
URL of image:
<input class="pt" type="text" name="inpix">
border width:
<input class="pt" type="text" name="f" size="2">
<input class="pk" type="submit" value="ENHANCE!"><br>
- <input type="checkbox" class="pt" name="a"> ignore color-fading
+ <input type="checkbox" class="pt" name="c"> ignore color-fading
+ <input type="checkbox" class="pt" name="n"> remove alpha
+ <input type="checkbox" class="pt" name="a"> enhance alpha
</form>
<br>
- <form method="post" action="/cgi/nofading/nofadingd" enctype="multipart/form-data">
+ <form method="post" action="/enhance/nofading" enctype="multipart/form-data">
Enhance by file upload<br>
Upload the image:
<input class="pt" type="file" name="inpix">
border width:
<input class="pt" type="text" name="f" size="2">
<input class="pk" type="submit" value="ENHANCE!"><br>
- <input type="checkbox" class="pt" name="a"> ignore color-fading
+ <input type="checkbox" class="pt" name="c"> ignore color-fading
+ <input type="checkbox" class="pt" name="n"> remove alpha
+ <input type="checkbox" class="pt" name="a"> enhance alpha
</form>
- <br>
- Source code available at <a href="http://1190.bicyclesonthemoon.info/pro/nofading">http://1190.bicyclesonthemoon.info/pro/nofading</a>.<br>
- Livensed under <a href="/a/agpl.txt">AGPL 3</a>.
-
- </body>
-</html>
/*
nofading.c
The tool to remove fading from an image
-29.11.2022
+04.12.2022
Copyright (C) 2015, 2022 Balthasar Szczepański
{"help", no_argument, NULL, 'h'},
{0, 0, 0, 0}
};
- char short_options[] = "acfh";
+ char short_options[] = "acfh0";
int opt;
int r;
// ###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);
useragent: ENHANCE!ment tool (http://1190.bicyclesonthemoon.info/enhance)
title_enhance: ENHANCE!
+title_nofading: No fading!
title_bluenh: ENHANCE!
bin_path: /botm/bin/enhance
_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
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)