Hi there. I am trying to load and save a jpeg file losslessly, however I get an exception when I try to save the file. The code bellow works fine, however, it will break if I replace the EncoderParameter with the one in the commended line. Any help will be appreciated?
manoj kumar124 reputationPosted Dec 29, 2009, 10:27 PM EST
0
hi...
if you want save jpeg file save..you give parameter file only jpeg..other give the error parameter is not found...
here change code
using(Image b = Image.FromFile("somefile.jpeg"))
and
string newName = "newfile.Jpeg";
try it ....
Hope full for you...
Pencho Ilchev5 reputationPosted Jan 1, 2010, 8:22 PM EST
0
Hi Manoj, The exception I get is "Parameter is not valid". Unfortunately, changing the extension of the file from jpg to jpeg doesn't help. Any other suggestions?
Pencho Ilchev5 reputationPosted Jan 1, 2010, 9:35 PM EST
0
I found out the if I don't modify the bitmap data (i.e. comment out
g.DrawString call) the image gets saved without any problems. What I
was trying to do is to draw some text on a jpeg/exif image (a
timestamp) and to save the file while avoiding re-compression. It
seems that it is not possible to pass transformation parameters when
saving modified bitmap data. However, GDI doesn't complain if any of
the image properties (incl. any of the exif properties) are modified. Kind
of a work-around is passing Quality parameter and value 100 when saving
the file. However, the image will get re-encoded and the file size will
decrease.
Hope this will help others who bump into the issue. Best, Pencho
manoj kumar124 reputationPosted Dec 29, 2009, 10:27 PM EST
if you want save jpeg file save..you give parameter file only jpeg..other give the error parameter is not found...
here change code
using(Image b = Image.FromFile("somefile.jpeg"))
and
string newName = "newfile.Jpeg";
try it ....
Hope full for you...
Pencho Ilchev5 reputationPosted Jan 1, 2010, 8:22 PM EST
The exception I get is "Parameter is not valid". Unfortunately, changing the extension of the file from jpg to jpeg doesn't help.
Any other suggestions?
Pencho Ilchev5 reputationPosted Jan 1, 2010, 9:35 PM EST
What I was trying to do is to draw some text on a jpeg/exif image (a timestamp) and to save the file while avoiding re-compression.
It seems that it is not possible to pass transformation parameters when saving modified bitmap data. However, GDI doesn't complain if any of the image properties (incl. any of the exif properties) are modified.
Kind of a work-around is passing Quality parameter and value 100 when saving the file. However, the image will get re-encoded and the file size will decrease.
Hope this will help others who bump into the issue.
Best,
Pencho