Bug 444898 - JPEG writer uses poor quality default options for compression. r=tor+dolske, sr=pavlov
authorrsx11m <rsx11m.pub@gmail.com>
Tue, 10 Mar 2009 13:14:52 +0100
changeset 23729 67f5935b0f89530986aee81baaae8606e941636f
parent 23728 7e48540a4b9921c6bec6bbd92c65ba1fc251ab5a
child 23730 4d2253d3fcf0e5bd4f7b23091e24625b67c7ad78
push id880
push userdgottwald@mozilla.com
push dateTue, 10 Mar 2009 12:16:05 +0000
reviewerstor, pavlov
bugs444898
milestone1.9.1b4pre
Bug 444898 - JPEG writer uses poor quality default options for compression. r=tor+dolske, sr=pavlov
modules/libpr0n/encoders/jpeg/nsJPEGEncoder.cpp
modules/libpr0n/public/imgIEncoder.idl
modules/libpr0n/test/unit/image1png16x16.jpg
modules/libpr0n/test/unit/image1png64x64.jpg
modules/libpr0n/test/unit/test_imgtools.js
--- a/modules/libpr0n/encoders/jpeg/nsJPEGEncoder.cpp
+++ b/modules/libpr0n/encoders/jpeg/nsJPEGEncoder.cpp
@@ -101,17 +101,17 @@ NS_IMETHODIMP nsJPEGEncoder::InitFromDat
     return NS_ERROR_INVALID_ARG;
   }
 
   // can't initialize more than once
   if (mImageBuffer != nsnull)
     return NS_ERROR_ALREADY_INITIALIZED;
 
   // options: we only have one option so this is easy
-  int quality = 50;
+  int quality = 92;
   if (aOutputOptions.Length() > 0) {
     // have options string
     const nsString qualityPrefix(NS_LITERAL_STRING("quality="));
     if (aOutputOptions.Length() > qualityPrefix.Length()  &&
         StringBeginsWith(aOutputOptions, qualityPrefix)) {
       // have quality string
       nsCString value = NS_ConvertUTF16toUTF8(Substring(aOutputOptions,
                                                         qualityPrefix.Length()));
--- a/modules/libpr0n/public/imgIEncoder.idl
+++ b/modules/libpr0n/public/imgIEncoder.idl
@@ -83,17 +83,17 @@ interface imgIEncoder : nsIInputStream
   // xoffset=#  --  default: "0"
   // yoffset=#  --  default: "0"
   //     Where to draw the frame, relative to the canvas.
   //
   //
   // JPEG:
   // -----
   //
-  // quality=#  --  default: "50"
+  // quality=#  --  default: "92"
   //    Quality of compression, 0-100 (worst-best). 
   //    Quality >= 90 prevents down-sampling of the color channels.
 
 
   // Possible values for input format (note that not all image formats
   // support saving alpha channels):
 
     // Input is RGB each pixel is represented by three bytes:
index cfb749ab47a33b3b775dadf0cbf331b1a5046e6b..b0176d692e73dc9933bcfe37a86156ee23695559
GIT binary patch
literal 1081
zc%1ux<NpH&0WUXCHwH#V1_nkTWcYuZ!I^=X2?RhSGZ3(_v48*v8yhPdCkGc7CkH1d
z7Y{!V7dIa_Cnv8UFCV{vfS>>ukC3pCfH06P05XITq?4J21E^7eo0D6BWbpq0gCGZk
z0D}NCqaXv5AS1IN<NqTJ@<4a8GJ*jE6fiO|v#_$Ub8vET0~Kr)U|<5;&BVgY%F4n5
zl&uBIGq4D<3Mm>ovIz$!vMUve7&T5@$f4}C@t|nX#SbdRNkvVZTw>x9l2WQ_>Kd9_
zCZ=ZQ7M51dF0O9w9-dyoA)#U65s^{JDXD4c8JStdC8cHM6_r)ZEv;?s9i3g1CQq3<
zZTgIvvlcC0vUJ(<6)RV5+Pr1!w(UE1?mBe%$kAiRPn<k;>GGAU*RJ2VdF$b$$4{O<
zd;a3(tB;>PfBE|D`;VW$K>lK6U}l5?to{N90wWU(Fi6=!{$gY*2PqI_VO2C_6LJh>
zPb?HxGHT=yahkYr<3Ubk<Dd_sNktdA#8gZks(u7{4eT@GJk~^(&)^<I`0Ew}4>Kb$
z@|Xn~>={1)XK0+y{7<09aNC8i@!}QAUi&|)EzVBMTW~GP`p1GD5y598loCRo`D`{&
zm+q5LVA|*1YVlgW>+FAq%^$9aJa}$@&($>0>C)59xo)<?Rc5opiZ*_gi9IM$Bj)ir
zymPANF~RRDe~+8zWq&$)Dm;8sc(~_Fxup3=>Kpzuu>7;giWgkFPrf1|vSPQ>#bsA?
z9$dVr6PlN+R6aH8&Lc~O87H~e7(92GrKZPB{<2RsO=3^iGH#R7$8VMg2Cd|DHCHt)
zH8t6}bLBCi@3D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we'll reuse the container from the previous test
 istream = imgTools.encodeScaledImage(container, "image/jpeg", 16, 16);
 
 var encodedBytes = streamToArray(istream);
 // Get bytes for exected result
 var refName = "image1png16x16.jpg";
 var refFile = do_get_file(TESTDIR + refName);
 istream = getFileInputStream(refFile);
-do_check_eq(istream.available(), 733);
+do_check_eq(istream.available(), 1081);
 var referenceBytes = streamToArray(istream);
 
 // compare the encoder's output to the reference file.
 compareArrays(encodedBytes, referenceBytes);
 
 
 /* ========== 3 ========== */
 testnum++;
@@ -186,17 +186,17 @@ testdesc = "test encoding an unscaled JP
 // we'll reuse the container from the previous test
 istream = imgTools.encodeImage(container, "image/jpeg");
 encodedBytes = streamToArray(istream);
 
 // Get bytes for exected result
 refName = "image1png64x64.jpg";
 refFile = do_get_file(TESTDIR + refName);
 istream = getFileInputStream(refFile);
-do_check_eq(istream.available(), 1593);
+do_check_eq(istream.available(), 4493);
 referenceBytes = streamToArray(istream);
 
 // compare the encoder's output to the reference file.
 compareArrays(encodedBytes, referenceBytes);
 
 
 /* ========== 4 ========== */
 testnum++;