diff --git a/Common/Engines/BaseBuilderEngine.cs b/Common/Engines/BaseBuilderEngine.cs
index c6aed14..89951a4 100644
--- a/Common/Engines/BaseBuilderEngine.cs
+++ b/Common/Engines/BaseBuilderEngine.cs
@@ -116,10 +116,6 @@ public override void SetJsonParams(string json)
/// Does the dirty work
///
/// Image to print
- public override MagickImage GetResult(bool quiet)
- {
- img = new(fmt);
- return base.GetResult(quiet);
- }
+ public override MagickImage GetResult(bool quiet) => base.GetResult(quiet);
}
diff --git a/Common/Engines/BaseEngine.cs b/Common/Engines/BaseEngine.cs
index d59e35e..8297102 100644
--- a/Common/Engines/BaseEngine.cs
+++ b/Common/Engines/BaseEngine.cs
@@ -44,6 +44,7 @@ public int Dpi
{
_dpi = value;
fmt = new(_dpi);
+ img = new(fmt);
}
}
///
@@ -107,7 +108,7 @@ public string Script
///
/// Storage for the instantiated Script object
///
- protected object ScriptInstance { get; set; }
+ protected object ScriptInstance { get; set; }
#endregion
@@ -200,7 +201,14 @@ public void SetBaseJsonParams()
///
/// suppress messages when running
/// Image to print
- public virtual MagickImage GetResult(bool quiet) => null;
+ public virtual MagickImage GetResult(bool quiet)
+ {
+ if (CustomCode != null)
+ {
+ ScriptInstance = Compiler.New(CustomCode, this);
+ }
+ return null;
+ }
///
/// Writes exif infos on image
diff --git a/Common/Engines/CreditCardEngine.cs b/Common/Engines/CreditCardEngine.cs
index 88df134..550cfa4 100644
--- a/Common/Engines/CreditCardEngine.cs
+++ b/Common/Engines/CreditCardEngine.cs
@@ -184,9 +184,16 @@ public override void SetJsonParams(string json)
/// Image to print
public override MagickImage GetResult(bool quiet)
{
- img = new(fmt);
-
MagickImage final = img.FineArt10x15_v();
+ if (ScriptInstance != null)
+ {
+ var f = Compiler.Run(ScriptInstance, "OutputImage", null);
+ if (f != null)
+ {
+ final = (MagickImage)f;
+ }
+ }
+
MagickImage front = Get(FilesList[0], quiet);
int bordertop = final.Height / 2 - front.Height;
int borderleft = (final.Width - front.Width) / 2;
diff --git a/Common/Engines/MontaggioDorsiEngine.cs b/Common/Engines/MontaggioDorsiEngine.cs
index de78523..bbd95dc 100644
--- a/Common/Engines/MontaggioDorsiEngine.cs
+++ b/Common/Engines/MontaggioDorsiEngine.cs
@@ -95,14 +95,18 @@ public override void SetJsonParams(string json)
///
public override MagickImage GetResult(bool quiet)
{
- if (CustomCode != null)
+ _ = base.GetResult(quiet);
+
+ MagickImage final = PaperFormat == PaperFormats.Medium ? img.InCartha15x20_o() : img.InCartha20x27_o();
+ if (ScriptInstance != null)
{
- ScriptInstance = Compiler.New(CustomCode, this);
+ var f = Compiler.Run(ScriptInstance, "OutputImage", null);
+ if(f != null)
+ {
+ final = (MagickImage)f;
+ }
}
- img = new(fmt);
-
- MagickImage final = PaperFormat == PaperFormats.Medium ? img.InCartha15x20_o() : img.InCartha20x27_o();
MagickImageCollection imagesV = new();
MagickImageCollection imagesO = new();
@@ -185,7 +189,11 @@ private int LoadImages(int n, int counter, MagickImageCollection dest, bool quie
if (ScriptInstance != null)
{
- image = (MagickImage)Compiler.Run(ScriptInstance, "ProcessOnLoad", new object[] { image });
+ var im = Compiler.Run(ScriptInstance, "ProcessOnLoad", new object[] { image });
+ if (im != null)
+ {
+ image = (MagickImage)im;
+ }
}
MagickImage dorso = Utils.RotateResizeAndFill(image, orientation, FillColor);
diff --git a/Common/Engines/MontaggioFotoEngine.cs b/Common/Engines/MontaggioFotoEngine.cs
index 56e9c02..f72760e 100644
--- a/Common/Engines/MontaggioFotoEngine.cs
+++ b/Common/Engines/MontaggioFotoEngine.cs
@@ -126,15 +126,19 @@ public override void SetJsonParams(string json)
///
public MagickImage GetResult(bool quiet, int i)
{
- if (CustomCode != null)
+ _ = base.GetResult(quiet);
+
+ MagickImage final = img.FineArt10x15_o();
+ if (ScriptInstance != null)
{
- ScriptInstance = Compiler.New(CustomCode, this);
+ var f = Compiler.Run(ScriptInstance, "OutputImage", null);
+ if (f != null)
+ {
+ final = (MagickImage)f;
+ }
}
- img = new(fmt);
- MagickImage final = img.FineArt10x15_o();
MagickImage img1 = Get(FilesList[i], quiet);
-
MagickImage img2;
i++;
if (i < FilesList.Count)
@@ -183,7 +187,11 @@ private MagickImage Get(string filename, bool quiet)
if (ScriptInstance != null)
{
- image = (MagickImage)Compiler.Run(ScriptInstance, "ProcessOnLoad", new object[] { image });
+ var i = Compiler.Run(ScriptInstance, "ProcessOnLoad", new object[] { image });
+ if(i != null)
+ {
+ image = (MagickImage)i;
+ }
}
MagickImage img1 = Utils.RotateResizeAndFill(image,
diff --git a/Common/Scripting/BaseScripting.cs b/Common/Scripting/BaseScripting.cs
index 05f4cee..72f30dc 100644
--- a/Common/Scripting/BaseScripting.cs
+++ b/Common/Scripting/BaseScripting.cs
@@ -33,6 +33,12 @@ internal class BaseScripting : IScripting
/// Custom class initialization
///
public void Init() { }
+
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
";
public virtual string WrapScript(string script, string engine) => $@"{Compiler.Usings}
diff --git a/Common/Scripting/Compiler.cs b/Common/Scripting/Compiler.cs
index 4217146..ad26fcc 100644
--- a/Common/Scripting/Compiler.cs
+++ b/Common/Scripting/Compiler.cs
@@ -129,11 +129,17 @@ public static object Run(Assembly assembly, string ClassName, string Method, obj
public static object Run(object obj, string Method, object[] args)
{
Type type = obj.GetType();
- return type.InvokeMember(Method,
+ if (type != null && type.GetMethod(Method) != null)
+ {
+
+ return type.InvokeMember(Method,
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
obj,
args);
+ }
+ else
+ return null;
}
///
diff --git a/build_tools/publish.cmd b/build_tools/publish.cmd
index 1ae9411..6dc7c93 100644
--- a/build_tools/publish.cmd
+++ b/build_tools/publish.cmd
@@ -33,7 +33,7 @@ set candle="%wix%candle.exe"
set light="%wix%light.exe"
set WixUtils="%wix%WixUtilExtension.dll"
-set version=22.03.26
+set version=22.04.03
@del /S /Q %build%
@del /Q %bin%%pkgname%*.*
diff --git a/docs/Cartella.1 b/docs/Cartella.1
index 95c9bbf..029f98c 100644
--- a/docs/Cartella.1
+++ b/docs/Cartella.1
@@ -197,6 +197,14 @@ set output dir/filename
.P
.PD
extra info for user scripts
+.PD 0
+.P
+.PD
+Text can be stored in a file instead of a string
+.PD 0
+.P
+.PD
+The file must be referenced as `\[at]filename'
.PP
\f[B]\[en]nobanner\f[R] :
.PD 0
@@ -349,6 +357,10 @@ These are the signatures of the scriptable methods:
/// Custom class initialization ///
.PP
public void Init() { }
+///
+/// Image for final output ///
+.PP
+/// public MagickImage OutputImage() => null;
.PP
\[ti]\[ti]\[ti]
.SH COPYRIGHT
diff --git a/docs/CreditCard.1 b/docs/CreditCard.1
index 58ac266..e7dc400 100644
--- a/docs/CreditCard.1
+++ b/docs/CreditCard.1
@@ -167,6 +167,14 @@ set output dir/filename
.P
.PD
extra info for user scripts
+.PD 0
+.P
+.PD
+Text can be stored in a file instead of a string
+.PD 0
+.P
+.PD
+The file must be referenced as `\[at]filename'
.PP
\f[B]\[en]nobanner\f[R] :
.PD 0
@@ -315,6 +323,10 @@ These are the signatures of the scriptable methods:
/// Custom class initialization ///
.PP
public void Init() { }
+///
+/// Image for final output ///
+.PP
+/// public MagickImage OutputImage() => null;
.PP
\[ti]\[ti]\[ti]
.SH COPYRIGHT
diff --git a/docs/MontaggioDorsi.1 b/docs/MontaggioDorsi.1
index 6192c9e..020501e 100644
--- a/docs/MontaggioDorsi.1
+++ b/docs/MontaggioDorsi.1
@@ -104,6 +104,14 @@ set output dir/filename
.P
.PD
extra info for user scripts
+.PD 0
+.P
+.PD
+Text can be stored in a file instead of a string
+.PD 0
+.P
+.PD
+The file must be referenced as `\[at]filename'
.PP
\f[B]\[en]nobanner\f[R] :
.PD 0
@@ -243,6 +251,10 @@ These are the signatures of the scriptable methods:
.PP
public void Init() { }
///
+/// Image for final output ///
+.PP
+/// public MagickImage OutputImage() => null;
+///
/// Preprocesses the loaded image ///
.PP
/// The loaded image /// The Processed image public MagickImage
diff --git a/docs/MontaggioFoto.1 b/docs/MontaggioFoto.1
index a2ace86..dfbc997 100644
--- a/docs/MontaggioFoto.1
+++ b/docs/MontaggioFoto.1
@@ -114,6 +114,14 @@ set output dir/filename
.P
.PD
extra info for user scripts
+.PD 0
+.P
+.PD
+Text can be stored in a file instead of a string
+.PD 0
+.P
+.PD
+The file must be referenced as `\[at]filename'
.PP
\f[B]\[en]nobanner\f[R] :
.PD 0
@@ -256,6 +264,10 @@ These are the signatures of the scriptable methods:
.PP
public void Init() { }
///
+/// Image for final output ///
+.PP
+/// public MagickImage OutputImage() => null;
+///
/// Preprocesses the loaded image ///
.PP
/// The loaded image /// The Processed image public MagickImage
diff --git a/docs/Scatola.1 b/docs/Scatola.1
index 9720b5c..b95faf5 100644
--- a/docs/Scatola.1
+++ b/docs/Scatola.1
@@ -194,6 +194,14 @@ set output dir/filename
.P
.PD
extra info for user scripts
+.PD 0
+.P
+.PD
+Text can be stored in a file instead of a string
+.PD 0
+.P
+.PD
+The file must be referenced as `\[at]filename'
.PP
\f[B]\[en]nobanner\f[R] :
.PD 0
@@ -346,6 +354,10 @@ These are the signatures of the scriptable methods:
/// Custom class initialization ///
.PP
public void Init() { }
+///
+/// Image for final output ///
+.PP
+/// public MagickImage OutputImage() => null;
.PP
\[ti]\[ti]\[ti]
.SH COPYRIGHT
diff --git a/docs/help_cartella.txt b/docs/help_cartella.txt
index 9459f74..00e1390 100644
--- a/docs/help_cartella.txt
+++ b/docs/help_cartella.txt
@@ -37,6 +37,8 @@ Options:
The file must be referenced as '@filename'
-o, --output=VALUE set output dir/filename
--tag=VALUE extra info for user scripts
+ Text can be stored in a file instead of a string
+ The file must be referenced as '@filename'
--nobanner suppress the banner
-h, --help show this message and exit
--helpjson show json parameters template
diff --git a/docs/help_creditcard.txt b/docs/help_creditcard.txt
index c50e0d0..26bd5a0 100644
--- a/docs/help_creditcard.txt
+++ b/docs/help_creditcard.txt
@@ -35,6 +35,8 @@ Options:
The file must be referenced as '@filename'
-o, --output=VALUE set output dir/filename
--tag=VALUE extra info for user scripts
+ Text can be stored in a file instead of a string
+ The file must be referenced as '@filename'
--nobanner suppress the banner
-h, --help show this message and exit
--helpjson show json parameters template
diff --git a/docs/help_montaggiodorsi.txt b/docs/help_montaggiodorsi.txt
index 4647351..af67867 100644
--- a/docs/help_montaggiodorsi.txt
+++ b/docs/help_montaggiodorsi.txt
@@ -22,6 +22,8 @@ Options:
The file must be referenced as '@filename'
-o, --output=VALUE set output dir/filename
--tag=VALUE extra info for user scripts
+ Text can be stored in a file instead of a string
+ The file must be referenced as '@filename'
--nobanner suppress the banner
-h, --help show this message and exit
--helpjson show json parameters template
diff --git a/docs/help_montaggiofoto.txt b/docs/help_montaggiofoto.txt
index f55cb72..3a721e5 100644
--- a/docs/help_montaggiofoto.txt
+++ b/docs/help_montaggiofoto.txt
@@ -23,6 +23,8 @@ Options:
The file must be referenced as '@filename'
-o, --output=VALUE set output dir/filename
--tag=VALUE extra info for user scripts
+ Text can be stored in a file instead of a string
+ The file must be referenced as '@filename'
--nobanner suppress the banner
-h, --help show this message and exit
--helpjson show json parameters template
diff --git a/docs/help_scatola.txt b/docs/help_scatola.txt
index 099d3e1..0828253 100644
--- a/docs/help_scatola.txt
+++ b/docs/help_scatola.txt
@@ -37,6 +37,8 @@ Options:
The file must be referenced as '@filename'
-o, --output=VALUE set output dir/filename
--tag=VALUE extra info for user scripts
+ Text can be stored in a file instead of a string
+ The file must be referenced as '@filename'
--nobanner suppress the banner
-h, --help show this message and exit
--helpjson show json parameters template
diff --git a/docs/helpscript_Cartella.txt b/docs/helpscript_Cartella.txt
index 2f29a60..00f5545 100644
--- a/docs/helpscript_Cartella.txt
+++ b/docs/helpscript_Cartella.txt
@@ -9,4 +9,10 @@ Copyright (c) 2020-2022 Roberto Ceccarelli - Casasoft
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
-----
diff --git a/docs/helpscript_CreditCard.txt b/docs/helpscript_CreditCard.txt
index 5049343..f9e8a64 100644
--- a/docs/helpscript_CreditCard.txt
+++ b/docs/helpscript_CreditCard.txt
@@ -9,4 +9,10 @@ Copyright (c) 2020-2022 Roberto Ceccarelli - Casasoft
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
-----
diff --git a/docs/helpscript_MontaggioDorsi.txt b/docs/helpscript_MontaggioDorsi.txt
index 15cc93e..24d1f2b 100644
--- a/docs/helpscript_MontaggioDorsi.txt
+++ b/docs/helpscript_MontaggioDorsi.txt
@@ -9,6 +9,12 @@ Copyright (c) 2020-2022 Roberto Ceccarelli - Casasoft
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
///
/// Preprocesses the loaded image
///
diff --git a/docs/helpscript_MontaggioFoto.txt b/docs/helpscript_MontaggioFoto.txt
index 9485aab..98c262d 100644
--- a/docs/helpscript_MontaggioFoto.txt
+++ b/docs/helpscript_MontaggioFoto.txt
@@ -9,6 +9,12 @@ Copyright (c) 2020-2022 Roberto Ceccarelli - Casasoft
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
///
/// Preprocesses the loaded image
///
diff --git a/docs/helpscript_Scatola.txt b/docs/helpscript_Scatola.txt
index 07c33c3..e821fd3 100644
--- a/docs/helpscript_Scatola.txt
+++ b/docs/helpscript_Scatola.txt
@@ -9,4 +9,10 @@ Copyright (c) 2020-2022 Roberto Ceccarelli - Casasoft
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
-----
diff --git a/docs/man_Cartella.md b/docs/man_Cartella.md
index fda68b1..1e97bc0 100644
--- a/docs/man_Cartella.md
+++ b/docs/man_Cartella.md
@@ -111,6 +111,8 @@ set output dir/filename
**--tag=VALUE** :
extra info for user scripts
+Text can be stored in a file instead of a string
+The file must be referenced as '@filename'
**--nobanner** :
@@ -216,6 +218,12 @@ These are the signatures of the scriptable methods:
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
~~~
# COPYRIGHT
diff --git a/docs/man_CreditCard.md b/docs/man_CreditCard.md
index 6c11f35..d2fba2f 100644
--- a/docs/man_CreditCard.md
+++ b/docs/man_CreditCard.md
@@ -95,6 +95,8 @@ set output dir/filename
**--tag=VALUE** :
extra info for user scripts
+Text can be stored in a file instead of a string
+The file must be referenced as '@filename'
**--nobanner** :
@@ -196,6 +198,12 @@ These are the signatures of the scriptable methods:
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
~~~
# COPYRIGHT
diff --git a/docs/man_MontaggioDorsi.md b/docs/man_MontaggioDorsi.md
index f880f81..3d76d0c 100644
--- a/docs/man_MontaggioDorsi.md
+++ b/docs/man_MontaggioDorsi.md
@@ -53,6 +53,8 @@ set output dir/filename
**--tag=VALUE** :
extra info for user scripts
+Text can be stored in a file instead of a string
+The file must be referenced as '@filename'
**--nobanner** :
@@ -144,6 +146,12 @@ These are the signatures of the scriptable methods:
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
///
/// Preprocesses the loaded image
///
diff --git a/docs/man_MontaggioFoto.md b/docs/man_MontaggioFoto.md
index 97163d3..c737481 100644
--- a/docs/man_MontaggioFoto.md
+++ b/docs/man_MontaggioFoto.md
@@ -63,6 +63,8 @@ set output dir/filename
**--tag=VALUE** :
extra info for user scripts
+Text can be stored in a file instead of a string
+The file must be referenced as '@filename'
**--nobanner** :
@@ -157,6 +159,12 @@ These are the signatures of the scriptable methods:
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
///
/// Preprocesses the loaded image
///
diff --git a/docs/man_Scatola.md b/docs/man_Scatola.md
index b63771d..bb1d5ae 100644
--- a/docs/man_Scatola.md
+++ b/docs/man_Scatola.md
@@ -110,6 +110,8 @@ set output dir/filename
**--tag=VALUE** :
extra info for user scripts
+Text can be stored in a file instead of a string
+The file must be referenced as '@filename'
**--nobanner** :
@@ -215,6 +217,12 @@ These are the signatures of the scriptable methods:
///
public void Init() { }
+///
+/// Image for final output
+///
+///
+public MagickImage OutputImage() => null;
+
~~~
# COPYRIGHT