473,405 Members | 2,160 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,405 software developers and data experts.

JPG image actually saved as PNG

Al
private void GetResizedImage(string imagePath, int width, int height, string destinationDirectory, string destinationFileName)
{
System.Drawing.Image image = System.Drawing.Image.FromFile( imagePath, true );

Bitmap thumbnail = new Bitmap( width, height, image.PixelFormat );

Graphics graphics = Graphics.FromImage( thumbnail );
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQu ality;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;

Rectangle rectangle = new Rectangle(0, 0, width, height);
graphics.DrawImage( image, rectangle );

image.Dispose();
thumbnail.Save( destinationDirectory + "\\" + destinationFileName + "." + System.Drawing.Imaging.ImageFormat.Jpeg);
thumbnail.Dispose();
}
Nov 19 '05 #1
2 2453
Try

thumbnail.Save( destinationDirectory + "\\" + destinationFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

"Al" <none@gmail_NOSPAM_.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
private void GetResizedImage(string imagePath, int width, int height, string destinationDirectory, string destinationFileName)
{
System.Drawing.Image image = System.Drawing.Image.FromFile( imagePath, true );

Bitmap thumbnail = new Bitmap( width, height, image.PixelFormat );

Graphics graphics = Graphics.FromImage( thumbnail );
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQu ality;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;

Rectangle rectangle = new Rectangle(0, 0, width, height);
graphics.DrawImage( image, rectangle );

image.Dispose();
thumbnail.Save( destinationDirectory + "\\" + destinationFileName + "." + System.Drawing.Imaging.ImageFormat.Jpeg);
thumbnail.Dispose();
}
Nov 19 '05 #2
Al
That worked beautifully! Thank you.
"Chris Lovett" <so*****@nospam.please> wrote in message news:gL*****************************************@c omcast.com...
Try

thumbnail.Save( destinationDirectory + "\\" + destinationFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

"Al" <none@gmail_NOSPAM_.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
private void GetResizedImage(string imagePath, int width, int height, string destinationDirectory, string destinationFileName)
{
System.Drawing.Image image = System.Drawing.Image.FromFile( imagePath, true );

Bitmap thumbnail = new Bitmap( width, height, image.PixelFormat );

Graphics graphics = Graphics.FromImage( thumbnail );
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQu ality;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic;

Rectangle rectangle = new Rectangle(0, 0, width, height);
graphics.DrawImage( image, rectangle );

image.Dispose();
thumbnail.Save( destinationDirectory + "\\" + destinationFileName + "." + System.Drawing.Imaging.ImageFormat.Jpeg);
thumbnail.Dispose();
}
Nov 19 '05 #3

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

Similar topics

6
by: Marek Mänd | last post by:
Can the <button><img></button> mutated via CSS so, that the inner image of <BUTTON> would entirely visually become the button itsself - I mean without the outer elements borders and so... ...
14
by: George Hester | last post by:
http://hesterloli.dnsalias.com/test/javascript_image.htm The image is the 100x100 px block. If we right-click in it and try to save the image we cannot. Is it possible to say set a mime-type so...
6
by: Tim Marshall | last post by:
Is this possible does anyone know? I mean other than using imaging software. The scenario is this. I have a form with a large image control over which is imposed a grid of squares (label...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
9
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New...
1
by: Andrea Gavana | last post by:
Hello NG, sorry if the message is not strictly Python-related, but it is fantastically impossible to send post to Image-SIG. I am using PIL to load and display some pictures (via wxPython) in a...
1
by: jitu78 | last post by:
GIF Images Use GIF files for images that have a small number of colors. GIF files are always reduced to no more than 256 unique colors. The compression algorithm for GIF files is less complex than...
0
by: Saaima | last post by:
Hi All when I store a picture of size 800*600 pixels in database (SqlServer) field Photo (Image) and load it into crystal report through query by dragging and dropping the field on report it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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.