]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
nofading online
authorb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 22:08:39 +0000 (22:08 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 22:08:39 +0000 (22:08 +0000)
bluenh-cgi.c
enhance-bottom.htm
enhance.1.conf
makefile
makefile.1.mak
nofading-cgi.c
nofading.1.htm
nofading.c
online-core.1.h
settings-release.txt
settings.txt

index 08d41e59608c1e0c9ae01c9ff2b3fec172814571..aa431db28b5dd18e5e105f85a69886bb59953247 100644 (file)
@@ -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 <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[])
 {
@@ -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);
index 2b9e22cec322eb519edf83370576e2e2ad071ecf..9fca8156625519a22ab721154fc7cef190e0fff3 100644 (file)
@@ -1,5 +1,5 @@
                <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>
index dc7b2cf88c59f8f3f3f4cae847290103b716fefe..47f21d214cb8a33b1f2279a96bb69050fcb2243d 100644 (file)
@@ -1,7 +1,16 @@
 # 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
index 5d6ad886afacf4d7f0a264379b7d21a1eb346566..9998d0dc42fb34c2940e46bbc5e105a58a094bb2 100644 (file)
--- 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
index 3ea26f608238dcdaa02e85a175fe2c740b12560e..b54178cb43eca2f1c376392168faad7e744af803 100644 (file)
@@ -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
index 2c20885b80599c0e8c4c7a9e245b528736b96111..5b4f065562aa98b2bb895db2527fa040e92d6305 100644 (file)
-// 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>
@@ -145,4 +249,6 @@ void mustard(int mustard)
                fclose(pix);
        }
        exit(mustard);
-}
\ No newline at end of file
+}
+
+*/
\ No newline at end of file
index e7709893a978177ced8572b7d0b27c815d69f2cc..9326bc9a347e3cb1a8bac6a52f8ce39219b52dcc 100644 (file)
@@ -1,36 +1,24 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
-<html lang="pl">
-       <head>
-               <title>No fading! &bull; 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>
index acd888f531b41584f3e79dd065ecbf72c0ac7efc..f3048ba4542b54bacbf453113e030e1a09c4522a 100644 (file)
@@ -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;
index eb15e33bc603e453faf693931e518acdd4d00931..71fecfcd156048849c96ee79024444e5c330e55e 100644 (file)
@@ -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);
index 9af43474380077c2ad84067f32673cf4969f6617..57b49c19f1599102567638a214a647e309ffd966 100644 (file)
@@ -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
index 85ad2fa83eadbe5fe9c5c2caf3f092bac3be7942..56e70fb405f8bacf759faf27fcba051b4341dc0f 100644 (file)
 _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)