Hello!
I want to know / to read the size of an image (x-pixels, y-pixels)
Is it possible with AHK?
//Jan
Read the image size (solved)
Started by
Albireo
, Jun 29 2010 02:01 PM
11 replies to this topic
#1
-
Posted 29 June 2010 - 02:01 PM
Thank´s for the answer!
But I can´t se how
You can create many images in many ways with this "script"
But if I have an image I want to know the x,y-size (in pixels)
(Before I want to process the image)
//Jan
But I can´t se how
You can create many images in many ways with this "script"
But if I have an image I want to know the x,y-size (in pixels)
(Before I want to process the image)
//Jan
#3
-
Posted 29 June 2010 - 02:40 PM
imagefile=c:\image.png GDIPToken := Gdip_Startup() pBM := Gdip_CreateBitmapFromFile( imagefile ) W:= Gdip_GetImageWidth( pBM ) H:= Gdip_GetImageHeight( pBM ) Gdip_DisposeImage( pBM ) Gdip_Shutdown( GDIPToken ) MsgBox, width=%W% height=%H% #Include Gdip.ahk
#4
-
Posted 29 June 2010 - 02:52 PM
imagefile=c:\image.png GDIPToken := Gdip_Startup() pBM := Gdip_CreateBitmapFromFile( imagefile ) W:= Gdip_GetImageWidth( pBM ) H:= Gdip_GetImageHeight( pBM ) Gdip_DisposeImage( pBM ) Gdip_Shutdown( GDIPToken ) MsgBox, width=%W% height=%H% #Include Gdip.ahk
Jepp! It works!
(I haven' t see this :-)
Thank you!
//Jan
#5
-
Posted 29 June 2010 - 03:09 PM
imagefile=c:\image.png GDIPToken := Gdip_Startup() pBM := Gdip_CreateBitmapFromFile( imagefile ) W:= Gdip_GetImageWidth( pBM ) H:= Gdip_GetImageHeight( pBM ) Gdip_DisposeImage( pBM ) Gdip_Shutdown( GDIPToken ) MsgBox, width=%W% height=%H% #Include Gdip.ahk.....
Can I have this "code" in an other Function?
(It doesn't work for me )
//Jan
#6
-
Posted 30 June 2010 - 03:55 PM
Can I have this "code" in an other Function?
Can you please further define "other Function" ? .. or post a part of your code that shows your usage of the given code.
#7
-
Posted 30 June 2010 - 04:36 PM
Here's another way to get the size of an image. It doesn't depend on GDI+
The GUI number 99 is arbitrary, just don't want to interfere with an existing GUI.
The GUI number 99 is arbitrary, just don't want to interfere with an existing GUI.
imagefile=c:\image.png guinum=99 gui, %guinum%:add, picture, vmypic, %imagefile% GuiControlGet, mypic, %guinum%:Pos gui, %guinum%:destroy ;MsgBox The X coordinate is %mypicX%. The Y coordinate is %mypicY%. MsgBox The width is %mypicW%. The height is %mypicH%. return
#8
-
Posted 01 July 2010 - 08:16 AM
Dear leef_me: That would not work if the image dimensions are larger than A_ScreenWidth / A_ScreenHeight.
#9
-
Posted 01 July 2010 - 08:18 AM
Do you need something like this?Can I have this "code" in an other Function?
;Example: MsgBox % GetImageSize("C:\image.png") ;===Functions=== #Include Gdip.ahk ; by Tic. Location: http://www.autohotkey.com/forum/topic32238.html GetImageSize(ImageFullPath) { GDIPToken := Gdip_Startup() pBM := Gdip_CreateBitmapFromFile( ImageFullPath ) W:= Gdip_GetImageWidth( pBM ), H:= Gdip_GetImageHeight( pBM ) Gdip_DisposeImage( pBM ), Gdip_Shutdown( GDIPToken ) return w "x" h }
#10
-
Posted 01 July 2010 - 08:44 AM
Dear SKAN, your statement is incorrect.Dear leef_me: That would not work if the image dimensions are larger than A_ScreenWidth / A_ScreenHeight.
I just tested the script with an oversize image 3125 x 1768 and it works. :wink:
I used such a large value in case my (3) monitors 1024 x 768 might allow for bigger images.
#11
-
Posted 01 July 2010 - 09:03 AM
Dear SKAN, your statement is incorrect.
Jeez!. I did not look into your code properly. Last time I tried something like that, I was ascertaining the GUI size instead of control's size. Thank you. Your snippet is a treat.
#12
-
Posted 01 July 2010 - 09:29 AM