Find bitmap file x/y size
Moderators: Dorian (MJT support), JRL
Find bitmap file x/y size
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.
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.
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%
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%
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 -
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 -
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.
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%
Hi JRL,
Now that's a lot easier and a lot less code isn't it... thanks for sharing!
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 -
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 -
Re:
Excellent thank you
JRL wrote: ↑Mon Nov 05, 2012 6:39 pmFor 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%