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

Optimizing file size of an image?

Hi,

Got an interesting problem here: I'm using C# to resize an image
(jpeg) from over 2000x1700 (in pixels) to 550x412. When I save the new
image, its file size ends up being in the neighborhood of 550K. When I
use a graphics editor app, it produces a similar quality 550x412 jpeg
that's only 40K in size. What can I do in C# to cut down on resulting
image's file size? Thanks!

Nov 17 '05 #1
5 2485
<sl*******@yahoo.com> wrote:
Got an interesting problem here: I'm using C# to resize an image
(jpeg) from over 2000x1700 (in pixels) to 550x412. When I save the new
image, its file size ends up being in the neighborhood of 550K. When I
use a graphics editor app, it produces a similar quality 550x412 jpeg
that's only 40K in size. What can I do in C# to cut down on resulting
image's file size? Thanks!


I've never tried it, but I suspect that using the version of Image.Save
that takes and ImageCodecInfo and EncoderParameters is the way - just
set an appropriate parameter to specify the quality and turn it down a
bit.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Jon wrote:

I've never tried it, but I suspect that using the version of Image.Save
that takes and ImageCodecInfo and EncoderParameters is the way - just
set an appropriate parameter to specify the quality and turn it down a
bit.


Thanks Jon, I'll give it a try. I just turned resolution down a bit
(to 72x72 dpi, equal to what the editor app is producing), and it made
no difference whatsoever on image quality and file size. Makes me
wonder if the resolution API is working at all, besides setting the
attribute in file header.

Nov 17 '05 #3
<sl*******@yahoo.com> wrote:
Thanks Jon, I'll give it a try. I just turned resolution down a bit
(to 72x72 dpi, equal to what the editor app is producing), and it made
no difference whatsoever on image quality and file size. Makes me
wonder if the resolution API is working at all, besides setting the
attribute in file header.


The resolution is likely to make no odds at all - I think it's just
informational, so that programs which need to print the image know how
to scale it appropriately.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
Slavinger,
I have been trying to do this for a couple of weeks and could not figure out
how to save the resized image. Would you provide info on how you are
resizing and saving the new image in c#?

THanks,
Evan

"sl*******@yahoo.com" wrote:
Hi,

Got an interesting problem here: I'm using C# to resize an image
(jpeg) from over 2000x1700 (in pixels) to 550x412. When I save the new
image, its file size ends up being in the neighborhood of 550K. When I
use a graphics editor app, it produces a similar quality 550x412 jpeg
that's only 40K in size. What can I do in C# to cut down on resulting
image's file size? Thanks!

Nov 17 '05 #5
Slavinger,
I have been trying to do this for a couple of weeks and could not figure out
how to save the resized image. Would you provide info on how you are
resizing and saving the new image in c#?

THanks,
Evan

"sl*******@yahoo.com" wrote:
Hi,

Got an interesting problem here: I'm using C# to resize an image
(jpeg) from over 2000x1700 (in pixels) to 550x412. When I save the new
image, its file size ends up being in the neighborhood of 550K. When I
use a graphics editor app, it produces a similar quality 550x412 jpeg
that's only 40K in size. What can I do in C# to cut down on resulting
image's file size? Thanks!

Nov 17 '05 #6

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

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
4
by: John Malek | last post by:
Hi, I ran a profiler against this complex app that I'm trying to opimize. This is an application I'm doing to test image processing. Even though it does a lot of computation, two simple lines...
4
by: Flashman | last post by:
A little confusing with setting up optimizing options with 2003 .NET. Under the Optimization Tab. if you set to /O1 or /O2 is the program ignoring the settings for Inline Function expansion,...
3
by: Nick Gilbert | last post by:
Hi, I have to send an array of prices for a list of products over XML. Currently my XML data looks like this: <ArrayOfProd> <Prod Code="productcode001"> <Prices> <P F="2005-01-01"...
24
by: Richard G. Riley | last post by:
Without resorting to asm chunks I'm working on a few small routines which manipulate bitmasks. I'm looking for any guidance on writing C in a manner which tilts the compilers hand in, if possible,...
4
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
3
by: foekall | last post by:
Dear all, I would like to ask how to optimize png image with C#. One of my project I am reading image from IP Camera with bmp format. I want to change bmp to png and want to optimize png file...
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...
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
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
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...

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.