<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://eiffelroom.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>eiffelroom - How to save a Jpg file with quality option - Comments</title>
 <link>http://eiffelroom.com/article/how_to_save_a_jpg_file_with_quality_option</link>
 <description>Comments for &quot;How to save a Jpg file with quality option&quot;</description>
 <language>en</language>
<item>
 <title>How to save a Jpg file with quality option</title>
 <link>http://eiffelroom.com/article/how_to_save_a_jpg_file_with_quality_option</link>
 <description>
&lt;h2 id=&quot;toc0&quot;&gt;The result&lt;/h2&gt;
&lt;p&gt;First let&#039;s see the results of images in different quality levels. The highest quality is 100, the lowest quality is 0.&lt;/p&gt;

&lt;p&gt;Original image: &lt;a href=&quot;http://eiffelroom.com/node/268&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/images/Goleta_Flower_orignal.jpg&quot; alt=&quot;Goleta_Flower_orignal&quot; title=&quot;Goleta_Flower_orignal&quot; width=&quot;2592&quot; height=&quot;1944&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quality 100 image: (Maybe because the image is too big, 2.6mb, we can&#039;t upload it now. Sorry.) &lt;a href=&quot;http://eiffelroom.com/node/273&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/&quot; alt=&quot;Goleta_Flower_with_quality_100&quot; title=&quot;Goleta_Flower_with_quality_100&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quality 75 image: &lt;a href=&quot;http://eiffelroom.com/node/272&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/images/Goleta_Flower_with_quality_75.jpg&quot; alt=&quot;Goleta_Flower_with_quality_75&quot; title=&quot;Goleta_Flower_with_quality_75&quot; width=&quot;2592&quot; height=&quot;1944&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quality 50 image: &lt;a href=&quot;http://eiffelroom.com/node/271&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/images/Goleta_Flower_with_quality_50.jpg&quot; alt=&quot;Goleta_Flower_with_quality_50&quot; title=&quot;Goleta_Flower_with_quality_50&quot; width=&quot;2592&quot; height=&quot;1944&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quality 25 image: &lt;a href=&quot;http://eiffelroom.com/node/270&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/images/Goleta_Flower_with_quality_25.jpg&quot; alt=&quot;Goleta_Flower_with_quality_25&quot; title=&quot;Goleta_Flower_with_quality_25&quot; width=&quot;2592&quot; height=&quot;1944&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quality 0 image: &lt;a href=&quot;http://eiffelroom.com/node/269&quot;&gt;&lt;img src=&quot;http://eiffelroom.com/files/images/Goleta_Flower_with_quality_0.jpg&quot; alt=&quot;Goleta_Flower_with_quality_0&quot; title=&quot;Goleta_Flower_with_quality_0&quot; width=&quot;2592&quot; height=&quot;1944&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you compare the images above carefully, you will find noise is lesser when the quality is higher. We can also find the image size is larger when the quality is higher.&lt;/p&gt;

&lt;p&gt;In the example above:&lt;/p&gt;

&lt;p&gt;original image&#039;s size is: 1810kb&lt;/p&gt;

&lt;p&gt;quality 100 image&#039;s size is: 2619kb&lt;/p&gt;

&lt;p&gt;quality 75 image&#039;s size is: 329kb&lt;/p&gt;

&lt;p&gt;quality 50 image&#039;s size is: 186kb&lt;/p&gt;

&lt;p&gt;quality 25 image&#039;s size is: 127kb&lt;/p&gt;

&lt;p&gt;quality 0 image&#039;s size is: 82kb&lt;/p&gt;


&lt;h2 id=&quot;toc1&quot;&gt;How to use it&lt;/h2&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;save_jpg_with_quality &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;a_quality: NATURAL_64&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Test of usage of saving image with quality parameter&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;require&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; valid: &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &amp;lt;= a_quality &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;and&lt;/span&gt; a_quality &amp;lt;= &lt;span style=&quot;color: #FF0000;&quot;&gt;100&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;local&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_source: WEL_GDIP_BITMAP&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_paras: WEL_GDIP_IMAGE_ENCODER_PARAMETERS&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_para: WEL_GDIP_IMAGE_ENCODER_PARAMETER&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_format: WEL_GDIP_IMAGE_ENCODER&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_source.&lt;span style=&quot;color: #000060;&quot;&gt;make_with_size&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_source.&lt;span style=&quot;color: #000060;&quot;&gt;load_image_from_file&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0080A0;&quot;&gt;&amp;quot;Goleta_Flower_orignal.jpg&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Start create parameters used by image saving feature&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_paras.&lt;span style=&quot;color: #000060;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- We set quality parameter here.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_para.&lt;span style=&quot;color: #000060;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;WEL_GDIP_IMAGE_ENCODER&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;make_empty&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;quality&lt;/span&gt;, a_quality&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_paras.&lt;span style=&quot;color: #000060;&quot;&gt;parameters&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;extend&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;l_para&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_format.&lt;span style=&quot;color: #000060;&quot;&gt;make_empty&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_source.&lt;span style=&quot;color: #000060;&quot;&gt;save_image_to_file_with_encoder_and_parameters&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0080A0;&quot;&gt;&amp;quot;Goleta_Flower_with_quality_&amp;quot;&lt;/span&gt; + a_quality.&lt;span style=&quot;color: #000060;&quot;&gt;out&lt;/span&gt; + &lt;span style=&quot;color: #0080A0;&quot;&gt;&amp;quot;.jpg&amp;quot;&lt;/span&gt;, l_format.&lt;span style=&quot;color: #000060;&quot;&gt;jpg&lt;/span&gt;, l_paras&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;The key is feature {WEL_GDIP_IMAGE}.save_image_to_file_with_encoder_and_parameters. This feature will use {WEL_GDIP_IMAGE_ENCODER_PARAMETERS} as last parameter. When saving a image we can not only set quality parameter, but also compression, color_depth, scan_method, version, render_method, transformation, luminance_table, chrominance_table and save_flag parameters. For the parameter type enumeration, please see {WEL_GDIP_IMAGE_ENCODER}.&lt;/p&gt;

&lt;p&gt;PS:&lt;/p&gt;

&lt;p&gt;Quality parameter has effects on Jpeg format images. For Png format images, the quality parameter will not work.&lt;/p&gt;

&lt;p&gt;Saving image with parameters feature is added in revision#72923.&lt;/p&gt;

</description>
 <comments>http://eiffelroom.com/article/how_to_save_a_jpg_file_with_quality_option#comments</comments>
 <category domain="http://eiffelroom.com/taxonomy/term/3">Tutorial</category>
 <category domain="http://eiffelroom.com/taxonomy/term/8">Intermediate</category>
 <category domain="http://eiffelroom.com/tag/gdi">gdi+</category>
 <category domain="http://eiffelroom.com/tag/image">image</category>
 <category domain="http://eiffelroom.com/tag/quality">quality</category>
 <category domain="http://eiffelroom.com/tag/saving">saving</category>
 <pubDate>Tue, 01 Apr 2008 06:10:38 -0700</pubDate>
 <dc:creator>larryliuming</dc:creator>
 <guid isPermaLink="false">267 at http://eiffelroom.com</guid>
</item>
</channel>
</rss>
