]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
diff online
authorb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 23:46:33 +0000 (23:46 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 23:46:33 +0000 (23:46 +0000)
bluenh.1.htm
df.png [new file with mode: 0644]
diff-cgi.c [new file with mode: 0644]
diff.1.htm [new file with mode: 0644]
enhance-top.htm
enhance.1.conf
makefile
makefile.1.mak
online-core.1.h
settings-release.txt
settings.txt

index 1c8766028b63f9ff6e839af0ba18008ad01f5dec..12d07c6f1038e40262e56157384bfbfbc17d3836 100644 (file)
@@ -2,18 +2,18 @@
                <form method="post" action="/enhance/bluenh" enctype='multipart/form-data'>
                        <img src="param.png" alt="parameter explanation picture"><br>
                        <br>
-                       a=<input type="text" name="a" value=  "0">, b=<input type="text" name="b" value= "34">, c=<input type="text" name="c" value= "41">,<br>
-                       d=<input type="text" name="d" value=  "0">, e=<input type="text" name="e" value= "40">, f=<input type="text" name="f" value="255">.<br>
+                       a=<input class="pt" type="text" name="a" value=  "0">, b=<input class="pt" type="text" name="b" value= "34">, c=<input class="pt" type="text" name="c" value= "41">,<br>
+                       d=<input class="pt" type="text" name="d" value=  "0">, e=<input class="pt" type="text" name="e" value= "40">, f=<input class="pt" type="text" name="f" value="255">.<br>
                        a &lt; b &lt; c<br>
                        <br>
                        Enhance by URL<br>
                        URL of image:
-                       <input type="text" name="inpix">
-                       <input type="submit" value="ENHANCE!"><br>
+                       <input class="pt" type="text" name="inpix">
+                       <input class="pk" type="submit" value="ENHANCE!"><br>
                        <br>
                        Enhance by file upload<br>
                        Upload the image:
-                       <input type="file" name="inpix2">
-                       <input type="submit" value="ENHANCE!">
+                       <input class="pt" type="file" name="inpix2">
+                       <input class="pk" type="submit" value="ENHANCE!">
                </form>
 
diff --git a/df.png b/df.png
new file mode 100644 (file)
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 (file)
index 0000000..2707359
--- /dev/null
@@ -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 <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 "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 (file)
index 0000000..054500d
--- /dev/null
@@ -0,0 +1,17 @@
+               <h1>See the difference!</h1>
+               <form method="post" action="/enhance/diff" enctype='multipart/form-data'>
+                       Enhance by URL<br>
+                       URL 1: <input class="pt" type="text" name="inpix0"><br>
+                       URL 2: <input class="pt" type="text" name="inpix1"><br>
+                       <br>
+                       Enhance by file upload<br>
+                       File 1: <input class="pt" type="file" name="inpixf0"><br>
+                       File 2: <input class="pt" type="file" name="inpixf1"><br>
+                       <br>
+                       Color A:<br>
+                       R=<input class="pt" type="text" name="ra" value=  "0">, G=<input class="pt" type="text" name="ga" value= "87">, B=<input class="pt" type="text" name="ba" value="175"><br>
+                       Color B:<br>
+                       R=<input class="pt" type="text" name="rb" value="187">, G=<input class="pt" type="text" name="gb" value="102">, B=<input class="pt" type="text" name="bb" value= "34"><br>
+                       <br>
+                       <input class="pk" type="submit" value="ENHANCE!"><br>
+               </form>
\ No newline at end of file
index df6f770948f0a9053e14ff09b2e35cc594e3dade..94172fa690ae554e0948420fea88220068e54030 100644 (file)
@@ -2,7 +2,8 @@
 <html lang="pl">
        <head>
                <title>###HTML_TITLE; &bull; Bicycles on the Moon</title>
-               <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
+               <meta http-equiv="Content-type" content="text/html; charset=UTF-8">
+               <link rel="stylesheet" href="/css/botm.css">
                <link rel="icon" type="image/png" href="/img/favicon.png">
        </head>
        <body>
index 8dbf99f0907c075738a0d2e28708cbfbe3700151..4a138c7f1917284254d2aa189360d78f7aed397c 100644 (file)
@@ -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;
 </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
+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
index 1af611e65c96bef24254151ab41d758e024aa14d..6fe317998cd410a159f80ae8313653c71330faef 100644 (file)
--- 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=\
index 58ce7abfb907da6cef5b7bf2c972c119847a66a4..914f0de775c495fcf0ef3a81133a60f03df5b807 100644 (file)
@@ -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=\
index 6b8f87051a1922ebb2e62d63e23c3e085f53d2e1..46e935bdd090c326497fac79396aad23c4b9a2d8 100644 (file)
@@ -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"
index 2350af8ae6807b1643aef3678b6611512d0b2fca..eed7ff2a0f962638584a2c54b7701a275dc86c17 100644 (file)
@@ -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!
index 202c4ec4a5afdb7dec9f3d06ece09fd790c40d42..a2294a600519c32c0726ef71480f4375e340afd4 100644 (file)
@@ -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)