C# - Resizing Images On The Fly, Or Storing Different Sizes On Disk?
Aug 12, 2010
I'm building a Web application that will eventually contain a lot of images. These images will need to be displayed in different formats across the site. What would be the pros/cons of the two solutions:
Storing various versions of the picture when they are uploaded (e.g. thumb, small, medium, large, verylarge)
Resizing the image through the URL - e.g. /Content/Image/1?height=300
Edit:I had a really hard time accepting one answer over the other, so for anyone reading this q/a, take your time to read both answers because the accepted answer was selected by the flip of a coin :) They're both equally good.
I need to take an uploaded image, resize it, and save it to the database. Simple enough, except I don't have access to save any temp files to the server. I'm taking the image, resizing it as a Bitmap, and need to save it to a database field as the original image type (JPG for example). How can I get the FileBytes() like this, so I can save it to the database?Before I was using ImageUpload.FileBytes() but now that I'm resizing I'm dealing with Images and Bitmaps instead of FileUploads and can't seem find anything that will give me the bytes.
I'm developing a service in which users can upload images and save them in a library. I want to preserve the original file (so people can upload high resolution images), but also make a copy of the image to use as a thumbnail.
The problem I have is that the thumbnail "weights" much more than the original file, proportionally. When I check the basic properties of each file (in XnView), I can see that the original files are for instance saved with 32 bits per Plane, whereas the source file will have, for instance, only 24 bits per plane.
What would be the correct way to make a copy of the original file while still using compression? This is an excerpt of the code:
private void ResizeImage(string originalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider, string directory) { System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(originalFile); // Prevent using images internal thumbnail
Let's say I am creating a image hosting website. My potential users will be somewhere around 1 Million, and every user potential has 10,000 images, and I need to serve over 1000 images per second.
So, I bought a diskarray, with 10T storage, SAS 15K SCSI drives.
The problem is: What is the best way to save those files on disk? How to organize the folder structure to make sure NTFS can find one file from a billion files under a huge tree folder quickly? I mean, serve 1000 images per second is non trivial issue. My current website is serving over 100 images per second, and I already see the performance problem: NTFS can't find the file fast enough! And of course, my folder structure is not good enough either.
i want to store images of my employees with thier profiles in sql server database.i have following reservations.whether i should compress images or not if yes please provide me sample code or article how should i retrieve images efficiently, i an afraid of asp.net application performance issue. i think with ten thousand employee records it will halt or slow down
I am designing an prototyping an app the needs to store images, similar to facebook. This will be a public facing site and I am not sure how many users I will end up with but what I am looking for is a way to efficiently retrieve them.
So far I am thinking of storing them in SQL Server varbinary columns. I have the upload code and the storage code for that. My concern is retrieving them. I can retireve and build the image tag on the fly but I am worried about having to hit the database for each one.
I have been thinking about getting all images for a user and caching them in the asp.net cache for 10 to 30 seconds. I have never had to do something like this so I would be interested in hearing a few different approaches. Obviously the images can vary in size and I was thinking about defining a size limit, but I haven't gotten that far yet.
i am a beginer and i want to know how to store images in the database tables like pictures of the pizzas and when the user selects one of the pizza from the dropdownlist he sees the image of the selected pizza.
I'm working on an application which will store around 50.000 images within it's first year and another 75.000 in it's second. Images can come from Galleries, news images, article images and profile images. So I want to give each image a GUID and store the GUID in the database.As for the directory structure i was thinking of something like this:
So I'm using the first 4 characters of the GUID as my directory structure to spread images a bit more evenly between directories. Now I have some questions about this approach:Is it considered good practice to store all different kinds of images together rather then use ~/Images/Upload/Profiles, ~/Images/Upload/Articles etc.I'm also storing thumbnails and they have a different GUID obviously so the thumbs will not be in the same folder as the original and somehow that doesnt give me a good feeling but I guess it should not matter but.Same goes for Galleries, I'm used to store galleries in folders like ~/Images/Upload/Galleries/12 , and now all the images from a gallery will be scattered around in different subfolders, is this a big performance hit?Do you guys have any other ideas for directory structures?
As you can probably see I'm a bit afraid to use this approach but since there will be lots of images maybe even more then the numbers i gave i have to let the control go I think :)
I suppose this question has been asked to death all over the web, but I can seem to find a clear cut answer. What I am trying to achieve is as follows: I have a web application that lists various products, their descriptions, names etc and also an image of that specific product. The user will type in a product code or name of the product and a page will pop up with al the previous mentioned info and image or images of that specific product. The problem I am having is: I read somewhere that storing images in a database is 'bad idea' since it effects performance, then I read somewhere else to keep it in the images / or app_data folder. But what would be the best approach and how would I call it from the database (if that's the best way)? And if App_Data / images are the way to go how many images can I put in there (??) already the product catalog has several hundred images of various products. So how would one go about sorting everthing in those folders without having a few hundred images rolling down in my solutions explorer.
i m developing website using asp.net with microsoft access 2003 i have product details along with the images now i want to add this images into database but how i add this pictures what code is use if there are 100 products with 100 images i want to show 10 records per page i need also code of that
i m developing website using asp.net with microsoft access 2003 i have product details along with the images now i want to add this images into database but how i add this pictures what code is use if there are 100 products with 100 images i want to show 10 records per page i need also code of that
I am trying to build a small e-commerce website that will allow user to upload and store the image of their product in the database and also the user could upload the image of the product and compare it with all the similar product images that are already stored in the database. I am using MS ASP.Net using VB.Net as the front end.
if MS SQL server is the best option to carry out such task or should I consider some other database to do this in terms of complexity involved as well as the integration with MS .Net framework.
I'm working in ASP.NET 4.0, and I've got a large web form which represents a single business entity. A user can upload multiple images associated with the entity. The entity is created and assigned a GUID upon submitting the form. The files will be stored to a file system.
The problem is that we have to name the files after the GUID that is assigned to the entity after it is inserted to the database. So before the submit button is clicked, we will have several image files floating around in limbo.
There are obvious answers to this question -- you save the images to the file system and then when the business entity is created, you rename those files. However, I believe that there must be very strong patterns and several key details that would make for a very robust system. What's best practice for this scenario?
Friends have quick question for you.i want to know storing videos and images into database(binary data) or local hard drive is efficent. What way general websites stores them in their websites.
We are sending html-based emails out to customers. This is a stripped-down version of it:
Code: <table border="1" cellspacing="0" cellpadding="4"> <!-- Get the items here --> <tr bgcolor="ddddee"> <td align="left"><strong>1</strong></td>
[Code] ....
I have this code in an html file and I can view it in IE. There are eight columns, and currently one row that just has a value of One in column 1, Two in column 2, etc.
So a customer is currently receiving an email with these eight columns. He wants a ninth column called "Special Instructions". It can be free-form text and therefore rather lengthy. The customer wants to make all the text smaller to accomodate the new field. How would this be accomplished? How does it know what font to use now?
I am planning to make a membership-oriented website where users are allowed to upload files to their accounts, which have a limited amount of space.I can surely see a code-oriented solution (with a database holding the size of each file), but I was wondering whether it's possible to restrict folder sizes with Windows or ASP.Net (web.config?). I don't really think it's possible through the web.config, but I'd still like to ask the community.Does anyone know what's the best way to implement the above?
I am trying to add paging to my datagrid. This datagrid stores hierarchical data. So the top row has several children rows that need to go beneath it. When a new top row type is going to be added I want to make a new page. This way all related rows will be displayed on the same page. So, I think the tricky part might be making pages with varying sizes. I am not sure how to go about attacking this issue. All of the custom paging examples I have seen still have x amount of rows per page. Like I said my pages have to all be various sizes.
I have questions relating to specifying font-sizes in web page.Is it ok to specify it as style='font-size:12px' or style = 'font-size:14pt' or there is a better way to do this? I want to be sure that I get a uniform cross-browser solution to font-sizes.
I need to obtain a persons measurements for wearing clothes, shoes etc such as below.
Neck / Shirt Collar size Trouser length Jacket Shoe size The problem is each size is different for UK, Europe and US versions
So far on a form I have a dropdown list for each measurement item whichs show the selections like
ShoeSize DropDownList 38 eu / 5 uk / 6 us 40 eu / 6uk / 8 us etc
I then show all the results from each DDL in a gridview which has a column for each item.
Instead of displaying all 3, which takes up space in the gridview, I want to just display one measurement
they have selected such as "40" for shoe size
So do this I guess I want to allow the user to select which country is approaprite before they start the form and then the dropdown lists(Trouser DDL, ShoeDDL, JacketDDL, CollarDDL etc) display the corresponding sizes relevant to that country.
I have in my sql database a table for each measurement item.
I have a File Uploader in my ASP.NET application Using C#, we can upload any type like images, documents, pdf etc.
I m storing it in the Filesystem and having only the Name of the File in DB.My doubt is can we store the entire file, images in DB. State me Which is good practice and why we need to use it.
Using Visual Web Developer 10, I've been re-designing my site. When I attempt to size a table cell down, it smashes all my text in the shrinking cell long before any sides are near the edges. Also, it refuses to size down further, it simply stops. Then, if I take the css formatting out of the smashed text, it fixes it, but increases the size of the table cell! lol.
What good alternative products are there to make my asp.net site or to stop this irritating problem.