473,394 Members | 1,956 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,394 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 2368
"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

4
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping...
1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
1
by: David | last post by:
Hello. How can I resize image in Bitmap object?
3
by: DichkoSoft | last post by:
Dear All I don't know haw i resize inage in VB.NET I want load image with size 800x600 then rezize it to 80x60 pixels and save to a file. -- DichkoSoft
2
by: Adam J Knight | last post by:
Hi all, I am trying resize an image using the following code. //resize image System.Drawing.Image ImageUpload =...
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...
6
by: Bob Bedford | last post by:
Hi all, I've a classic upload form where people may select images on their computer to send on my website. Since this is done by people not very confortable with computers, some sent pictures...
6
by: Bob Bedford | last post by:
Hi all, I've to resize uploaded images with the "imagecopyresampled" but when I've images quite large (common those days) I reach the 16mb limits of the ISP. How can I fix this ? I absolutely...
3
by: Danny Ni | last post by:
Hi, I am looking for a way to display images with different aspect ratio into frames with fixed width and height, the problem is some images will look distorted if they are forced into fixed...
3
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
how can i reesize an image so its quallity will stay the same as the original 1? thnaks in advance peleg
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.