Find bitmap file x/y size

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
twardega
Newbie
Posts: 15
Joined: Fri Oct 12, 2007 5:54 pm

Find bitmap file x/y size

Post by twardega » Tue Jan 29, 2008 4:09 am

There is a function to capture a rectangle to .bmp file:
ScreenCapture>X1,Y1,X2,Y2,Filename

I am looking for a way to find width, height and color depth of bitmap file from Macro Scheduler, something like:
ImageProperties>Filename,Width,Height,ColorDepth

Image editors provide this information about image files. I would appreciate suggestions how to get this information in Macro Scheduler.

twardega
Newbie
Posts: 15
Joined: Fri Oct 12, 2007 5:54 pm

Post by twardega » Tue Jan 29, 2008 1:45 pm

OK. After some research this what I came up with (still need to find color depth). Maybe it will be useful for others...

VBSTART
Function ImgDimensions (ImgFile)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
If fs.fileExists(ImgFile) Then
Set myImg = Loadpicture(ImgFile)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
Set myImg = nothing
ImgDimensions = iWidth & "X" & iHeight
End If
End Function
VBEND

Let>NeedleImageFile1=%SCRIPT_DIR%\ToolbarIdentifier6.bmp
VBEval>ImgDimensions("%NeedleImageFile1%"),Dims
MessageModal>%NeedleImageFile1% %Dims%

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jan 29, 2008 2:08 pm

Good job :D

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Jan 29, 2008 7:08 pm

jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

twardega
Newbie
Posts: 15
Joined: Fri Oct 12, 2007 5:54 pm

Post by twardega » Tue Jan 29, 2008 10:00 pm

Thanks! This is what I was looking for.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jan 29, 2008 11:49 pm

Wow, great example jpuziano. I downloaded that same code but couldn't get it working :oops:

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

Post by JRL » Wed Jan 30, 2008 4:37 am

Very nice.

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

Post by JRL » Mon Nov 05, 2012 6:39 pm

For several years I've been using the scripts on this page to get image size information. Today it occurred to me there is an easy way to get size info for jpg, bmp and png files. All you need to do is create a dialog in Macro Scheduler version 12 or greater and load the image into an autosized image abject. Acquire the width and height of the object and you have the size information. No need to actually display the dialog.

Hope someone finds this useful.

Code: Select all

Let>ImageFile=Path\fname.png

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

MDL>%xpixels% by %ypixels%

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon Nov 05, 2012 7:08 pm

Hi JRL,

Now that's a lot easier and a lot less code isn't it... thanks for sharing!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re:

Post by ocnuybear » Wed Sep 05, 2018 5:11 pm

Excellent thank you :D
JRL wrote:
Mon Nov 05, 2012 6:39 pm
For several years I've been using the scripts on this page to get image size information. Today it occurred to me there is an easy way to get size info for jpg, bmp and png files. All you need to do is create a dialog in Macro Scheduler version 12 or greater and load the image into an autosized image abject. Acquire the width and height of the object and you have the size information. No need to actually display the dialog.

Hope someone finds this useful.

Code: Select all

Let>ImageFile=Path\fname.png

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

MDL>%xpixels% by %ypixels%

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