472,958 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Shrink .jpg to a new file

I'd like to automate the process of shrinking .jpg files using C#. I'd like
to point at 1000 files, shrink them to 30%, and then resave the new files.
I've seen the Graphics.DrawImage method, but this appears to be used for
display only?

What classes/method would be most useful?

Thanks in advance.

Mark
Jan 4 '06 #1
5 1782
Mark <ma**@nojunkmail.com> wrote:
I'd like to automate the process of shrinking .jpg files using C#. I'd like
to point at 1000 files, shrink them to 30%, and then resave the new files.
I've seen the Graphics.DrawImage method, but this appears to be used for
display only?

What classes/method would be most useful?


Have you tried using Image.GetThumbnailImage? Alternatively, use
Graphics.DrawImage having created a new Graphics with
Graphics.FromImage. You'll need to create a new Bitmap to draw onto
first.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 4 '06 #2
Hi,

the Bitmap class is the more appropiated, it has a method to get a thumbnail
from the image , you could use this.

In anycase I advise you to do a search for a third party tool also , you may
get a better performance.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mark" <ma**@nojunkmail.com> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
I'd like to automate the process of shrinking .jpg files using C#. I'd
like to point at 1000 files, shrink them to 30%, and then resave the new
files. I've seen the Graphics.DrawImage method, but this appears to be
used for display only?

What classes/method would be most useful?

Thanks in advance.

Mark

Jan 4 '06 #3
Mark,

Are you talking about shrinking in terms of the size of the file, or the
size of the image, or are you looking to change the compression rate of the
JPEG? Which is it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <ma**@nojunkmail.com> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
I'd like to automate the process of shrinking .jpg files using C#. I'd
like to point at 1000 files, shrink them to 30%, and then resave the new
files. I've seen the Graphics.DrawImage method, but this appears to be
used for display only?

What classes/method would be most useful?

Thanks in advance.

Mark

Jan 4 '06 #4
Sorry for not being precise. I'm interested in shrinking the size of the
image. Thanks again.

Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ed**************@TK2MSFTNGP14.phx.gbl...
Mark,

Are you talking about shrinking in terms of the size of the file, or
the size of the image, or are you looking to change the compression rate
of the JPEG? Which is it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <ma**@nojunkmail.com> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
I'd like to automate the process of shrinking .jpg files using C#. I'd
like to point at 1000 files, shrink them to 30%, and then resave the new
files. I've seen the Graphics.DrawImage method, but this appears to be
used for display only?

What classes/method would be most useful?

Thanks in advance.

Mark


Jan 4 '06 #5
Mark,

If you are interested in shrinking the size of the image by 30%, you
could use the GetThumbnailImage method on the Image class to resize the
image.

However, you have to be careful. If your image contains thumbnail data,
then it will use that and possibly scale it up (which results in a much
larger loss of quality usually than scaling down).

If there is no data in the thumbnail image, then the Image class will
just scale the image down, and that would work.

If there is thumbnail data, you will have to create a new Bitmap at the
appropriate size, and then draw the current image onto the new one (there
are methods on the DrawImage method on the Graphics class which will handle
the scaling for you).

It should also be noted that the quality of GDI+ (which the Graphics
instance is based on), is generally crap. You might not get the quality you
are looking for, and might have to look for a third party solution.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <ma**@nojunkmail.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
Sorry for not being precise. I'm interested in shrinking the size of the
image. Thanks again.

Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:ed**************@TK2MSFTNGP14.phx.gbl...
Mark,

Are you talking about shrinking in terms of the size of the file, or
the size of the image, or are you looking to change the compression rate
of the JPEG? Which is it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <ma**@nojunkmail.com> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
I'd like to automate the process of shrinking .jpg files using C#. I'd
like to point at 1000 files, shrink them to 30%, and then resave the new
files. I've seen the Graphics.DrawImage method, but this appears to be
used for display only?

What classes/method would be most useful?

Thanks in advance.

Mark



Jan 4 '06 #6

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

Similar topics

2
by: SP | last post by:
I've production sql server 7 sp3 on windows NT. I had a 8GB data file of which 5GB were used and 3GB were unused. I wanted to take back the unused 3GB. So I did the following with EM GUI: 1. I...
1
by: R Camarda | last post by:
Help, I have a database that has a data file of 2GB and a log file of 31GB. In enterprise manager, when I choose shrink it says there is 30GB of unused space. When I shrink the database, it does...
1
by: Fibre Optic | last post by:
Hello, I try to shrink DB, in "Shrink action" I mark "Truncate free space from the end of file". After press "OK" button I see such a message: "Error 8985: Could not locate file...
5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
5
by: war_wheelan | last post by:
My trancaction log is 25GB and my database file is 39GB. I just switched to the 'Simple' recovery model from the 'Full' recovery model. When if ever can I expect the size of the transaction log to...
4
by: Tommy.Vincent | last post by:
hi all, This will be a easy question for all out here. I have a database of 28GB. having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively. and a Transaction Log file of 156 mb. When i...
0
by: Suzi Carr | last post by:
Hello, We have a basic report that prints a customer's name followed by their order detail lines (part#, qty, price, ext price, etc). We setup the detail section to print the rows tightly...
4
by: Gary Bond | last post by:
Hi All, Can anybody point me to some 'how-to' documentation, tutorials, etc as to how to write a shrink/protect wrapper for .Net exes/dlls, (like the Shrinkwrap product for instance). I have...
13
by: Matik | last post by:
Hello everybody, First: SQL Server 2000 sp3a, HP cluster server, MS 2003 server, database recovery model simple Torn page detection: When I have this option turned on, processes conected with...
6
by: Major Drake | last post by:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2 compability mode 90, recovery model simple. I have about 40 Gb database where is about 98% free space (I deleted data from tables). dbcc...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.