473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Image size question

dgk
I have an app that has many subdirectories containing one or more
images (jpg, gif, bmp). When the user selects a directory, my plan is
to show the images if there are only one or two, or show thumbnails if
there are more and allow the user to click on each thumbnail to view
it full size.

Right now I'm just sticking an <IMG> tag for each image into a literal
control. It works fine but the images are huge which surprised me. I
really don't know the size of the image in order to specify height and
width in the IMG tag. I tried loading them and checking the
image.height and width but, after around 6 or 7 it runs out of memory.
Very weird. I am disposing the image after each one is loaded.

But that approach is very wasteful anyway. There can't be a need to
load each image just to get the browser to display it at the proper
size. Should I try adding image controls dynamically instead of
spitting out html? Am I missing the point entirely?

The thumbnail idea also presents the same problem. It seems wasteful
to load an image and generate the thumbnail in memory each time. I
guess I can check to see if the thumbnails exist and if not create
them. That way I only do it once or can even have a separate app do it
"offline".

Any image assistance appreciated.
Nov 19 '05 #1
4 1306
I have a sample app that does exactly that:

http://staff.develop.com/ballen/blog...8-9aff48bf2481

I'd suggest reading the comments for the blog entry and there's a link off
to more help on the image resizing bit.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an app that has many subdirectories containing one or more
images (jpg, gif, bmp). When the user selects a directory, my plan is
to show the images if there are only one or two, or show thumbnails if
there are more and allow the user to click on each thumbnail to view
it full size.

Right now I'm just sticking an <IMG> tag for each image into a literal
control. It works fine but the images are huge which surprised me. I
really don't know the size of the image in order to specify height and
width in the IMG tag. I tried loading them and checking the
image.height and width but, after around 6 or 7 it runs out of memory.
Very weird. I am disposing the image after each one is loaded.

But that approach is very wasteful anyway. There can't be a need to
load each image just to get the browser to display it at the proper
size. Should I try adding image controls dynamically instead of
spitting out html? Am I missing the point entirely?

The thumbnail idea also presents the same problem. It seems wasteful
to load an image and generate the thumbnail in memory each time. I
guess I can check to see if the thumbnails exist and if not create
them. That way I only do it once or can even have a separate app do it
"offline".

Any image assistance appreciated.


Nov 19 '05 #2
dgk
On Sun, 03 Apr 2005 08:25:09 -0700, Brock Allen
<ba****@NOSPAMdevelop.com> wrote:
I have a sample app that does exactly that:

http://staff.develop.com/ballen/blog...8-9aff48bf2481

I'd suggest reading the comments for the blog entry and there's a link off
to more help on the image resizing bit.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an app that has many subdirectories containing one or more
images (jpg, gif, bmp). When the user selects a directory, my plan is
to show the images if there are only one or two, or show thumbnails if
there are more and allow the user to click on each thumbnail to view
it full size.

Right now I'm just sticking an <IMG> tag for each image into a literal
control. It works fine but the images are huge which surprised me. I
really don't know the size of the image in order to specify height and
width in the IMG tag. I tried loading them and checking the
image.height and width but, after around 6 or 7 it runs out of memory.
Very weird. I am disposing the image after each one is loaded.

But that approach is very wasteful anyway. There can't be a need to
load each image just to get the browser to display it at the proper
size. Should I try adding image controls dynamically instead of
spitting out html? Am I missing the point entirely?

The thumbnail idea also presents the same problem. It seems wasteful
to load an image and generate the thumbnail in memory each time. I
guess I can check to see if the thumbnails exist and if not create
them. That way I only do it once or can even have a separate app do it
"offline".

Any image assistance appreciated.



Thanks. It will take me a bit to sort though this. Setting the
contextType:
ctx.Response.ContentType = "image/jpeg";

tells the browser not the expect a webpage but rather an image. And
this line:
img2.Save(ctx.Response.OutputStream,System.Drawing .Imaging.ImageFormat.Jpeg);

spits it out.

But does it appear somewhere in the current webpage or open up a new
window? And how would I attach JavaScript to trigger a request for the
full image?
Nov 19 '05 #3
Download the entire sample and run it -- the page dynamically creates <img>
to make requests for the thumbnails. It also wraps each of those <img> with
<a> so the user can click the link and get the real (non-thumbnail) image.

-Brock
DevelopMentor
http://staff.develop.com/ballen
On Sun, 03 Apr 2005 08:25:09 -0700, Brock Allen
<ba****@NOSPAMdevelop.com> wrote:
I have a sample app that does exactly that:

http://staff.develop.com/ballen/blog...d=2d8b430b-836
1-416d-9df8-9aff48bf2481

I'd suggest reading the comments for the blog entry and there's a
link off to more help on the image resizing bit.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an app that has many subdirectories containing one or more
images (jpg, gif, bmp). When the user selects a directory, my plan
is to show the images if there are only one or two, or show
thumbnails if there are more and allow the user to click on each
thumbnail to view it full size.

Right now I'm just sticking an <IMG> tag for each image into a
literal control. It works fine but the images are huge which
surprised me. I really don't know the size of the image in order to
specify height and width in the IMG tag. I tried loading them and
checking the image.height and width but, after around 6 or 7 it runs
out of memory. Very weird. I am disposing the image after each one
is loaded.

But that approach is very wasteful anyway. There can't be a need to
load each image just to get the browser to display it at the proper
size. Should I try adding image controls dynamically instead of
spitting out html? Am I missing the point entirely?

The thumbnail idea also presents the same problem. It seems wasteful
to load an image and generate the thumbnail in memory each time. I
guess I can check to see if the thumbnails exist and if not create
them. That way I only do it once or can even have a separate app do
it "offline".

Any image assistance appreciated.

Thanks. It will take me a bit to sort though this. Setting the
contextType:
ctx.Response.ContentType = "image/jpeg";
tells the browser not the expect a webpage but rather an image. And
this line:
img2.Save(ctx.Response.OutputStream,System.Drawing .Imaging.ImageFormat
.Jpeg);

spits it out.

But does it appear somewhere in the current webpage or open up a new
window? And how would I attach JavaScript to trigger a request for the
full image?


Nov 19 '05 #4
dgk
On Sun, 03 Apr 2005 11:58:47 -0700, Brock Allen
<ba****@NOSPAMdevelop.com> wrote:
Download the entire sample and run it -- the page dynamically creates <img>
to make requests for the thumbnails. It also wraps each of those <img> with
<a> so the user can click the link and get the real (non-thumbnail) image.


Thanks a lot. It does exactly what I want. However I do not understand
how it works so I'm slogging my way through it. This is my first
experience with HttpHandlers. Cute, the only ashx file is a pointer in
web.config back to the Thumb class. Hee hee. MS documentation seems a
bit, umm, sparse on HttpHandlers. Possible questions will follow.
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
38
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find...
4
by: no-spam | last post by:
Hello, I have an HTML question that I'm not sure can be solved. I want to restrict the maximum size of an inline image. For example, I can force the image to be 200x200 if I do this: <img...
0
by: P N | last post by:
Hi all, I have question about copying picture from MS-Word into the Clipboard and then copy from the Clipboard into the bitmap variable within C#. The original image size is 2288 x 1712. If I...
11
by: KarimL | last post by:
Thanks for your advices... but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height. More i just have the url (relative parth) to the...
6
by: nichughes | last post by:
Hello all, A question relating to http://www.entrust-systems.net/ Just for a change I have run into a problem that seems to be OS specific rather than browser specific - the box image that is...
4
by: LT.Ang | last post by:
I am developing an application that possibly opens very large images - bmp, jpeg, tiff. I have 2 questions: Language: C#, VS .NET 2003. 1. When the program opens a BMP image, the amount of...
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.