473,812 Members | 2,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1338
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****@NOSPAMd evelop.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
DevelopMento r
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.Co ntentType = "image/jpeg";

tells the browser not the expect a webpage but rather an image. And
this line:
img2.Save(ctx.R esponse.OutputS tream,System.Dr awing.Imaging.I mageFormat.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****@NOSPAMd evelop.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.Co ntentType = "image/jpeg";
tells the browser not the expect a webpage but rather an image. And
this line:
img2.Save(ctx.R esponse.OutputS tream,System.Dr awing.Imaging.I mageFormat
.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****@NOSPAMd evelop.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
11770
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 table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
38
5097
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 out what i'm doing wrong, and so far it seems i'm doing it the right way. Here's my code...any suggestions would be appreciated. <script language="javascript"> <!-- window.open("256fx/index.htm", "", "height=400, width=600"); //-->
4
16671
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 src=blah.gif width=200 height=200> But, that messes up the aspect ratio, and could size the image larger than it's original size.
0
3256
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 were to copy the image from Ms- Word and "Paste as New Image" in Photo Editor, I got the resolution 2288 x 1712. If I used the code below, I got the image size of 720 x 538 stored in PreviewBitmap variable. Why is the size of the picture...
11
2029
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 the image but in design time mode all variables concerning Server or Context ar not set ! ...so I can't use MapPath function to obtain the physical parth of the picture ... So my second question is how to retrieve the physical root path of the...
6
1996
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 acting as a faux border for the main text block shows nasty image effects on the outside when using either Firefox or Konqueror on Suse Linux. This image is set to resize with the browser window (and hence the text) and this seems to be what...
4
3469
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 memory used seems to be larger for BMP files than JPEGs with the same pixel dimensions. For example, 5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG, but 200MB for BMP (with Task Manager). The Mem Usage is noted before and...
0
2473
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 over the screen or I drag another window on top of the fast display, I get errors (Pyassertion ....). I believe those are related to a conflict between the thread that is updating the buffer (over which I have control) and the thread that is doing the...
3
3615
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 small and I can put them on the URL and pass them in as HTTP GET. In my image generation script I just need to read the parameters and then pump out the right MIME type and the right image byte stream. It is also very easy to use:
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10417
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.