#

Listato 12

Creazione dei menu con immagini per i 16:9
 
<!--
DVD authoring suite
makesimgmenu.wsf
(c) copyright 2005-2007 Roberto Ceccarelli
-->

<job>
<runtime>
<named name="filename" helpstring="Il nomefile del menu" required="true" type="string" />
<named name="backfile" helpstring="Il file con lo sfondo" required="true" type="string" />
<named name="aspect" helpstring="L'aspect-ratio delle immagini (normal o widescreen, default:widescreen)" required="false" type="string" />
<named name="item1" helpstring="Immagine n.1" required="true" type="string" />
<named name="item2" helpstring="Immagine n.2" required="false" type="string" />
<named name="item3" helpstring="Immagine n.3" required="false" type="string" />
<named name="item4" helpstring="Immagine n.4" required="false" type="string" />
<named name="iconhome" helpstring="Icona per tornare al menu principale" required="false" type="string" />
<named name="iconprev" helpstring="Icona per tornare al menu precedente" required="false" type="string" />
<named name="iconnext" helpstring="Icona per andare al menu successivo" required="false" type="string" />
<named name="maskcolor" helpstring="Eventuale colore della maschera (default: green)" required="false" type="string" />
<named name="xgap" helpstring="Eventuale margine tra le immagini (default: 11)" required="false" type="string" />
</runtime>

<script language="JScript">
// dichiarazione variabili
var filename, backfile;
var im;
var maskcolor, xwidth, xgap;

// controllo che esistano gli argomenti obbligatori
if( !WScript.Arguments.Named.Exists("filename") || !WScript.Arguments.Named.Exists("backfile") || !WScript.Arguments.Named.Exists("item1") )
{
        WScript.Arguments.ShowUsage();
        WScript.Quit();
}
filename = WScript.Arguments.Named("filename");
backfile = WScript.Arguments.Named("backfile");
item1 = WScript.Arguments.Named("item1");
if( WScript.Arguments.Named.Exists("maskcolor") )
{
        maskcolor = WScript.Arguments.Named("maskcolor");
}
else  
{
        maskcolor = "green";
}
if( WScript.Arguments.Named.Exists("xgap") )
{
        xgap = WScript.Arguments.Named("xgap") * 1;
}
else  
{
        xgap = 11;
}
if( WScript.Arguments.Named.Exists("aspect") )
{
        switch( WScript.Arguments.Named("aspect")) {
          case "normal" : xwidth = 192; break;
          case "widescreen" : xwidth = 256; break;
          default:
        WScript.Arguments.ShowUsage();
            WScript.Quit();
    }
}
else  
{
        xwidth = 256;
}

im = WScript.CreateObject("ImageMagickObject.MagickImage.1");
var arr = new Array();
var arrc = new Array();

var cnt = 0;
arr[0] = item1;
if( WScript.Arguments.Named.Exists("item2") )
{
        cnt++;
        arr[cnt] = WScript.Arguments.Named("item2");
}
if( WScript.Arguments.Named.Exists("item3") )
{
        cnt++;
        arr[cnt] = WScript.Arguments.Named("item3");
}
if( WScript.Arguments.Named.Exists("item4") )
{
        cnt++;
        arr[cnt] = WScript.Arguments.Named("item4");
}

arr[cnt+1] = "-tile";
arr[cnt+2] = "2x2";
arr[cnt+3] = "-geometry";
arr[cnt+4] = xwidth + "x144!+" + xgap + "+11";
arr[cnt+5] = "-frame";
arr[cnt+6] = "5";
arr[cnt+7] = "-background";
arr[cnt+8] = "transparent";
arr[cnt+9] = filename+"_page.png";

var cmd = "im.Montage(\"" + arr.join("\",\"")+"\")";
WScript.StdOut.WriteLine(cmd);
eval(cmd);

var cntc = 0;
arrc[0] = backfile;
arrc[1] = filename+"_page.png";
arrc[2] = "-geometry";
arrc[3] = "+" + (512 - xgap*2 - 5*2 - xwidth) + "+64";
arrc[4] = "-composite";
if( WScript.Arguments.Named.Exists("iconprev") )
{
        arrc[5] = WScript.Arguments.Named("iconprev");
        arrc[6] = "-geometry";
        arrc[7] = "+" + (512 - xgap - 5 - xwidth) + "+450";
        arrc[8] = "-composite";
        cntc++;
}
if( WScript.Arguments.Named.Exists("iconhome") )
{
        arrc[cntc*4+5] = WScript.Arguments.Named("iconhome");
        arrc[cntc*4+6] = "-geometry";
        arrc[cntc*4+7] = "+" + (512 - 64/2) + "+450";
        arrc[cntc*4+8] = "-composite";
        cntc++;
}
if( WScript.Arguments.Named.Exists("iconnext") )
{
        arrc[cntc*4+5] = WScript.Arguments.Named("iconnext");
        arrc[cntc*4+6] = "-geometry";
        arrc[cntc*4+7] = "+" + (512 + xgap + 5 + xwidth - 64) + "+450";
        arrc[cntc*4+8] = "-composite";
        cntc++;
}
arrc[cntc*4+5] = "-resize";
arrc[cntc*4+6] = "720x576!";
arrc[cntc*4+7] = filename+".jpg";

var cmd = "im.Convert(\"" + arrc.join("\",\"")+"\")";
WScript.StdOut.WriteLine(cmd);
eval(cmd);

// creazione maschere
im.Convert("xc:transparent", "-resize", xwidth+"x144!", "-bordercolor", maskcolor, "-compose", "copy", "-border", "5", "empty.png");
im.Convert("xc:transparent", "-resize", "64x64!", "-bordercolor", maskcolor, "-compose", "copy", "-border", "5", "btnmask.png");

for(j=0; j <= cnt; j++)
{
  arr[j] = "empty.png";
}
arr[cnt+4] = "+" + xgap + "+11";
arr[cnt+5] = "-bordercolor"
arr[cnt+6] = "transparent";
arr[cnt+9] = "png8:"+filename+"_page_mask.png";

var cmd = "im.Montage(\"" + arr.join("\",\"")+"\")";
WScript.StdOut.WriteLine(cmd);
eval(cmd);

arrc[0] = "-type";
arrc[1] = "Palette";
arrc[2] = "-colors";
arrc[3] = "2";
arrc[4] = "xc:transparent";
arrc[5] = "-resize";
arrc[6] = "1024x576!";
arrc[7] = filename+"_page_mask.png";
arrc[8] = "-geometry";
arrc[9] = "+" + (512 - xgap*2 - 5*2 - xwidth) + "+64";
arrc[10] = "-composite";
cntc = 0;
if( WScript.Arguments.Named.Exists("iconprev") )
{
        arrc[11] = "btnmask.png";
        arrc[12] = "-geometry";
        arrc[13] = "+" + (512 - xgap - 5 - xwidth - 5 ) + "+445";
        arrc[14] = "-composite";
        cntc++;
}
if( WScript.Arguments.Named.Exists("iconhome") )
{
        arrc[cntc*4+11] = "btnmask.png";
        arrc[cntc*4+12] = "-geometry";
        arrc[cntc*4+13] = "+" + (512 - 64/2 - 5) + "+445";
        arrc[cntc*4+14] = "-composite";
        cntc++;
}
if( WScript.Arguments.Named.Exists("iconnext") )
{
        arrc[cntc*4+11] = "btnmask.png";
        arrc[cntc*4+12] = "-geometry";
        arrc[cntc*4+13] = "+" + (512 + xgap + 5 + xwidth - 64 - 5) + "+445";
        arrc[cntc*4+14] = "-composite";
        cntc++;
}
arrc[cntc*4+11] = "-resize";
arrc[cntc*4+12] = "720x576!";
arrc[cntc*4+13] = "png8:"+filename+"_169_mask.png";

var cmd = "im.Convert(\"" + arrc.join("\",\"")+"\")";
WScript.StdOut.WriteLine(cmd);
eval(cmd);

// maschera per letterbox
arrc[cntc*4+12] = "720x432!";
arrc[cntc*4+13] = "png8:"+filename+"_43_page_mask.png";
var cmd = "im.Convert(\"" + arrc.join("\",\"")+"\")";
WScript.StdOut.WriteLine(cmd);
eval(cmd);

im.Convert("-type", "Palette", "-colors", "2", "xc:transparent", "-resize", "720x576!", filename+"_43_page_mask.png", "-geometry", "+0+72", "-composite", "png8:"+filename+"_43_mask.png");

</script>
</job>
Inizio pagina
Home page
 
Creative Commons  License BY-NC-SA
Ove non diversamente specificato i contenuti del sito sono rilasciati con licenza Creative Commons BY-NC-SA 4.0 

Copyright © 2007-2020 The Strawberry Field - Roberto Ceccarelli