Using variable in a script sub
Posted: 16 Oct 2012 16:42
Hi, I've been going nuts trying to do something very simple in a script. I have a working script which I've assigned a TB button. It basically just provides a menu to crop a photo down to specific resolutions mainly just to view the photos as wallpaper on a few computers which have different aspect ratios (eg., one computer is 8x5 (1920x1200) and anther is 16x9 (1920x1080). The original photos have different resolutions and aspect ratios (3x2, 4x3, and 16x9). I'd like to make the script (and me
) a bit smarter such that it detects the "property dimensions" of the current file selected (e.g 4320x3240) and based on that, the script goes to a "sub" section ot the script which performs the appropriate actions using Irfanview to crop the photo to the desired resolution. At this point, I'll probably just work with one file (jpg) at a time. I figured I can use the property command to determine the jpg file resoltion, but I want the script to go to a particular section of the script based on that resolution. This portion of the code will give you an idea of what I'm trying to accomplish. Obviously, I must be messing up the variable syntax somehow, but I tried numerous variations without any luck. Note: The Irfanview and Input command work fine. How do I get the script to go to the appropriate section of the script based on the property dimension (resolution). I'm not sure if having the labels the same, but based on the "property dimension" variable will be a problem either since I've been testing this with only one label at this point and still can't get it to function (Error: The list of Labels did not match any script...) Any help would be greatly appreciated.
Thanks,
Ken
Code: Select all
//"IrfanView Convert to 16x9|D:\Graphics\Icons\k321-icon-218.ico";
$d = property(dimensions, <curitem>);
sub "res_$d";
//"Convert Landscape 4320x3240 to 16x9|D:\Graphics\Icons\k321-icon-218.ico";
"res_$d : _res$d";
$a = input("Crop offset "y" value from 0,0",Enter number from 1 to 810 (405 centers crop vetically). ,405, "m",,300,300);
run """D:\Graphics\IrfanView\i_view32.exe"" ""<curitem>"" /aspectratio /jpgq=100 /resample /crop=(0,$a,4320,2430) /convert=<curpath>\<curbase>_16x9.<curext>", , 2,0;
//"Convert Landscape 3888x2592 to 16x9|D:\Graphics\Icons\program-small-icons.ico;
"res_$d : res_$d";
$a = input("Crop offset "y" value from 0,0","Enter number from 1 to 405 (203 is centered)." ,203, "m",,300,300);
run """D:\Graphics\IrfanView\i_view32.exe"" ""<curitem>"" /aspectratio /jpgq=100 /resample /crop=(0,$a,3888,2187) /convert=<curpath>\<curbase>_16x9.<curext>", , 2,0;
"res_$d : res_$d";
//"Convert Portrait 3240x4320 to 16x9|D:\Graphics\Icons\k321-icon-219.ico";
$a = input("Crop offset "y" value from 0,0","Enter number from 1 to 2498 (1248 is centered)." ,1248, "m",,300,300);
run """D:\Graphics\IrfanView\i_view32.exe"" ""<curitem>"" /aspectratio /jpgq=100 /resample /crop=(0,$a,3240,1822) /convert=<curpath>\<curbase>_16x9.<curext>", , 2,0;
Thanks,
Ken