473,769 Members | 6,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DrawIm age 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 1814
Mark <ma**@nojunkmai l.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.DrawIm age method, but this appears to be used for
display only?

What classes/method would be most useful?


Have you tried using Image.GetThumbn ailImage? Alternatively, use
Graphics.DrawIm age having created a new Graphics with
Graphics.FromIm age. You'll need to create a new Bitmap to draw onto
first.

--
Jon Skeet - <sk***@pobox.co m>
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**@nojunkmai l.com> wrote in message
news:uQ******** ******@tk2msftn gp13.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.DrawIm age 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.co m

"Mark" <ma**@nojunkmai l.com> wrote in message
news:uQ******** ******@tk2msftn gp13.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.DrawIm age 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.c om> wrote in
message news:ed******** ******@TK2MSFTN GP14.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.co m

"Mark" <ma**@nojunkmai l.com> wrote in message
news:uQ******** ******@tk2msftn gp13.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.DrawIm age 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 GetThumbnailIma ge 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.co m

"Mark" <ma**@nojunkmai l.com> wrote in message
news:Ol******** ******@TK2MSFTN GP10.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.c om> wrote
in message news:ed******** ******@TK2MSFTN GP14.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.co m

"Mark" <ma**@nojunkmai l.com> wrote in message
news:uQ******** ******@tk2msftn gp13.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.DrawIm age 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
3054
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 tried to "truncate fre space from end of the file". Didn't truncate the file. I believe there was no empty space at the end of the file. 2. Next I chose the option to "shrink file to 5GB". And to my horror the data file instead of taking just...
1
5710
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 not shrink, (however it says it has completed). I've done a complete backup, tried shrink again, no dice. I then backed up the database (which the backup was 1.9GB), deleted the database and made a new database with 2,048MB for the data and same...
1
5040
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 "file_name.dat" in system. DBCC execution completed. If DBCC printed error messages, contact your system administrator." So, can you tell my what is wrong ? How to resolve this problem ?
5
18340
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 (%) Status MY_eems 368.49219 16.034182 0 I made a complete backup of the database and transaction log and then executed this statement: DBCC SHRINKFILE (MYeems_log, 1)
5
12299
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 reduce in size? Is there anything else that I should do to aide with the reduction? Thanks, Peter
4
6731
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 executed DBCC Shrinkdatabase(databasename),it reduced size of datafile but the LOG file had gone up to 5 Gb from 156mb.
0
2256
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 together like we want. To ensure that all customers appear on the report -- even those without orders -- we use a query to LEFT JOIN the Customer file to the Orders file. However, customers without orders have a blank detail line and we want to...
4
1765
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 got a couple of products nearly ready for sale, and have already come up with some routines to protect them, (in the style of the old TurboPower OnGuard), but really wanted to shrink and protect the exe's, so as to make reverse engineering a bit...
13
7379
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 updating and writing in database, was MUCH more slower, than if I've this option turned off.
6
8795
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 checkdb -OK. dbcc reindex all tables -OK Shrink database (with reorganize and release unused pace) -no any affets,
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10000
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8879
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.