Picture size in pixel

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Picture size in pixel

Post by ZeitenWanderer » Fri Oct 10, 2014 2:37 pm

Would anyone have a hint on how I request in MacroScheduler (or VB) the size of a picture in pixel?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Picture size in pixel

Post by JRL » Fri Oct 10, 2014 3:51 pm


ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Re: Picture size in pixel

Post by ZeitenWanderer » Sat Oct 18, 2014 12:12 pm

Yep, your snippet worked just fine. Now I am trying to enhance it.

[snippet=]Let>ImageFile=c:\test\pics2.jpg
Dialog>ImageSizeDialog
object ImageSizeDialog: TForm
object MSImage1: tMSImage
AutoSize = True
end
end
EndDialog>ImageSizeDialog
SetDialogProperty>ImageSizeDialog,MSImage1,LoadImage,Imagefile
GetDialogProperty>ImageSizeDialog,MSImage1,Width,Xpixels
GetDialogProperty>ImageSizeDialog,MSImage1,Height,Ypixels

WriteLN>test.txt,result,%xpixels%,%ypixels%[/snippet]

This gets me the pixel size. (Thanks again!!)

Now I have set up a tiny ini.file, from where I want to read permanent values for the calibration of a fixed camera.
This would convert the gained pixel sizes into cm. That for, I first of all take a picture of an object, which I measured before.
I find out, it is 100 x 100 mm, which I later would divide by the number of pixels. The final value would tell me, how many pixel make out a cm in this setting. So far for the plan ...

test.ini
[calibrate]
value1=100
value2=100

[snippet=]
ReadIniFile>C:\test\test.ini,calibrate,value1,size
Let>msg=The size is
ConCat>msg,size
Message>msg
[/snippet]

I had expected to see a message "The size is 100" - but it is "The size is ".
Any hint why I can not pick the value from the ini-file?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Picture size in pixel

Post by Marcus Tettmar » Sat Oct 18, 2014 9:30 pm

What is the value of "size" in the debugger watch list?

What do you see if you do:

MessageModal>size

Or:

MessageModal>Size is %size%

right after the ReadiniFile call.

Could any of those values already be variables. What happens if you do:

ReadIniFile>C:\test\test.ini,{"calibrate"},{"value1"},varSize
MessageModal>varSize
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ZeitenWanderer
Pro Scripter
Posts: 68
Joined: Wed Dec 07, 2005 7:13 am

Re: Picture size in pixel

Post by ZeitenWanderer » Sun Oct 19, 2014 4:00 pm

What is the value of "size" in the debugger watch list?
The watch list shows a zero for every line. Do I have this right?
MessageModal>size

Or:

MessageModal>Size is %size%

right after the ReadiniFile call.
It shows "size" or "Size is %size%"
Could any of those values already be variables. What happens if you do:

ReadIniFile>C:\test\test.ini,{"calibrate"},{"value1"},varSize
MessageModal>varSize
I have not defined any further variables and in this case the message field is empty.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Picture size in pixel

Post by JRL » Mon Oct 20, 2014 3:55 am

Look in the ini file and make sure that the spelling is correct for the Section Name and the Entry Name. Also make sure you have a value for "value1".

Also check that the path and file name are correct and that you and Macro Scheduler have rights to open the file.

ReadIniFile> has always worked well. You're likely missing something easy
The watch list shows a zero for every line. Do I have this right?
Yes, every line in the watch list starts with 0: . I think its for future capabilities. It has no bearing on the watch list functionality.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Picture size in pixel

Post by Marcus Tettmar » Mon Oct 20, 2014 11:50 am

Yes, every line in the watch list starts with 0: . I think its for future capabilities. It has no bearing on the watch list functionality.
Actually it tells you the level of scope. If you step into a subroutine and local variables are enabled, you'll see that number increment. Each level of scope deeper, the higher that number becomes. It's really just to help in the case where you may have local variables enabled and a local variable with the same name as a variable at a higher scope. Without this numeric scope indicator you won't know which was which.

Probably 99% of people will never use local variables and won't care (and may not understand what I just said). If that's you just ignore that zero :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts