Page 1 of 1

Finding Image Height Widht

Posted: Tue Sep 16, 2014 5:10 pm
by pradeepnitp
hi ,

I have a image and have to find the image height & widht and then based on that I need to process further .



Is this possible from enfocus inbuilt variables. Or do I have to call external command to fetch this value.



I see Photo.PixelXDimension in script option but don't know how to use it .

Finding Image Height Widht

Posted: Tue Sep 16, 2014 6:36 pm
by dkelly
Select "single line with variables" and select Photo->PixelXDimension

Finding Image Height Widht

Posted: Wed Sep 17, 2014 9:45 pm
by pradeepnitp
Thanks . But which flow element should I select for this and how I can use this in script .



I tried with below code in script

var imageWidth = job.getVariableAsNumber("[Photo.PixelXDimension]");



It is giving error Photo Object is not recognized.

Finding Image Height Widht

Posted: Wed Sep 17, 2014 10:02 pm
by gabrielp
pradeepnitp wrote: Thanks . But which flow element should I select for this and how I can use this in script .



I tried with below code in script

var imageWidth = job.getVariableAsNumber("[Photo.PixelXDimension]");



It is giving error Photo Object is not recognized.


So... I think what he is saying, you would have to have an element grab this value ahead of time -- said another way: he isn't explaining how to get this value inside the actual script.



What I would do is drop a "write to private data script" that writes the key "PixelXDimension" to value, select "Single line text with values". Then Photo > PixelxDimension. Then flow that into your script.



Now, in your script, you can do:

var PixelXDimension = job.getPrivateData("PixelXDimension");

Finding Image Height Widht

Posted: Wed Sep 17, 2014 10:49 pm
by dkelly
Here's how I get info from any PDF file in a script. Photo should be similar.





var stats = new FileStatistics(filename);

var numPages = stats.getNumber("NumberOfPages");

var pageWidth = stats.getNumber("PageWidth");

var pageHeight = stats.getNumber("PageHeight");





and for a PDF job





var numPages = job.getVariableAsNumber("[Stats.NumberOfPages]");

var pageWidth = job.getVariableAsNumber("[Stats.PageWidth]");

var pageHeight = job.getVariableAsNumber("[Stats.NPageHeight]");




Finding Image Height Widht

Posted: Thu Sep 18, 2014 3:05 pm
by gabrielp
dkelly wrote: Here's how I get info from any PDF file in a script
Was not aware of that class. Very cool. Thank you!

Finding Image Height Widht

Posted: Fri Sep 19, 2014 6:52 pm
by pradeepnitp
HI Thanks , I am new to scripting .

But which flow element should I select for writing private data.

Finding Image Height Widht

Posted: Fri Sep 19, 2014 7:42 pm
by gabrielp
pradeepnitp wrote: HI Thanks , I am new to scripting .

But which flow element should I select for writing private data.
Switch doesn't come with one right out of the box but it's a pretty simple script (and very handy). Mine has a bunch of input values (Key1, Value1, Key2, Value2, etc..) and you can specify key and value pairs with single line text with values. Then just pass your job through and access the private data anywhere later.



The script is as simple as:

job.setPrivateData( key1, value1 );


If you can't figure it out, let me know and I can share mine with you.

Finding Image Height Widht

Posted: Fri Sep 19, 2014 8:55 pm
by pradeepnitp
If you can share it. It will be great help for me.



I

Finding Image Height Widht

Posted: Fri Sep 19, 2014 9:28 pm
by gabrielp
pradeepnitp wrote: If you can share it. It will be great help for me.



I
Here you go: https://github.com/dominickp/SwitchWriteToPrivateData