Link to home
Start Free TrialLog in
Avatar of VB-tinkerer
VB-tinkerer

asked on

width and height for HTML <IMG> tag from VB

Does anybody know how I can determine the width/height
of a gif picture in the measurements that a Html browser
expects to see in
<IMG height="50" width="120" SRC=".......>
Please give me some code!!!
Avatar of tward
tward

If you have read the line in then simply use:

Position = Instr(1,TheLine,"height",0)
SpacePosition = Instr(Position, TheLine, " ", 0)

Height = Mid(TheLine, Position+8, SpacePosition-(Position+8))

This should get the height then do the same thing with some different numbers to get the width.
Avatar of VB-tinkerer

ASKER

I obviously didn't express myself very well.  What I want to do is
load a picture in VB and then determine the width number and the height number of the picture, so that I can use it in my html statement:

      <IMG height="50" width="120" SRC=".......>

In other words I want to be able to determine what the numbers should be so that I can write the above statement
Oh, can't you just load it into a picture box that has the autosize set to true, what happens is the picture box will shrink or expand to fit the image loaded into it, then just take the width and height from the size of the picturebox..?  I know VB 5.0's pictureboxes supports GIF and JPEG but you didn't state which version of VB you were using.
I am quite familiar with the .width and .height properties of the picture box.  However none of the measurements available seem to correspond to the measurements required in the HTML pages.  I tried to find a conversion factor - but the conversion factor seems to be non-constant:

e.g.  Picture Term_Small.gif

                       VB                                   HTML
height            990                                   62
width            1470                                   94

Home.gif
height             705                                    47
width               420                                   24

As the original question states:  I want some code that gives me
the MEASUREMENTS THAT A HTML BROWSER EXPECTS TO SEE
Since the Picturebox give the values in twips by default take the
width/screen.twipsperpixelX
height/screen.twipsperpixelY

or set your form to be in Pixels ScaleMode.

The Height and Width of Images in HTML is needed in Pixels.
Thanks - this seems to work fine.
If you know a faster way to do this (e.g. reading the .GIF file directly and getting the information from there) that would be great!!

Do you know how I now can award you the points?  I don't seem to have a rating possibility anymore?

Thanks again.
ASKER CERTIFIED SOLUTION
Avatar of tward
tward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I'll check that out later.