<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eugeni&#039;s blog &#187; web</title>
	<atom:link href="http://dodonov.net/blog/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://dodonov.net/blog</link>
	<description>My view on technology, open-source, Linux and other cool things.</description>
	<lastBuildDate>Sun, 29 Jan 2012 15:11:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Improving website scalability: image sizes</title>
		<link>http://dodonov.net/blog/2009/09/24/improving-website-scalability-image-sizes/</link>
		<comments>http://dodonov.net/blog/2009/09/24/improving-website-scalability-image-sizes/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 03:56:22 +0000</pubDate>
		<dc:creator>eugeni</dc:creator>
				<category><![CDATA[devel]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[Linux-Planet]]></category>
		<category><![CDATA[mandriva]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://dodonov.net/blog/?p=571</guid>
		<description><![CDATA[One of non-trivial tricks involved in web site scalability is the optimization of all image files. One of the sites I am helping to take care of has a front page with more than 350KB in .jpeg images. And, obviously, it takes lots of time to load and, considering the number of accesses, the bandwidth <a href='http://dodonov.net/blog/2009/09/24/improving-website-scalability-image-sizes/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>One of non-trivial tricks involved in web site scalability is the optimization of all image files. One of the sites I am helping to take care of has a front page with more than <strong>350KB</strong> in .jpeg images. And, obviously, it takes lots of time to load and, considering the number of accesses, the bandwidth is huge. Usually, those images can be optimized in photo editor, or saved with higher compression or lower quality, but sometimes there is not much else you can do. Or you think so.</p>

<p>One quick trick to improve this situation is by converting some images to png with ImageMagick and running <strong>pngcrush</strong> on them. A simple script can be used to do so:</p>

<pre><code>    #!/bin/bash
    totalsize=0
    for file in *jpg; do
            # file.jpg becomes file.png
            newfile=${file/jpg/png}
            # convert to png
            convert $file 1.png
            # compact with pngcrush
            pngcrush -brute 1.png $newfile &gt; /dev/null
            # calculate old and new sizes
            newsize=$(wc -c &lt; $newfile)
            oldsize=$(wc -c &lt; $file)
            if [ $newsize -lt $oldsize ]; then
                    echo "$file: reduced from $oldsize to $newsize bytes"
                    # remove old jpg file
                    rm -f $file
                    # replace all references to old file everywhere
                    sed -i -e "s/$file/$newfile/g" *
                    totalsize=$[$totalsize + $oldsize - $newsize]
            else
                    # old file is smaller, remove new file
                    rm -f $newfile
            fi
    done
    echo "total reduction: $totalsize"
    # remove temporary file
    rm -f 1.png
</code></pre>

<p>By running it on the website in question, it managed to shrink the front page by about <strong>200KB</strong> of image data. Considering <strong>10000</strong> daily accesses, it would save about <strong>2GB</strong> of network traffic per day.</p>
]]></content:encoded>
			<wfw:commentRss>http://dodonov.net/blog/2009/09/24/improving-website-scalability-image-sizes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: dodonov.net @ 2012-02-07 12:26:19 -->
