HELP!!!! How to get the resolution or size of the image (.jpg, .bmp,....)

HELP!!!! How to get the resolution or size of the image (.jpg, .bmp,....)

Post by Luis Gerardo SAyeg » Thu, 15 May 2003 09:39:06


Hi,

I need to get the resolution or size of the image file (.jpg or .bmp)

 
 
 

HELP!!!! How to get the resolution or size of the image (.jpg, .bmp,....)

Post by Mike D Sutto » Thu, 15 May 2003 18:50:46


Quote:> I need to get the resolution or size of the image file (.jpg or .bmp)

I have a couple of libraries that will do this for you by parsing the image
header (JPEGInfo and BMPInfo - Also GIFInfo too if you're interested in that
format too.)  If you want them then e-mail me and I'll send them over.
The other way of doing it is to load the entire image into a StdPicture
object, and query the size:

'***
Dim TempPic As StdPicture

Set TempPic = LoadPicture("X:\Path\File.jpg")
ImgWidth = ScaleX(TempPic.Width, vbHimetric, vbPixels)
ImgHeight = ScaleY(TempPic.Height, vbHimetric, vbPixels)
Set TempPic = Nothing
'***

This however does assume that you have a control exposing the ScaleX/Y()
methods available, and that you're sure the files are not broken since
LoadPicture will often *on these taking you application with it.  To
bypass the latter problem, you can use this alternative function:
http://www.veryComputer.com/%40TK2MSFTNGP12
(This validation method is also built into the afore mentioned libraries.)
If this is going into a class or such like then to bypass the ScaleX/Y()
methods, you can use the following conversion:
http://www.veryComputer.com/%23cuCHA.2280%40TK2MSFTNGP11
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: http://www.veryComputer.com/