How to do JPEG Compression Save at 10

View: New views
13 Messages — Rating Filter:   Alert me  

How to do JPEG Compression Save at 10

by prasadtv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I am using JMagick to resize JPG images. I am able to resize to any specified size. The problem is, I want to save the generated image using JPEG Compression "10". By default JMagick saves the images in JPEG Compression "12". But I want to save the generated image using JPEG Compression "10" and JPEG Compression "5" also. Please let me know any body has solution for this.

It will be great help for me, if some one helps on this...

I am using the following code to resize:

ImageInfo info = new ImageInfo();

MagickImage blobImage = new MagickImage(info, srcImageData);

blobImage.setFilter(FilterType.HermiteFilter);

MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);

processedImageData = scaled.imageToBlob(info);

scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\\shd0112l.jpg");

scaled.writeImage(info);

Thanks & regards

Prasad T.V


-----------------------------------------------------------------------------------------------------------------------------
Disclaimer
-----------------------------------------------------------------------------------------------------------------------------

"This message(including attachment if any)is confidential and may be privileged.Before opening attachments please check them
for viruses and defects.MindTree Consulting Private Limited (MindTree)will not be responsible for any viruses or defects or
any forwarded attachments emanating either from within MindTree or outside.If you have received this message by mistake please notify the sender by return  e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission."

-----------------------------------------------------------------------------------------------------------------------------
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

Re: How to do JPEG Compression Save at 10

by Jin Zhao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I guess you need implement the get/set methods for jpeg image quality in
JMagick image class.

You may add the following code, rebuild jmagick and start testing.

################ MagickImage.java ################
public native int getQuality()
        throws MagickException;
public native void setQuality(int value)
        throws MagickException;
################ MagickImage.java ################

################ magick_MagickImage.c ################
getIntMethod(Java_magick_MagickImage_getQuality,
             quality,
             "magickImageHandle",
             Image)
setIntMethod(Java_magick_MagickImage_setQuality,
             quality,
             "magickImageHandle",
             Image)
################ magick_MagickImage.c ################

In your code, you may try something like this.
############################################
        int quality = 90;
        scaled.setQuality(quality);
############################################

Please let me know how well this can work for you.

Thanks,


Jin

On Mon, 12 Sep 2005, Prasad TV wrote:

> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any specified
> size. The problem is, I want to save the generated image using JPEG
> Compression "10". By default JMagick saves the images in JPEG Compression
> "12". But I want to save the generated image using JPEG Compression "10" and
> JPEG Compression "5" also. Please let me know any body has solution for this.
>
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\\shd0112l.jpg");
>
> scaled.writeImage(info);
>
> Thanks & regards
>
> Prasad T.V
>
>
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

Re: How to do JPEG Compression Save at 10

by Eric Yeo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2005-09-12 at 14:44 +0530, Prasad TV wrote:

> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any
> specified size. The problem is, I want to save the generated image
> using JPEG Compression "10". By default JMagick saves the images in
> JPEG Compression "12". But I want to save the generated image using
> JPEG Compression "10" and JPEG Compression "5" also. Please let me
> know any body has solution for this.
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\
> \shd0112l.jpg");
>
> scaled.writeImage(info);

Before calling writeImage, use the setQuality method in ImageInfo, e.g.

info.setQuality(XX);
scaled.writeImage(info);

Please note that the quality value range from 1 to 100 (I think).
Someone please confirm.

Regards,
Eric

_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

Parent Message unknown RE: How to do JPEG Compression Save at 10

by prasadtv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Eric,

As you said I tried by setting quality for info object before write to file.
But when I open that new image in photo shop it allways shows saved as 12.
But I want to save the file as 10. I tried with different values for quality
between 1 to 100.

One more Quick Question, How do I set the DPI while saving an image?

I have an image with 800 dpi, I want to resize to 285x431 with 72 DPI using
JMagick api.

It will be more helpful, if you can provide some code...

Help me on this at an earliest, becz I am stucked on this...need urzent help
on this...

Thanks & regards
Prasad T.V


-----Original Message-----
From: Eric Yeo [mailto:ttey@...]
Sent: Wednesday, September 14, 2005 2:36 PM
To: Prasad TV
Cc: jmagick@...
Subject: Re: [Jmagick] How to do JPEG Compression Save at 10

On Mon, 2005-09-12 at 14:44 +0530, Prasad TV wrote:

> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any
> specified size. The problem is, I want to save the generated image
> using JPEG Compression "10". By default JMagick saves the images in
> JPEG Compression "12". But I want to save the generated image using
> JPEG Compression "10" and JPEG Compression "5" also. Please let me
> know any body has solution for this.
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\
> \shd0112l.jpg");
>
> scaled.writeImage(info);
Before calling writeImage, use the setQuality method in ImageInfo, e.g.

info.setQuality(XX);
scaled.writeImage(info);

Please note that the quality value range from 1 to 100 (I think).
Someone please confirm.

Regards,
Eric




-----------------------------------------------------------------------------------------------------------------------------
Disclaimer
-----------------------------------------------------------------------------------------------------------------------------

"This message(including attachment if any)is confidential and may be privileged.Before opening attachments please check them
for viruses and defects.MindTree Consulting Private Limited (MindTree)will not be responsible for any viruses or defects or
any forwarded attachments emanating either from within MindTree or outside.If you have received this message by mistake please notify the sender by return  e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission."

-----------------------------------------------------------------------------------------------------------------------------
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

Parent Message unknown RE: How to do JPEG Compression Save at 10

by prasadtv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
Hi Eric,

As you said I tried by setting quality for info object before write to file.
But when I open that new image in photo shop it allways shows saved as 12.
But I want to save the file as 10. I tried with different values for quality
between 1 to 100.

One more Quick Question, How do I set the DPI while saving an image?

I have an image with 800 dpi, I want to resize to 285x431 with 72 DPI using
JMagick api.

It will be more helpful, if you can provide some code...

Help me on this at an earliest, becz I am stucked on this...need urzent help
on this...

Thanks & regards
Prasad T.V


-----Original Message-----
From: Eric Yeo [mailto:ttey@...]
Sent: Wednesday, September 14, 2005 2:36 PM
To: Prasad TV
Cc: jmagick@...
Subject: Re: [Jmagick] How to do JPEG Compression Save at 10

On Mon, 2005-09-12 at 14:44 +0530, Prasad TV wrote:

> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any
> specified size. The problem is, I want to save the generated image
> using JPEG Compression "10". By default JMagick saves the images in
> JPEG Compression "12". But I want to save the generated image using
> JPEG Compression "10" and JPEG Compression "5" also. Please let me
> know any body has solution for this.
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\
> \shd0112l.jpg");
>
> scaled.writeImage(info);
Before calling writeImage, use the setQuality method in ImageInfo, e.g.

info.setQuality(XX);
scaled.writeImage(info);

Please note that the quality value range from 1 to 100 (I think).
Someone please confirm.

Regards,
Eric




-----------------------------------------------------------------------------------------------------------------------------
Disclaimer
-----------------------------------------------------------------------------------------------------------------------------

"This message(including attachment if any)is confidential and may be privileged.Before opening attachments please check them
for viruses and defects.MindTree Consulting Private Limited (MindTree)will not be responsible for any viruses or defects or
any forwarded attachments emanating either from within MindTree or outside.If you have received this message by mistake please notify the sender by return  e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission."

-----------------------------------------------------------------------------------------------------------------------------
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

RE: How to do JPEG Compression Save at 10

by Eric Yeo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 2005-09-14 at 15:22 +0530, Prasad TV wrote:
>  Hi Eric,
>
> As you said I tried by setting quality for info object before write to file.
> But when I open that new image in photo shop it allways shows saved as 12.
> But I want to save the file as 10. I tried with different values for quality
> between 1 to 100.

I don't believe that the quality is stored with the image. If you set
the quality value to something low in JMagick, the image will have low
quality.

> One more Quick Question, How do I set the DPI while saving an image?

Please read the comments in the code or generate the Javadoc. Use the
MagickImage#setXResolution and/or MagickImage#setYResolution methods.

Regards,
Eric

_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

RE: How to do JPEG Compression Save at 10

by Bob Friesenhahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 14 Sep 2005, Prasad TV wrote:

> Hi Eric,
>
> As you said I tried by setting quality for info object before write to file.
> But when I open that new image in photo shop it allways shows saved as 12.
> But I want to save the file as 10. I tried with different values for quality
> between 1 to 100.

There is no standard for JPEG quality values.  The IJG JPEG library
expects quality values between 1 to 100.  So any application which
depends on IJG JPEG will do the same.  However, Photoshop works
differently.

I believe that ImageMagick does include some code for estimating the
IJG JPEG quality value.  This might show up in the output of
'identify -verbose'. This would be handy for determining the
eqivalents to Photoshop quality values.

> One more Quick Question, How do I set the DPI while saving an image?
>
> I have an image with 800 dpi, I want to resize to 285x431 with 72 DPI using
> JMagick api.

DPI is controlled via the ImageInfo 'density' or Image x_resolution
and y_resolution values.  Note that Photoshop does not help here
either since while there is a standard for storing the resolution
value in JPEG, Photoshop doesn't usually use it.  Instead it stores
resolution in a private profile attached to the image.

Bob
======================================
Bob Friesenhahn
bfriesen@..., http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

RE: How to do JPEG Compression Save at 10

by Jin Zhao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> As you said I tried by setting quality for info object before write to file.
> But when I open that new image in photo shop it allways shows saved as 12.
> But I want to save the file as 10. I tried with different values for quality
> between 1 to 100.
>
I think Eric is right that jpeg compression rate is between 1-99(IJG) and
can be set via ImageInfo interface in JMagick. You may try different
quality values, compare different outputed images and will see the
difference. Another way is using convert and identify commands to compare
images with different quality values, as suggested by Bob.

Photoshop seems use totally different way for quality measurement. The
following link give some valuable information about jpeg compression.

http://www.photo.net/learn/jpeg/

Jin
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick

Re: How to do JPEG Compression Save at 10

by zaske :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI all,
To whom it may concern - I just wanted to point out that I just did quality setting and measurement.
Use the "getQuality" of MagickImage.
Use the "setQuality" of MagickInfo.

I tried using "getQuality" of MagickImage but it returned me 0 all the time, But the combination i wrote at the top is working.


Eric Yeo wrote:
On Mon, 2005-09-12 at 14:44 +0530, Prasad TV wrote:
> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any
> specified size. The problem is, I want to save the generated image
> using JPEG Compression "10". By default JMagick saves the images in
> JPEG Compression "12". But I want to save the generated image using
> JPEG Compression "10" and JPEG Compression "5" also. Please let me
> know any body has solution for this.
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\
> \shd0112l.jpg");
>
> scaled.writeImage(info);

Before calling writeImage, use the setQuality method in ImageInfo, e.g.

info.setQuality(XX);
scaled.writeImage(info);

Please note that the quality value range from 1 to 100 (I think).
Someone please confirm.

Regards,
Eric

_______________________________________________
JMagick mailing list
JMagick@yeo.id.au
http://www.yeo.id.au/mailman/listinfo/jmagick

Re: How to do JPEG Compression Save at 10

by srinivasp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi zaske:

I am trying to set the quality of a png to something lower (for smaller image size).
You are right "getQuality" of MagickImage returning a zero 0.

Just curious if anybody actually been sucessful in setting the compression/quality. Also when I use setXResolution (90) and setYResolution(90), and resize the image, the output png's x-resoultion is 0.009 and y-resolution is 0.009.  

I dont know what to infer from that.  Anybody help?


HI all,
To whom it may concern - I just wanted to point out that I just did quality setting and measurement.
Use the "getQuality" of MagickImage.
Use the "setQuality" of MagickInfo.

I tried using "getQuality" of MagickImage but it returned me 0 all the time, But the combination i wrote at the top is working.


Eric Yeo wrote:
On Mon, 2005-09-12 at 14:44 +0530, Prasad TV wrote:
> Hi All,
>
> I am using JMagick to resize JPG images. I am able to resize to any
> specified size. The problem is, I want to save the generated image
> using JPEG Compression "10". By default JMagick saves the images in
> JPEG Compression "12". But I want to save the generated image using
> JPEG Compression "10" and JPEG Compression "5" also. Please let me
> know any body has solution for this.
>
> It will be great help for me, if some one helps on this...
>
> I am using the following code to resize:
>
> ImageInfo info = new ImageInfo();
>
> MagickImage blobImage = new MagickImage(info, srcImageData);
>
> blobImage.setFilter(FilterType.HermiteFilter);
>
> MagickImage scaled = blobImage.zoomImage(imgWidth, imgHeight);
>
> processedImageData = scaled.imageToBlob(info);
>
> scaled.setFileName("F:\\imagestoprocess\\GeneratedImages\
> \shd0112l.jpg");
>
> scaled.writeImage(info);

Before calling writeImage, use the setQuality method in ImageInfo, e.g.

info.setQuality(XX);
scaled.writeImage(info);

Please note that the quality value range from 1 to 100 (I think).
Someone please confirm.

Regards,
Eric

_______________________________________________
JMagick mailing list
JMagick@yeo.id.au
http://www.yeo.id.au/mailman/listinfo/jmagick


Re: How to do JPEG Compression Save at 10

by Bob Friesenhahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 26 Jun 2008, srinivasp wrote:

> I am trying to set the quality of a png to something lower (for smaller
> image size).
> You are right "getQuality" of MagickImage returning a zero 0.

It used to be that this would return a value of 75 as a default.
PNGs don't actually have "quality" since PNG is lossless.  The quality
value is used to select various parameters when the file is written.
A higher quality value will usually take more CPU to write and is
often smaller.

> Just curious if anybody actually been sucessful in setting the
> compression/quality. Also when I use setXResolution (90) and
> setYResolution(90), and resize the image, the output png's x-resoultion is
> 0.009 and y-resolution is 0.009.
>
> I dont know what to infer from that.  Anybody help?

The PNG units are likely millimeters rather than DPI.  I would have to
check the specification to be sure.  The 'units' parameter determines
what the values you supply represent.  However, if the native units
are metric, then the software has to convert to the native units.

Bob
======================================
Bob Friesenhahn
bfriesen@..., http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick
Please ensure that JMagick@... is a recipient when replying.

Re: How to do JPEG Compression Save at 10

by srinivasp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bob,

You are totally right about the units.  I totally missed that part.  I needed to set the setUnits as Pixels per inch.

And again you are totally right about quality on PNG.  Thank you.  I am new to this and I am trying to put pieces together for the first time.

Thank you.

Bob Friesenhahn wrote:
On Thu, 26 Jun 2008, srinivasp wrote:

> I am trying to set the quality of a png to something lower (for smaller
> image size).
> You are right "getQuality" of MagickImage returning a zero 0.

It used to be that this would return a value of 75 as a default.
PNGs don't actually have "quality" since PNG is lossless.  The quality
value is used to select various parameters when the file is written.
A higher quality value will usually take more CPU to write and is
often smaller.

> Just curious if anybody actually been sucessful in setting the
> compression/quality. Also when I use setXResolution (90) and
> setYResolution(90), and resize the image, the output png's x-resoultion is
> 0.009 and y-resolution is 0.009.
>
> I dont know what to infer from that.  Anybody help?

The PNG units are likely millimeters rather than DPI.  I would have to
check the specification to be sure.  The 'units' parameter determines
what the values you supply represent.  However, if the native units
are metric, then the software has to convert to the native units.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
JMagick mailing list
JMagick@yeo.id.au
http://www.yeo.id.au/mailman/listinfo/jmagick
Please ensure that JMagick@yeo.id.au is a recipient when replying.

Re: How to do JPEG Compression Save at 10

by Jacob Nordfalk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

You are using the old JMagick mailling list.
We have switched to a new one some months ago.
The JMagick mailing list is now at jmagick-users@....

Please post there, to make sure that all participate in the same list.

To join the JMagick mailing list, please point your web brower at
    https://lists.sourceforge.net/lists/listinfo/jmagick-users


Jacob



2008/6/27 srinivasp <spulakanam@...>:

Bob,

You are totally right about the units.  I totally missed that part.  I
needed to set the setUnits as Pixels per inch.

And again you are totally right about quality on PNG.  Thank you.  I am new
to this and I am trying to put pieces together for the first time.

Thank you.


Bob Friesenhahn wrote:
>
> On Thu, 26 Jun 2008, srinivasp wrote:
>
>> I am trying to set the quality of a png to something lower (for smaller
>> image size).
>> You are right "getQuality" of MagickImage returning a zero 0.
>
> It used to be that this would return a value of 75 as a default.
> PNGs don't actually have "quality" since PNG is lossless.  The quality
> value is used to select various parameters when the file is written.
> A higher quality value will usually take more CPU to write and is
> often smaller.
>
>> Just curious if anybody actually been sucessful in setting the
>> compression/quality. Also when I use setXResolution (90) and
>> setYResolution(90), and resize the image, the output png's x-resoultion
>> is
>> 0.009 and y-resolution is 0.009.
>>
>> I dont know what to infer from that.  Anybody help?
>
> The PNG units are likely millimeters rather than DPI.  I would have to
> check the specification to be sure.  The 'units' parameter determines
> what the values you supply represent.  However, if the native units
> are metric, then the software has to convert to the native units.
>
> Bob
> ======================================
> Bob Friesenhahn
> bfriesen@..., http://www.simplesystems.org/users/bfriesen/
> GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
>
> _______________________________________________
> JMagick mailing list
> JMagick@...
> http://www.yeo.id.au/mailman/listinfo/jmagick
> Please ensure that JMagick@... is a recipient when replying.
>
>

--
View this message in context: http://www.nabble.com/How-to-do-JPEG-Compression-Save-at-10-tp838254p18142721.html
Sent from the JMagick mailing list archive at Nabble.com.

_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick
Please ensure that JMagick@... is a recipient when replying.



--
Jacob Nordfalk
http://javabog.dk
Skype: jacobnordfalk
_______________________________________________
JMagick mailing list
JMagick@...
http://www.yeo.id.au/mailman/listinfo/jmagick
Please ensure that JMagick@... is a recipient when replying.