[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Get dimensions of a GIF, JPG file

I need to get the dimensions (width and height) of a GIF and a JPG file using Visual Basic.Something like this:

  GetJPGDimensions (sFile as string, lWidth as long, lHeight as long)

  GetGIFDimennsions (sFile as string, lWidth as long, lHeight as long)

0
Jaume Gelabert
Asked:
Jaume Gelabert
  • 2
1 Solution
 
paaskyCommented:
Hello jaumeg,

With Access VBA you could use these functions:

Global lWidth As Long
Global lHeight As Long

Public Sub GetJPGDimensions(sFile As String)
Dim MyImage As Object

    Set MyImage = LoadPicture(sFile)
    lWidth = MyImage.Width
    lHeight = MyImage.Height
   
    ' Free memory
    Set MyImage = Nothing

End Sub

Public Sub GetGIFDimensions(sFile As String)
Dim MyImage As Object

    Set MyImage = LoadPicture(sFile)
    lWidth = MyImage.Width
    lHeight = MyImage.Height
   
    ' Free memory
    Set MyImage = Nothing
   
End Sub

If you're looking how to do this with VB you should post it to Visual Basic Topic.

Regards,
Paasky
0
 
TrygveCommented:
You could of course combine the two since they are 100% equal...

Public Sub GetDimensions(sFile As String, lWidth as long, lHeight as long)
Dim MyImage As Object

    Set MyImage = LoadPicture(sFile)
    lWidth = MyImage.Width
    lHeight = MyImage.Height
     
    ' Free memory
    Set MyImage = Nothing

End Sub
0
 
paaskyCommented:
Trygve, I know...

And you can check size of many other picture file formats with the same way too.

Paasky
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now