VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-Cart StoreFront Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 Image Resizing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - March 23 2004 :  10:56:05  Show Profile  Reply with Quote
Does any one have the code for automatic resizing the images.I need all my images to be of one fixed size without loosing the resolution.I know that this can be done thru Java script
Any Help is appreciated.

Senior Member

United Kingdom
1898 Posts

Posted - March 23 2004 :  13:24:22  Show Profile  Visit devshb's Homepage  Reply with Quote
I don't know about javascript, but I did the same thing once for my site to make sure that all thumbnails were a certain size. Here's some asp code you might find useful:

Sub FuShowProductPicture(arg_type,arg_filename,arg_suffix,arg_orig_width,arg_orig_height,arg_show_desc_flag,arg_desc,arg_size_type,arg_startcol,arg_endcol,arg_valign,arg_halign)
' Size Types: FULL
' Types: ICON
Dim new_width
Dim new_height
Dim max_dimension
Dim start_dimension
Dim pct_size_change
Dim img_id
if arg_size_type="FULL" then
if arg_size_type="THUMBS" then
end if
if arg_size_type="SMALLTHUMBS" then
end if
if arg_size_type="VERYSMALLTHUMBS" then
end if
if arg_orig_width>=arg_orig_height then
end if
end if

if (arg_startcol="Y") then
Response.Write vbcrlf&"<TD"
Response.Write " ALIGN="&arg_halign
Response.Write " VALIGN="&arg_valign
Response.Write ">"
end if
if arg_show_desc_flag="Y" then
Response.Write "<br>"
Response.Write arg_desc
Response.Write "<br>"
end if
if arg_type="ICON" then
Response.Write "<IMG SRC='../pics/products/tn/"
end if
if arg_type="IMAGE" then
Response.Write "<IMG SRC='../pics/products/"
end if
Response.Write arg_filename & "."
Response.Write arg_suffix & "'"
Response.Write " WIDTH="&new_width
Response.Write " HEIGHT="&new_height
Response.Write " BORDER=1"
Response.Write " NAME="&img_id
Response.Write ">"
if (arg_endcol="Y") then
Response.Write vbcrlf&"</TD>"
end if
End Sub

The call would be something like:

FuShowProductPicture "ICON","prod1234","jpg",400,400,"N","","THUMBS","N","N","MIDDLE","CENTER"

What this does is enlarge or shrink any image to a fixed size so that the overall shown image is always a uniform size, but without making the image skewed (ie it stays in proportion). If the height is too big then it'll make it shorter, and if the width is too long then it'll make it narrower, so if you used this function when printing an image, your final image will always end up within a specific dimension. This stretching/shrinking logic could also be applied to a javascript function; the key part to it is calculating the percentage change.
The "400,400" arguments in the example function call relate to the actual physical size of the image file; I store these in my database along with the filename, but I guess you could get this dynamically somehow. It should work for any image (tall+thin, short+fat etc), with your shown image being the same dimension regardless of the original width/height of the image.

If you want an example of where this is used, have a look at:


(the [details] popup page for each product uses the same logic, and the resizing is more obvious there)

Simon Barnaby
Freelance Developer
Java-E UK
[email protected]

Edited by - devshb on March 24 2004 04:31:43
Go to Top of Page

VP-ASP Super User

249 Posts

Posted - March 24 2004 :  07:37:27  Show Profile  Reply with Quote
You could also possibly do what I do, and that is to specify either the height OR width in your IMG SRC tag. By specifying only one dimension, each image will retain it's own height-to-width proportions, but all will be a fairly uniform size.


Go to Top of Page

Starting Member

30 Posts

Posted - March 29 2004 :  10:55:58  Show Profile  Reply with Quote
I do it the simple way. I have 2 image folders. One thumbnails, one full size. I take the fullsize pics, and re-size them to whatever size I want using hte program picSizer image resizer (by Axiom I thnk)

Go to Top of Page

VP-ASP New User

199 Posts

Posted - March 29 2004 :  14:14:59  Show Profile  Visit ProductivePC's Homepage  Reply with Quote

I like to keep full control over my images sizes and I like to keep full control over load time. Yes, it is a LOT of work however here are the pros and cons of doing this both ways

Auto image resizing
Less images to deal with
Easy Implementation

You are stuck with whatever the biggest image size is
an AOL proxy server can handle a 3kb a second to transfer rate to a user. (This is what the user sees low end)
If that image is 90kb then now what? You thumbnail will still be 90kb no matter what size you resize it to. So you expect that phone line user to wait 30 seconds for that 1 thumbnail image to download.
Absolutely unacceptable.

Less control over what you want to do. You cannot add a border to the thumbnail picture because it will change all of it. You cannot add effects onto the image because it will change the bigger one as well or visa versa.

Handling each image individually
Full control over all images
Full optimization control over all images
Full load time control over all images
(Those 3 things say it all)

If you have a lot of images, you are in image hell trying to work with them all... whew... many hours were spent optimzing all of the images and thumbnails.

Anyway, that is my two cents. If anyone out there is thinking of auto-resizing they should take into consideration the above tips.

Hope it helps.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000