Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Image Sizes

Reply
Thread Tools

Image Sizes

 
 
p byers
Guest
Posts: n/a
 
      12-08-2008
Hello Folks,

I have a WebSite that allows clients to upload 'ImageFiles'

They are restricted to .JPG, .GIF and .PNG and a size of 100Kb.

I have a page that will show the Images. The size is to be restricted.

If the image height and width is less than the restricted size, the
image is just centred in the 'Restricted Area'.

If the image height or width is greater than the restricted size, the
"IMG" tag has "height" & "width" parameters to contain it into the
"Restricted Area".

At the momement, the image size is obtained by the use of ServerObjects
ASPImage Active X object.


I need to put a copy of the page onto a server that does not have
ASPImage installed.

Is there any way I can get Image Width and Height without any special
Active X 'es ??

Thank you
Pete (Northolt UK)

 
Reply With Quote
 
 
 
 
Mike Brind
Guest
Posts: n/a
 
      12-08-2008

"p byers" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Folks,
>
> I have a WebSite that allows clients to upload 'ImageFiles'
>
> They are restricted to .JPG, .GIF and .PNG and a size of 100Kb.
>
> I have a page that will show the Images. The size is to be restricted.
>
> If the image height and width is less than the restricted size, the
> image is just centred in the 'Restricted Area'.
>
> If the image height or width is greater than the restricted size, the
> "IMG" tag has "height" & "width" parameters to contain it into the
> "Restricted Area".
>
> At the momement, the image size is obtained by the use of ServerObjects
> ASPImage Active X object.
>
>
> I need to put a copy of the page onto a server that does not have
> ASPImage installed.
>
> Is there any way I can get Image Width and Height without any special
> Active X 'es ??
>


Not unless you can use ASP.NET for that page.

--
Mike Brind
MVP - ASP/ASP.NET


 
Reply With Quote
 
 
 
 
Roger
Guest
Posts: n/a
 
      12-09-2008

"p byers" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Folks,
>
> I have a WebSite that allows clients to upload 'ImageFiles'
>
> They are restricted to .JPG, .GIF and .PNG and a size of 100Kb.
>
> I have a page that will show the Images. The size is to be restricted.
>
> If the image height and width is less than the restricted size, the
> image is just centred in the 'Restricted Area'.
>
> If the image height or width is greater than the restricted size, the
> "IMG" tag has "height" & "width" parameters to contain it into the
> "Restricted Area".
>
> At the momement, the image size is obtained by the use of ServerObjects
> ASPImage Active X object.
>
>
> I need to put a copy of the page onto a server that does not have
> ASPImage installed.
>
> Is there any way I can get Image Width and Height without any special
> Active X 'es ??
>
> Thank you
> Pete (Northolt UK)


Hi Pete,

I have an old bit of code which works for jpg and gif...

set i = loadpicture(server.mappath(whatever))
owidth = round(i.width / 26.4583)
oheight = round(i.height / 26.4583)

I don't recall why I had to divide by 26.4583, and it does need write
permission on the file - or folder(?).

For png the width + height seems to be bytes 16-20 and 21-24 (but check the
spec, this code is ancient)
so you can do...

set o = server.CreateObject("ADODB.Stream")
set fso = server.CreateObject("Scripting.FileSystemObject")
set ff = fso.GetFile(server.mappath(f))
o.Type = 1
o.Open
o.LoadFromFile(server.mappath(f))
select case ff.type
case "PNG Image"
scanimg 24, 20, 24

where scanimg is...

function scanimg(f,w,h)
dim s

s = o.Read(f)
if lenb(s) = f then
owidth = clng(ascb(midb(s, w, 1)) + ((ascb(midb(s, w - 1, 1)) * 256)))
oheight = clng(ascb(midb(s, h, 1)) + ((ascb(midb(s, h - 1, 1)) * 256)))
end if

end function

That code only looks at two bytes rather than four, but you can see the
idea.

You can do similar things with bitmap, tif, gif, but jpeg is a right pain in
the arse.

Roger


 
Reply With Quote
 
p byers
Guest
Posts: n/a
 
      12-09-2008
Jon
Thanks - it is brilliant - just what I needed
Pete (Northolt UK)

"Jon Paal [MSMD]" wrote:

> try this
>
> http://www.4guysfromrolla.com/webtec...imgsz.asp.html
>
> "p byers" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > Hello Folks,
> >
> > I have a WebSite that allows clients to upload 'ImageFiles'
> >
> > They are restricted to .JPG, .GIF and .PNG and a size of 100Kb.
> >
> > I have a page that will show the Images. The size is to be restricted.
> >
> > If the image height and width is less than the restricted size, the
> > image is just centred in the 'Restricted Area'.
> >
> > If the image height or width is greater than the restricted size, the
> > "IMG" tag has "height" & "width" parameters to contain it into the
> > "Restricted Area".
> >
> > At the momement, the image size is obtained by the use of ServerObjects
> > ASPImage Active X object.
> >
> >
> > I need to put a copy of the page onto a server that does not have
> > ASPImage installed.
> >
> > Is there any way I can get Image Width and Height without any special
> > Active X 'es ??
> >
> > Thank you
> > Pete (Northolt UK)
> >


 
Reply With Quote
 
p byers
Guest
Posts: n/a
 
      12-09-2008
Thanks for your reply

Roger wrote:

> "p byers" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello Folks,
> >
> > I have a WebSite that allows clients to upload 'ImageFiles'
> >
> > They are restricted to .JPG, .GIF and .PNG and a size of 100Kb.
> >
> > I have a page that will show the Images. The size is to be restricted.
> >
> > If the image height and width is less than the restricted size, the
> > image is just centred in the 'Restricted Area'.
> >
> > If the image height or width is greater than the restricted size, the
> > "IMG" tag has "height" & "width" parameters to contain it into the
> > "Restricted Area".
> >
> > At the momement, the image size is obtained by the use of ServerObjects
> > ASPImage Active X object.
> >
> >
> > I need to put a copy of the page onto a server that does not have
> > ASPImage installed.
> >
> > Is there any way I can get Image Width and Height without any special
> > Active X 'es ??
> >
> > Thank you
> > Pete (Northolt UK)

>
> Hi Pete,
>
> I have an old bit of code which works for jpg and gif...
>
> set i = loadpicture(server.mappath(whatever))
> owidth = round(i.width / 26.4583)
> oheight = round(i.height / 26.4583)
>
> I don't recall why I had to divide by 26.4583, and it does need write
> permission on the file - or folder(?).
>
> For png the width + height seems to be bytes 16-20 and 21-24 (but check the
> spec, this code is ancient)
> so you can do...
>
> set o = server.CreateObject("ADODB.Stream")
> set fso = server.CreateObject("Scripting.FileSystemObject")
> set ff = fso.GetFile(server.mappath(f))
> o.Type = 1
> o.Open
> o.LoadFromFile(server.mappath(f))
> select case ff.type
> case "PNG Image"
> scanimg 24, 20, 24
>
> where scanimg is...
>
> function scanimg(f,w,h)
> dim s
>
> s = o.Read(f)
> if lenb(s) = f then
> owidth = clng(ascb(midb(s, w, 1)) + ((ascb(midb(s, w - 1, 1)) * 256)))
> oheight = clng(ascb(midb(s, h, 1)) + ((ascb(midb(s, h - 1, 1)) * 256)))
> end if
>
> end function
>
> That code only looks at two bytes rather than four, but you can see the
> idea.
>
> You can do similar things with bitmap, tif, gif, but jpeg is a right pain in
> the arse.
>
> Roger


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Win 7 changing font sizes without icon sizes? why? Computer Support 0 03-21-2010 11:32 AM
Re: Win 7 changing font sizes without icon sizes? why? Computer Support 0 03-21-2010 11:31 AM
The File Sizes of Pictures on my CDs Increased to Unreadable Sizes Marful Computer Support 11 03-08-2006 07:13 PM
Firefox doesn't change image sizes when zooming Markus Dehmann Firefox 3 02-19-2005 07:46 AM
Different image sizes - 464 KB to 1941 KB from the same setting zxcvar Digital Photography 2 05-12-2004 03:13 AM



Advertisments