From 48d9e9fe2c95eebf33031fb41524d14d529b9c8d Mon Sep 17 00:00:00 2001 From: b Date: Mon, 5 Dec 2022 22:28:34 +0000 Subject: [PATCH] palette tools online --- bluenh-cgi.c | 2 - diff-cgi.c | 2 - enhance-bottom.htm | 2 + enhance.1.conf | 1 + makefile | 12 +- makefile.1.mak | 12 +- nofading-cgi.c | 4 +- npb-cgi.c | 2 - online-core.1.h | 13 +- pal-cgi.c | 408 ++++++++++++++++++++++++++----------------- pal.1.htm | 28 +-- reveal-cgi.c | 4 +- settings-release.txt | 1 + settings.txt | 18 +- 14 files changed, 294 insertions(+), 215 deletions(-) diff --git a/bluenh-cgi.c b/bluenh-cgi.c index b55cc8a..68d031b 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -114,8 +114,6 @@ int main (int argc, char *argv[]) } r2 = rm(in_tmp); r3 = rm(out_tmp); - if (r) - return r; if (r1) return r1; if (r2) diff --git a/diff-cgi.c b/diff-cgi.c index 27a3267..90decf0 100644 --- a/diff-cgi.c +++ b/diff-cgi.c @@ -132,8 +132,6 @@ int main (int argc, char *argv[]) r2 = rm(in0_tmp); r3 = rm(in1_tmp); r4 = rm(out_tmp); - if (r) - return r; if (r1) return r1; if (r2) diff --git a/enhance-bottom.htm b/enhance-bottom.htm index 9fca815..8055a00 100644 --- a/enhance-bottom.htm +++ b/enhance-bottom.htm @@ -1,5 +1,7 @@
Source code available at http://bicyclesonthemoon.info/git-projects/?p=ott/enhance.
Licensed under AGPL 3. +

+ 1190.bicyclesonthemoon.info diff --git a/enhance.1.conf b/enhance.1.conf index 58eff10..58a2c9c 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -4,6 +4,7 @@ ScriptAlias /enhance/bluenh ###CONF_bluenh; ScriptAlias /enhance/diff ###CONF_diff; ScriptAlias /enhance/nofading ###CONF_nofading; ScriptAlias /enhance/npb ###CONF_npb; +ScriptAlias /enhance/pal ###CONF_pal; ScriptAlias /enhance/reveal ###CONF_reveal; diff --git a/makefile b/makefile index 8ae88dc..cc4fa89 100644 --- a/makefile +++ b/makefile @@ -110,28 +110,32 @@ nf.h\ rvl.h\ df.h\ mpb.h\ -mpb_503.h +mpb_503.h\ +nclr.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ diff-cgi\ -npb-cgi +npb-cgi\ +pal-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ diff.htm\ -npb.htm +npb.htm\ +pal.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ diff.1.htm\ -npb.1.htm +npb.1.htm\ +pal.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/makefile.1.mak b/makefile.1.mak index 0736b7a..6ebb2c7 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -110,28 +110,32 @@ nf.h\ rvl.h\ df.h\ mpb.h\ -mpb_503.h +mpb_503.h\ +nclr.h CGI=\ bluenh-cgi\ nofading-cgi\ reveal-cgi\ diff-cgi\ -npb-cgi +npb-cgi\ +pal-cgi HTM_CGI=\ bluenh.htm\ nofading.htm\ reveal.htm\ diff.htm\ -npb.htm +npb.htm\ +pal.htm HTM_CGI_1=\ bluenh.1.htm\ nofading.1.htm\ reveal.1.htm\ diff.1.htm\ -npb.1.htm +npb.1.htm\ +pal.1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/nofading-cgi.c b/nofading-cgi.c index 1c3c410..f6f3483 100644 --- a/nofading-cgi.c +++ b/nofading-cgi.c @@ -1,7 +1,7 @@ /* nofading-cgi.c The online interface for the fading enhancement tool -04.12.2022 +05.12.2022 Copyright (C) 2015, 2022 Balthasar Szczepański @@ -92,8 +92,6 @@ int main (int argc, char *argv[]) } r2 = rm(in_tmp); r3 = rm(out_tmp); - if (r) - return r; if (r1) return r1; if (r2) diff --git a/npb-cgi.c b/npb-cgi.c index 27049dd..855d85d 100644 --- a/npb-cgi.c +++ b/npb-cgi.c @@ -129,8 +129,6 @@ int main (int argc, char *argv[]) } r2 = rm(in_tmp); r3 = rm(out_tmp); - if (r) - return r; if (r1) return r1; if (r2) diff --git a/online-core.1.h b/online-core.1.h index 46e935b..7342407 100644 --- a/online-core.1.h +++ b/online-core.1.h @@ -32,11 +32,14 @@ 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" +// ###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_PAL_MIX_PATH: #define PAL_MIX_PATH "/botm/bin/pal_mix" +// ###C_PAL_MIXDIFF_PATH: #define PAL_MIXDIFF_PATH "/botm/bin/pal_mixdiff" +// ###C_PAL_UNMIX_PATH: #define PAL_UNMIX_PATH "/botm/bin/pal_unmix" +// ###C_REVEAL_PATH: #define REVEAL_PATH "/botm/bin/reveal" int cp (char *src, char *dst); int wget (char *url, char *dst); diff --git a/pal-cgi.c b/pal-cgi.c index 0ffe0dc..0e7e401 100644 --- a/pal-cgi.c +++ b/pal-cgi.c @@ -1,206 +1,286 @@ -// insertframe.c -// The online interface for the tools to insert and extract indexed images -// 25.06.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 . -// +/* +pal-cgi.c +The online interface for the tools to insert and extract indexed images +05.12.2022 -// Requires cgilib (http://www.infodrom.org/projects/cgilib/) - -#include -#include -#include -#include -#include -#include -#include +Copyright (C) 2015, 2022 Balthasar Szczepański -#define WGET_PATH "/usr/bin/wget" -#define INS_PATH "./insert" -#define EXT_PATH "./extract" -#define DIF_PATH "./seediff" +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. -#define RM_PATH "/bin/rm" -#define LOG_PATH "/eizm/log/insertframe/insertframe.log" -#define USERAGENT "Hidden frames. (1190.bicyclesonthemoon.dnsd.info/insertframe/insertframe.htm)" -#define MSTD_PATH "/pro/insertframe/nclr.png" +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. -int main (int argc, char *argv[]); -void mustard(int mustard); +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . -FILE *pix; -unsigned short act; +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "online-core.h" +#include "nclr.h" -char url0[1024]; -char path0[256]; -char url1[1024]; -char path1[256]; -s_cgi *cgi; -int t; -pid_t sub; +#define INSERT 0 +#define EXTRACT_H 1 +#define EXTRACT_V 2 +#define DETECT 3 +#define MAX_ACTION DETECT +int insert( + char *inpix0, char *inpix1, char *outpix, + uint_fast8_t r0, uint_fast8_t r1 +); +int extract( + char *inpix, char *outpix0, char *outpix1, + uint_fast8_t size_defined, + uint_fast8_t p0, uint_fast8_t p1 +); +int detect( + char *inpix, char *outpix, + uint_fast8_t size_defined, + uint_fast8_t p0, uint_fast8_t p1 +); int main (int argc, char *argv[]) { - unsigned char buf[1024]; - struct stat st; - unsigned long p, i; - unsigned short q; - char **up; + s_cgi *cgi; + char tmp0[256]; + char tmp1[256]; + char tmp2[256]; + char *in0_path; + char *in1_path; - // unsigned short r0, r1; - unsigned char n0=0; - unsigned char n1=0; - - cgi=cgiInit(); + char *t; + uint_fast8_t p0, p1; + uint_fast8_t size_defined = 0; + uint_fast8_t action; - sprintf(path0,"%s",(cgiGetValue(cgi,"a")!=NULL)?(cgiGetValue(cgi,"a")):"0"); - act=atoi(path0); - // sprintf(path0,"%s",(cgiGetValue(cgi,"r0")!=NULL)?(cgiGetValue(cgi,"r0")):"1"); - // r0=atoi(path0); - // sprintf(path0,"%s",(cgiGetValue(cgi,"r1")!=NULL)?(cgiGetValue(cgi,"r1")):"0"); - // r1=atoi(path0); - - up=cgiGetFiles(cgi); - if (up) - { - if (cgiGetFile(cgi,up[0])!=NULL) - { - sprintf(path0,"%s",cgiGetFile(cgi,up[0])->tmpfile); - sprintf(url0,"%s",cgiGetFile(cgi,up[0])->filename); - n0=1; - } - if (cgiGetFile(cgi,up[1])!=NULL) - { - sprintf(path1,"%s",cgiGetFile(cgi,up[1])->tmpfile); - sprintf(url1,"%s",cgiGetFile(cgi,up[1])->filename); - n1=1; - } - } + int r=0; + int r1=0; + int r2=0; + int r3=0; + int r4=0; - if(!n0) - { - sprintf(url0,"%s",(cgiGetValue(cgi,"inpix0")!=NULL)?(cgiGetValue(cgi,"inpix0")):""); - sprintf(path0,"/var/tmp/%lu_0",(unsigned long)getpid()); + do { + make_tmp_path(tmp0, 256, 0, ".png"); + make_tmp_path(tmp1, 256, 1, ".png"); + make_tmp_path(tmp2, 256, 2, ".png"); + + cgi=cgiInit(); + + t = cgiGetValue(cgi, "a"); + if (t != NULL) + sscanf(t,"%"SCNuFAST8, &action); + else + action = DETECT; + if (action > MAX_ACTION) + action = DETECT; - sub=fork(); - if(sub==0) + r = get_file(cgi,"inpixf0", tmp0, &in0_path); + if (r) + r = get_file(cgi,"inpix0", tmp0, &in0_path); + if (r) + break; + + if (action == INSERT) { - t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path0,url0,(char *)0); - exit(t); + r = get_file(cgi,"inpixf1", tmp1, &in1_path); + if (r) + r = get_file(cgi,"inpix1", tmp1, &in1_path); + if (r) + break; + + t = cgiGetValue(cgi, "r0"); + if (t != NULL) + sscanf(t,"%"SCNuFAST8, &p0); + else + p0 = 1; + + t = cgiGetValue(cgi, "r1"); + if (t != NULL) + sscanf(t,"%"SCNuFAST8, &p1); + else + p1 = 0; } - waitpid(sub,&t,0); - if(t)mustard(t); - } - - if(!n1) - { - sprintf(url1,"%s",(cgiGetValue(cgi,"inpix1")!=NULL)?(cgiGetValue(cgi,"inpix1")):""); - sprintf(path1,"/var/tmp/%lu_1",(unsigned long)getpid()); - - if(!act) + else { - sub=fork(); - if(sub==0) + t = cgiGetValue(cgi, "p0"); + if (t != NULL) + { + sscanf(t,"%"SCNuFAST8, &p0); + size_defined=1; + } + else + p0 = 0; + + t = cgiGetValue(cgi, "p1"); + if (t != NULL) { - t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path1,url1,(char *)0); - exit(t); + sscanf(t,"%"SCNuFAST8, &p1); + size_defined=1; } - waitpid(sub,&t,0); - if(t)mustard(t); + else + p1 = 0; } - } - - sub=fork(); - if(sub==0) - { - switch (act) + + switch (action) { - case 0: - t=execl(INS_PATH,INS_PATH,path0,path1,path0,(cgiGetValue(cgi,"r0")!=NULL)?(cgiGetValue(cgi,"r0")):"1",(cgiGetValue(cgi,"r1")!=NULL)?(cgiGetValue(cgi,"r1")):"0","q",(char *)0); - exit(t); - case 1: - case 2: - t=execl(EXT_PATH,EXT_PATH,path0,path0,path1,"q",(char *)0); - exit(t); - case 3: - t=execl(DIF_PATH,DIF_PATH,path0,path0,"q",(char *)0); - exit(t); - default: - exit(act); + case INSERT: + r = insert( + in0_path, in1_path, tmp2, + p0, p1 + ); + break; + case EXTRACT_H: + case EXTRACT_V: + r = extract( + in0_path, tmp1, tmp2, + size_defined, + p0, p1 + ); + break; + case DETECT: + r = detect( + in0_path, tmp2, + size_defined, + p0, p1 + ); + break; } + if (r) + break; + + r1 = send_file( + (action == EXTRACT_H) ? tmp1 : tmp2, + "image/png", + 0 + ); + } while (0); + if (r) + { + r1 = send_data(nclr, nclr_size, "image/png", 500); } - waitpid(sub,&t,0); - if(t)mustard(t); + r2 = rm(tmp0); + r3 = rm(tmp1); + r4 = rm(tmp2); + if (r1) + return r1; + if (r2) + return r2; + if (r3) + return r3; + if (r4) + return r4; + return 0; +} + +int insert( + char *inpix0, char *inpix1, char *outpix, + uint_fast8_t r0, uint_fast8_t r1 +) +{ + char s_r0[4]; + char s_r1[4]; - pix=fopen((act==2?path1:path0),"rb"); - if(pix==NULL) - mustard(123); - fstat(fileno(pix),&st); - p=st.st_size/1024; - q=st.st_size%1024; + pid_t sub; + int r; - printf("Content-Length: %lu\n",(unsigned long)(st.st_size)); - printf("Content-type: image/png\n\n"); - for(i=0;i - - - Hidden frames • Bicycles on the Moon - - - - - - 1190.bicyclesonthemoon.info -

Hidden frames

-
+

Hidden frames

+ Upload frame(s):
Frame 1:
Frame 2:
@@ -21,6 +11,9 @@ Visibility ratio: to

+ Palette sizes: + 1: , 2:
+
Select action:
Insert
Extract horizontally
@@ -29,14 +22,7 @@


- When inserting you need two indexed images with the same size and the same number of colors.
- When enhancing you need one indexed image with a squarish palette. - - + When inserting you need two indexed images with the same size.
+ When enhancing you need one indexed image, if palette sizes not specified then square root is used.

- Source code available at http://1190.bicyclesonthemoon.info/pro/insertframe.
- Livensed under AGPL 3. - - - diff --git a/reveal-cgi.c b/reveal-cgi.c index a03f077..43dfb0c 100644 --- a/reveal-cgi.c +++ b/reveal-cgi.c @@ -1,7 +1,7 @@ /* reveal-cgi.c The online interface for the hidden detail revealer tool -04.12.2022 +05.12.2022 Copyright (C) 2022 Balthasar Szczepański @@ -69,8 +69,6 @@ int main (int argc, char *argv[]) } r2 = rm(in_tmp); r3 = rm(out_tmp); - if (r) - return r; if (r1) return r1; if (r2) diff --git a/settings-release.txt b/settings-release.txt index 08fa7da..2596c29 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -18,6 +18,7 @@ title_diff: See the difference! title_enhance: ENHANCE! title_nofading: No fading! title_npb: It's NewpixbOTTification time! +title_pal: Hidden frames title_reveal: Reveal hidden detail! bin_path: /botm/bin/enhance diff --git a/settings.txt b/settings.txt index 8b0c9cd..e2668ba 100644 --- a/settings.txt +++ b/settings.txt @@ -27,6 +27,10 @@ _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) +_bin_pal_mix_path = @_PATH($bin_path, pal_mix) +_bin_pal_mixdiff_path = @_PATH($bin_path, pal_mixdiff) +_bin_pal_unmix_path = @_PATH($bin_path, pal_unmix) +_bin_pal_cgi_path = @_PATH($bin_path, pal-cgi) _bin_reveal_path = @_PATH($bin_path, reveal) _bin_reveal_cgi_path = @_PATH($bin_path, reveal-cgi) @@ -40,6 +44,7 @@ CONF_bluenh = $_bin_bluenh_cgi_path CONF_diff = $_bin_diff_cgi_path CONF_nofading = $_bin_nofading_cgi_path CONF_npb = $_bin_npb_cgi_path +CONF_pal = $_bin_pal_cgi_path CONF_reveal = $_bin_reveal_cgi_path @@ -73,8 +78,11 @@ 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) +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_PAL_MIX_PATH = @_C_DEFINE_STR(PAL_MIX_PATH, $_bin_pal_mix_path) +C_PAL_MIXDIFF_PATH = @_C_DEFINE_STR(PAL_MIXDIFF_PATH, $_bin_pal_mixdiff_path) +C_PAL_UNMIX_PATH = @_C_DEFINE_STR(PAL_UNMIX_PATH, $_bin_pal_unmix_path) +C_REVEAL_PATH = @_C_DEFINE_STR(REVEAL_PATH, $_bin_reveal_path) -- 2.30.2