Il montaggio delle foto

Preparazione dei file per la stampa delle foto
Le foto ritagliate

Il programma MontaggioFoto accorpa due foto su una superficie 10x15cm da stampare con la tecnica che si ritiene più opportuna.

Attraverso gli script utente è comunque possibile utilizzare formati diversi, ma il layout delle immagini rimane lo stesso.

Anche in questo caso il programma chiamato con il parametro -h o --help mostra la sintassi di utilizzo, come riportato di seguito:

Casasoft Contemporary Carte de Visite MontaggioFoto
Copyright (c) 2020-2023 Roberto Ceccarelli - Casasoft

Usage: MontaggioFoto [options]* inputfile+

Options:
      --fullsize             resize image to full format
      --withborder           include border to full format
      --trim                 trim white space
  -p, --padding=VALUE        blank border around the image
      --gravity=VALUE        canvas gravity, valid values are:
                               Northwest
                               North
                               Northeast
                               West
                               Center
                               East
                               Southwest
                               South
                               Southeast
      --fillcolor=VALUE      set the color used to fill the images
                               (default #FFFFFF)
      --bordercolor=VALUE    set the color used to border the images
                               (default #000000)
      --dpi=VALUE            set output resolution (default 300)
      --json=VALUE           parameters in json format,
                               use --helpjson for sample template
                               Text can be stored in a file instead of a string
                               The file must be referenced as '@filename'
      --script=VALUE         c# script for custom processing,
                               use --helpscript for sample template
                               Text can be stored in a file instead of a string
                               The file must be referenced as '@filename'
  -o, --output=VALUE         set output dir/filename
      --extension=VALUE      file extension for output file (default 'jpg')
      --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
      --helpscript           show script template
      --man                  show the man page source and exit
      --colors               list available colors by name
      --license              show program license (AGPL 3.0)

Colors can be written in any of these formats:
  #rgb
  #rrggbb
  #rrggbbaa
  #rrrrggggbbbb
  #rrrrggggbbbbaaaa
  colorname    (use MontaggioFoto --colors  to see all available colors)

Environment variables
The program can read values from these variables:
  CDV_OUTPATH                     Base path for output files
  CDV_DPI                         Resolution for output files
  CDV_FILL                        Color used to fill images
  CDV_BORDER                      Border color


Built-in images and renders
Instead of a filename you can use the following built-in templates:
  xc:color                        Fill the image with the specified color
  gradient:color1-color2          Fill the image with linear gradient
                                    from color1 to color2,
                                    if colors are omitted is white to black
  radial-gradient:color1-color2   Radial gradient as above
  plasma:color1-color2            Plasma gradient from color1 to color2,
                                    if colors are omitted is black to black
  plasma:fractal                  Creates a random plasma
  label:text                      Render the plain text with no word-wrap
  caption:text                    Render the plain text with auto word-wrap
  pango:text                      Render the text with pango markup

The parameters can be stored in a file instead of a string.
The file must be referenced as '@filename'

Per chi la preferisse è anche disponibile la man page (Nuova pagina) Unix

La man page, in formato MarkDown, può essere ottenuta chiamando il programma con l'opzione --man

I parametri possono essere passati in un file in formato json le cui struttura può essere ottenuta con il comando montaggiofoto --helpjson il cui output è riportato di seguito:

Casasoft Contemporary Carte de Visite MontaggioFoto
Copyright (c) 2020-2023 Roberto Ceccarelli - Casasoft

Json parameters template for: MontaggioFoto

{
  "FullSize": false,
  "Trim": false,
  "WithBorder": false,
  "Padding": 0,
  "CanvasGravity": 0,
  "FillColor": "#FFFFFF",
  "BorderColor": "#000000",
  "Dpi": 300,
  "OutputName": "",
  "Extension": "jpg",
  "Script": null,
  "Tag": null,
  "FilesList": []
}

Possono essere elencati uno o più file, eventualmente anche con wildcards, come ad esempio:

MontaggioFoto c:\foto\fq\storia*.jpg

Qualora il numero di file sia dispari nell'ultimo montaggio verrà inserita una immagine vuota.

Le immagini fornite saranno ridimensionate per entrare nel formato di una carte de viste (54x90mm), la parte eventualmente non coperta sarà riempita di colore bianco.
Possono essere sia orizzontali che verticali: la funzione RotateResizeAndFill, già descritta in precedenza, provvede alla rotazione, se necessaria.

Il comportamento appena descritto può essere alterato da quattro parametri opzionali:

  • --fullsize scala le immagini alla stessa dimensione del dorso (64x100mm)
  • --withborder imposta i segni di taglio alla dimensione dei dorsi, lasciando un bordo (riempito del colore di sfondo)
  • --trim imposta i segni di taglio senza lasciare bordi dovuto al differente rapporto tra i lati
  • --p oppure --padding imposta un bordo, specificato in millimetri tra l'immagine ed i segni di taglio (riempito del colore di sfondo)

L'opzione --dpi= (non esiste forma breve) specifica la risoluzione, in dpi, del file di uscita.
Se non indicata viene impostata a 300dpi.

L'opzione -o, o la versione lunga --output=, permette di specificare il prefisso del pathname dei file generati: se non specificato i file si chiameranno card-nnn.jpg e si troveranno nella stessa directory del programma.

Questa immagine mostra un esempio del risultato ottenuto.

Le foto pronte per la stampa

A partire dalla versione 22.03.13 è stata aggiunta la possibilità di richiamare uno script personalizzato, scritto in C#, che permette elaborazioni specializzate.

Con il comando MontaggioFoto --helpscript si può ottenere un template, riportato di seguito, per scrivere il proprio script.

Casasoft Contemporary Carte de Visite MontaggioFoto
Copyright (c) 2020-2023 Roberto Ceccarelli - Casasoft

-----
// Script template for MontaggioFoto

/// <summary>
/// Custom class initialization
/// </summary>
public void Init() { }

/// <summary>
/// Image for final output
/// </summary>
/// <returns></returns>
public MagickImage OutputImage() => null;

/// <summary>
/// Preprocesses the loaded image
/// </summary>
/// <param name="image">The loaded image</param>
/// <returns>The Processed image</returns>
public MagickImage ProcessOnLoad(MagickImage image) => image;
-----

Lo script viene compilato internamente dal programma, non necessita quindi di alcun programma aggiuntivo per crearlo (basta il semplice notepad).

Riporto un esempio che aggiunge una label sotto all'immagine con il nome del file.

// copyright (c) 2020-2023 Roberto Ceccarelli - Casasoft
// http://strawberryfield.altervista.org
//
// This file is part of Casasoft Contemporary Carte de Visite Tools
// https://github.com/strawberryfield/Contemporary_CDV
//
// Casasoft CCDV Tools 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.
//
// Casasoft CCDV Tools 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 General Public License for more details.
//
// You should have received a copy of the GNU AGPL v.3
// along with Casasoft CCDV Tools.  
// If not, see <http://www.gnu.org/licenses/>.

public MagickImage ProcessOnLoad(MagickImage image)
{
    // Get the image name
    string filename = Path.GetFileNameWithoutExtension(image.FileName);

    // Resize the image and put aligned to top
    MagickImage img1 = Utils.RotateResizeAndFill(image, engine.fmt.CDV_Internal_v, engine.FillColor);
    img1.Trim();
    image = engine.img.CDV_Full_v();
    image.Composite(img1, Gravity.North, 0, engine.fmt.ToPixels(5));

    // Format and overlay image name
    MagickReadSettings settings = new();
    settings.BackgroundColor = MagickColors.Transparent;
    MagickImage text = new(@$"pango:<span size='50000'>{filename}</span>", settings);
    image.Composite(text, Gravity.South, 0, engine.fmt.ToPixels(5), CompositeOperator.Over);

    return image;
}

Questo invece è il batch che richiama il programma passando lo script

rem test for montaggiofoto scripting

set projectdir=C:\projects\Contemporary_CDV\
set bin=%projectdir%bin\build\net6.0\
set samples=%projectdir%Test\

%bin%MontaggioFoto --dpi=600 ^
 --script=@%samples%AddLabel.cs ^
 --fullsize ^
 --output=%samples%AddLabel ^
 %samples%cdv*.jpg
 
Inizio pagina
 
Precedente
Sommario
Successivo