CImageInfo

Author: David Crowell
davidc@qtm.net
http://www.qtm.net/~davidc
Released to the public domain
version date: June 16, 1999

CImageInfo is a Visual Basic class module that will extract image dimensions, type, and color depth from the following image types:

How to use

Add this class module to your VB project, and...

{in declarations}
Private ImageInfo as CImageInfo

{In Form_Load or elsewhere}
Set ImageInfo = New CImageInfo

{when you need to use}
ImageInfo.ReadImageInfo "C:\somefolder\somefile.fil"
Debug.Print ImageInfo.Width, ImageInfo.Height

Properties

Width

Read-only. Returns long indicating width of the image.

Height

Read-only. Returns long indicating height of the image.

Depth

Read-only. Returns byte indicating color depth (in bits per pixel) of the image.

ImageType

Read-only. Returns long (actually an eImageType Enum) indicating the type of image. Possibe values are:

Methods

ReadImageInfo(sFileName As String)

Takes a string parameter containing the filename to read. Returns nothing.

Note that there is no error checking here. It is up to the application to handle any errors that may occur here. Also note that the file extension is not important. CImageInfo will recognize a JPEG file even if it has a .gif or .garbage extension.

Want to help?

If you've fixed a bug in this code, or added a new feature, or made any other improvement, feel free to let me know, and I can put the update on my site (giving you credit of course). If you submit an improved version to me it must be public domain, just as this version is. You can however change it yourself, claim a copyright on your part, and not submit it to me. It's your choice. If you find a bug and don't have the knowledge or time to fix it let me know and I'll try to fix it. Sending an image file that it can't read would be helpful, as I have tested it on thousands of files without a problem yet.

Hope you find this code useful,
David Crowell