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

Resize Images

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
4 18584
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dean | last post by:
First I've must say Im completly new in php scripting What I need to do is upload, resize pictures with path in database Here is theory of it, and plan of doing it Hope somebody can help me...
2
by: rams.kakara | last post by:
hi, My page have background image,on that image have more images and text. My problem is whenever resize browser that images are not resized and also not moved correct place .(i.e look not like...
2
by: J'son | last post by:
Guys, I have built an application for a client that allows people to list their products for sale along with a photo of the product. If the photo is too big, I currently resize it down when 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...
7
by: chad | last post by:
is it just me or does anybody else find the Image.RotateFlip method kind of slow? (I'm comparing to commercial softwares). Same for resizing. I'm using sourceImage =...
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...
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...
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). ...
1
by: Starance | last post by:
Well... I'm not sure if this can be fixed, I've tried many ways. But here goes; When you resize your browser window it seems to move my video & photo divs. I want them kept in line with the...
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.