By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,149 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,149 IT Pros & Developers. It's quick & easy.

Resize Images

P: n/a
BlankHi

How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg.

Thanks

Slasher
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"SlasherStanley" <as****@sshfshags.comsdg> wrote:
How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg.


You could download Fast Stone PhotoResizer from:
http://www.faststoneserver.com/download.htm

It can resize a whole folder of images and also convert them to
another format in one step.
Nov 16 '05 #2

P: n/a
Blank
One way of doing this is to load your picture into an Image or Bitmap object. Then create a new Image or Bitmap object of the size that you want and get a Graphics object for it. Finally use Graphics.DrawImage to draw the complete old picture to the new smaller picture. All that is left is for you to save your smaller picture to file.

I think microsoft.public.dotnet.framework.drawing is a better place to post image type questions.
Robby
VB.Net

"SlasherStanley" <as****@sshfshags.comsdg> wrote in message news:P7***************@newsfe2-gui.ntli.net...
Hi

How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg.

Thanks

Slasher
Nov 16 '05 #3

P: n/a
If you want to use .NET to resize an image, you will need to use
Image.FromFile to get an Image object from the JPG file. Then use the
Image.GetThumbnailImage() method resize the image to the size you want.
You can then use Image.Save to write the image out to a file. I don't
know whether Image remembers what format it was on input (probably
not), so you may have to use myImage.Save(outputFileName,
ImageFormat.Jpeg) in order to get JPEG output.

Nov 16 '05 #4

P: n/a
BlankThanks for everybody's input.

This is how I have done it. The only thing I have not done, is to reduce the colour depth of the thumbnail.Because of this the physical size of the thumbnail is quite large. Any ideas????
private void btnResize_Click(object sender, System.EventArgs e)

{

String[] files = Directory.GetFiles("c:\\images");

foreach (string imagefile in files)

{

FileInfo FileProps =new FileInfo(imagefile);

string filename = FileProps.Name;

string fileextension = FileProps.Extension;
string [] Split = filename.Split(new Char [] {'.'}); //removes all character after and including (.)

filename = Split[0].ToString();

if (fileextension.ToLower() == ".jpg")

{

Image OriginalImage;

OriginalImage= System.Drawing.Image.FromFile(imagefile);
Image thumbnailImage;

thumbnailImage = OriginalImage.GetThumbnailImage(150, 113, new System.Drawing.Image.GetThumbnailImageAbort(Thumbn ailCallback), IntPtr.Zero);

thumbnailImage.Save("c:\\images\\" + filename + "t.jpg");

}

}

}
public bool ThumbnailCallback()

{

return true;

}

"SlasherStanley" <as****@sshfshags.comsdg> wrote in message news:P7***************@newsfe2-gui.ntli.net...
Hi

How do you resize a jpg file. I want to open a file (c:\abc.jpg 800 x 600) and resize it as 120 x 100, I then want to save it as c:\abc_t.jpg.

Thanks

Slasher
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.