Find a piece of code on the Internet, compile it into a component can be used, but also support png<br>
<br>
<br>
' I have released this source code into the public domain. Use it<br>
' With no strings attached.<br>
' Just call getimagesize with a string containing the filename, and<br>
' It'll return a user defined type ' imagesize ' (below) <br>
' Return values of 0 indicate an error of some sort. The error handling<br>
' In this module is limited. There is *no* error handling on the test<br>
' Form. This routine was limited to X or Y sizes of 32767 pixels, but that<br>
' should not to be a problem.<br>
<br>
' Check back at http://www.qtm.net/~davidc<br>
' I may add support for the more file types.<br>
<br>
' Supported in this version:<br>
' Jpeg<br>
' Gif<br>
' Png<br>
<br>
' This routine does is not require any royalty fees for Unisys as it<br>
' Does nothing with the compressed part of GIF files. It simply Reads<br>
' 4 bytes to determine image size.<br>
<br>
Option explicit<br>
Public WiMG as Long<br>
Public himg as Long<br>
Public Type imagesize<br>
Width as Long<br>
Height as Long<br>
End Type<br>
<br>
Public Sub getimagesize (sfilename as String) <br>
On Error Resume Next ' I ll want to change this<br>
Dim IFN as Integer<br>
Dim Btemp (3) as byte<br>
Dim Lflen as Long<br>
Dim Lpos as Long<br>
Dim BHMSB as Byte<br>
Dim BHLSB as Byte<br>
Dim BWMSB as Byte<br>
Dim BWLSB as Byte<br>
Dim Bbuf (7) as byte<br>
Dim Bdone as Byte<br>
Dim Icount as Integer<br>
<br>
Lflen = FileLen (sfilename) <br>
IFN = freefile<br>
Open sfilename for Binary as ifn<br>
Get #iFN, 1, btemp () <br>
<br>
' PNG file<br>
If btemp (0) = &h89 and btemp (1) = &h50 and btemp (2) = &h4e _<br>
and Btemp (3) = &h47 then<br>
Get #iFN, bwmsb<br>
Get #iFN, bwlsb<br>
Get #iFN, bhmsb<br>
Get #iFN, bhlsb<br>
' Getimagesize.width = Combinebytes (BWLSB, BWMSB) <br>
' Getimagesize.height = Combinebytes (BHLSB, BHMSB) <br>
WiMG = Combinebytes (BWLSB, BWMSB) <br>
himg = Combinebytes (BHLSB, BHMSB) <br>
End If<br>
<br>
' GIF file<br>
If btemp (0) = &h47 and btemp (1) = &h49 and btemp (2) = &h46 _<br>
and Btemp (3) = &h38 then<br>
Get #iFN, 7, bwls