Note that there are some explanatory texts on larger screens.

plurals
  1. POPIL: Image resizing : Algorithm similar to firefox's
    text
    copied!<p>I'm getting about the same <em>bad looking</em> resizing from all the 4 algorithms of PIL</p> <pre><code>&gt;&gt;&gt; data = utils.fetch("http://wavestock.com/images/beta-icon.gif") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.save("/home/ptarjan/www/tmp/metaward/original.png") &gt;&gt;&gt; &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.resize((36,36), Image.ANTIALIAS).save("/home/ptarjan/www/tmp/metaward/antialias.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.resize((36,36), Image.BILINEAR).save("/home/ptarjan/www/tmp/metaward/bilinear.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.resize((36,36), Image.BICUBIC).save("/home/ptarjan/www/tmp/metaward/bicubic.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.resize((36,36), Image.NEAREST).save("/home/ptarjan/www/tmp/metaward/nearest.png") &gt;&gt;&gt; &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.thumbnail((36,36), Image.ANTIALIAS); image.save("/home/ptarjan/www/tmp/metaward/antialias-thumb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.thumbnail((36,36), Image.BILINEAR); image.save("/home/ptarjan/www/tmp/metaward/bilinear-thumb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.thumbnail((36,36), Image.BICUBIC); image.save("/home/ptarjan/www/tmp/metaward/bicubic-thumb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.thumbnail((36,36), Image.NEAREST); image.save("/home/ptarjan/www/tmp/metaward/nearest-thumb.png") &gt;&gt;&gt; &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.convert("RGB").resize((36,36), Image.ANTIALIAS).save("/home/ptarjan/www/tmp/metaward/antialias-rgb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.convert("RGB").resize((36,36), Image.BILINEAR).save("/home/ptarjan/www/tmp/metaward/bilinear-rgb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.convert("RGB").resize((36,36), Image.BICUBIC).save("/home/ptarjan/www/tmp/metaward/bicubic-rgb.png") &gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); image.convert("RGB").resize((36,36), Image.NEAREST).save("/home/ptarjan/www/tmp/metaward/nearest-rgb.png") </code></pre> <p>But the results look much worse that just resizing in firefox.</p> <p><a href="http://paulisageek.com/tmp/metaward/images.html" rel="nofollow noreferrer">http://paulisageek.com/tmp/metaward/images.html</a></p> <p>How can I get a similar effect to the firefox result using PIL (or another python image library)?</p> <p><strong>EDIT</strong> : Hover your mouse to see what each image is</p> <p><a href="http://paulisageek.com/tmp/metaward/original.png" rel="nofollow noreferrer" title="original">http://paulisageek.com/tmp/metaward/original.png</a> <a href="http://paulisageek.com/tmp/metaward/antialias.png" rel="nofollow noreferrer" title="antialias">http://paulisageek.com/tmp/metaward/antialias.png</a> <a href="http://paulisageek.com/tmp/metaward/bicubic.png" rel="nofollow noreferrer" title="bicubic">http://paulisageek.com/tmp/metaward/bicubic.png</a> <a href="http://paulisageek.com/tmp/metaward/bilinear.png" rel="nofollow noreferrer" title="bilinear">http://paulisageek.com/tmp/metaward/bilinear.png</a> <a href="http://paulisageek.com/tmp/metaward/nearest.png" rel="nofollow noreferrer" title="nearest">http://paulisageek.com/tmp/metaward/nearest.png</a> <a href="http://paulisageek.com/tmp/metaward/antialias-thumb.png" rel="nofollow noreferrer" title="antialias-thumb">http://paulisageek.com/tmp/metaward/antialias-thumb.png</a> <a href="http://paulisageek.com/tmp/metaward/bicubic-thumb.png" rel="nofollow noreferrer" title="bicubic-thumb">http://paulisageek.com/tmp/metaward/bicubic-thumb.png</a> <a href="http://paulisageek.com/tmp/metaward/bilinear-thumb.png" rel="nofollow noreferrer" title="bilinear-thumb">http://paulisageek.com/tmp/metaward/bilinear-thumb.png</a> <a href="http://paulisageek.com/tmp/metaward/nearest-thumb.png" rel="nofollow noreferrer" title="nearest-thumb">http://paulisageek.com/tmp/metaward/nearest-thumb.png</a> <a href="http://paulisageek.com/tmp/metaward/antialias-rgb.png" rel="nofollow noreferrer" title="antialias-rgb">http://paulisageek.com/tmp/metaward/antialias-rgb.png</a> <a href="http://paulisageek.com/tmp/metaward/bicubic-rgb.png" rel="nofollow noreferrer" title="bicubic-rgb">http://paulisageek.com/tmp/metaward/bicubic-rgb.png</a> <a href="http://paulisageek.com/tmp/metaward/bilinear-rgb.png" rel="nofollow noreferrer" title="bilinear-rgb">http://paulisageek.com/tmp/metaward/bilinear-rgb.png</a> <a href="http://paulisageek.com/tmp/metaward/nearest-rgb.png" rel="nofollow noreferrer" title="nearest-rgb">http://paulisageek.com/tmp/metaward/nearest-rgb.png</a></p> <p>It looks like the RGB and then ANTIALIS looks the best. Any other recommendations?</p> <p>For reference, this is the one that looked the best :</p> <pre><code>&gt;&gt;&gt; image = Image.open(StringIO.StringIO(data)); &gt;&gt;&gt; image.convert("RGB").resize((36,36), Image.ANTIALIAS) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload