Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imagesize 1

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
I am trying to ascertain the size of an image file with the following code


Local imagesize

Set Compatible On && file rather than field
&& get the size
(variables defined here)

imagesize = Str(Fsize(lcImage)/1024,6,1)+ 'K' && Kb
imagesize = Str(Fsize(Justfname(oldexhpath))/1024,6,1) + 'K'

Set Compatible Off

Neither give me a result!

Two points

I seem to remember someone giving me a better method?

Would this work on a mapped drive?

Regards

Coldan
 
Correction.

The routine works!

But the question remains.

C
 
Coldan,

Although your method works, it's generally not advisable to set COMPATIBLE on.

Also, can we assume that what you want is the size of the image file? (That is, the number of bytes in the file, rather than the number of pixels in the image).

If so, you could do it this way:

Code:
lnCount = ADIR(laTemp, lcImage)
IF lnCount > 0
  ? laTemp(2)    && file size in bytes
ELSE
  * File not found
ENDIF

This assumes that lcImage contains the file name of the image (including the path if not in the VFP search path).

In answer to your other question, it should work just as well if the image is on a mapped drive. Provided VFP can file the file, it should make no difference.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi,

and just in case you would like to have the picture.width and picture.heigth:

Code:
loImage = createobject("Image")
loImage.picture = getpict("JPG|GIF")
if empty(loImage.Picture)
	messagebox( "No picture !", 0+32+0, "Error",0 )
	return .f.
ENDIF
lnWidth = loImage.width
lnHeight = loImage.height

reagrds,

Jockey(2)

JOCKEY.GIF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top