473,406 Members | 2,867 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,406 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 1800
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.