Finding Image Height Widht

Post Reply
pradeepnitp
Newbie
Posts: 9
Joined: Tue Mar 18, 2014 3:17 pm

Finding Image Height Widht

Post 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 .
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Finding Image Height Widht

Post by dkelly »

Select "single line with variables" and select Photo->PixelXDimension
pradeepnitp
Newbie
Posts: 9
Joined: Tue Mar 18, 2014 3:17 pm

Finding Image Height Widht

Post 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.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Finding Image Height Widht

Post 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");
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Finding Image Height Widht

Post 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]");



User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Finding Image Height Widht

Post 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!
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
pradeepnitp
Newbie
Posts: 9
Joined: Tue Mar 18, 2014 3:17 pm

Finding Image Height Widht

Post by pradeepnitp »

HI Thanks , I am new to scripting .

But which flow element should I select for writing private data.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Finding Image Height Widht

Post 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.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
pradeepnitp
Newbie
Posts: 9
Joined: Tue Mar 18, 2014 3:17 pm

Finding Image Height Widht

Post by pradeepnitp »

If you can share it. It will be great help for me.



I
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Finding Image Height Widht

Post 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
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply