473,322 Members | 1,526 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,322 software developers and data experts.

Resize image in asp.net

I have some code for resizing image (create thumbnail) but there is no
compression. Thumbnail image is smaller in pixels, but in kilobytes is
bigger. How can I create smaller file? I need code in VB or C#.

// Get the path of the original Image

string displayedImg = Server.MapPath("~") + "/Testing.jpg";

// Get the path of the Thumb folder

string displayedImgThumb = Server.MapPath("~") + "/Images/";

// Get the original image file name

string imgFileName = System.IO.Path.GetFileName(displayedImg);

// Load original image

System.Drawing.Image myimg = System.Drawing.Image.FromFile(displayedImg);

// Get the thumbnail 100 X 100 px

myimg = myimg.GetThumbnailImage(1280, 825, null, IntPtr.Zero);

// Save the new thumbnail image

myimg.Save(displayedImgThumb + imgFileName, myimg.RawFormat);

Mar 28 '07 #1
2 1121
"Tomo" <to*************@gmail.comwrote in message
news:eu**********@magcargo.vodatel.hr...
>I have some code for resizing image (create thumbnail) but there is no
compression. Thumbnail image is smaller in pixels, but in kilobytes is
bigger. How can I create smaller file? I need code in VB or C#.
[...]
myimg.Save(displayedImgThumb + imgFileName, myimg.RawFormat);
Instead of saving the Image in RawFormat (which has no compression),
save it using one of the compressing ImageFormats. For instance:

myimg.Save(displayedImgThumb +
Path.GetFileNameWithoutExtension(imgFileName)+".jp g", ImageFormat.Jpeg);
Mar 28 '07 #2
On Mar 28, 4:01 pm, "Tomo" <tomislavjake...@gmail.comwrote:
I have some code for resizing image (create thumbnail) but there is no
compression. Thumbnail image is smaller in pixels, but in kilobytes is
bigger. How can I create smaller file? I need code in VB or C#.
Sound like you need a "DynamicImage" control...
http://ajaxwidgets.com/AllControlsSa...amicImage.aspx

Click the "View code" button...
--
http://ajaxwidgets.com
ASP.NET 2.0 Ajax Widgets

Mar 28 '07 #3

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

Similar topics

3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
14
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why...
2
by: Carl Gilbert | last post by:
Hi I am looking for either a component or technique to allow me to do the following: * Provide a panel with a background image * Resize the image to best fit the panel to maintain aspect...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
1
by: Arjen | last post by:
Hi, I want to resize an image on my server. I tried a lot of samples... but all the time it does resize and saves the images but I can not view the image insize a webbrowser. With an...
2
by: Tim Arnold | last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). ...
2
by: Dominic Vella | last post by:
Hi, I know I seem to have the really complicated questions, but I guess that's why I'm here. This is a little verbose, only because I've been trying to crack this for a week now. Your help...
8
by: infoseekar | last post by:
Image Resize & Rotation Hi I have 2 scripts, one for Image rotation and other image resize and they both are working. Image resize scripts load the picture and resize it and Image rotation...
3
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi! This discussion may help other programmers get a better idea of how to save uploaded images through a website. Why? Well currently, I save 3 versions of every uploaded image on my own...
22
by: simon2x1 | last post by:
i have an image which width is 213 and height is 200 when i echo the image and i resize it echo "<img src='company/$present' width='70' height='68'/>"; the image was not as clear as when it was...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: 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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.