<?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>Web Development Blog &#187; ImageMagick</title>
	<atom:link href="http://www.web-development-blog.com/archives/tag/imagemagick/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-development-blog.com</link>
	<description>Web development tutorials, SEO articles and PHP script resources</description>
	<lastBuildDate>Sun, 25 Jul 2010 14:38:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Best methods to optimize JPEG images for websites</title>
		<link>http://www.web-development-blog.com/archives/best-methods-to-optimize-jpeg-images-for-websites/</link>
		<comments>http://www.web-development-blog.com/archives/best-methods-to-optimize-jpeg-images-for-websites/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 06:53:01 +0000</pubDate>
		<dc:creator>Olaf</dc:creator>
				<category><![CDATA[PHP scripts]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[fireworks]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://www.web-development-blog.com/?p=964</guid>
		<description><![CDATA[While Internet connections becoming faster and faster, it&#8217;s still important to keep your website as fast as possible. One of the &#8220;slow&#8221; parts of your website are the images. In this article we show several ways to down-size the JPEG images for your website. If you design your website should use some compression for your [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>While Internet connections becoming faster and faster, it&#8217;s still important to keep your website as fast as possible. One of the &#8220;slow&#8221; parts of your website are the images. In this article we show several ways to down-size the JPEG images for your website. </p>
<p>If you design your website should use some compression for your photos, banners and many other web elements. You favorite image editor should have some function to down-size your images. For this article we compare 4 ways to compress our example photo (file-size 393KB):</p>
<h3>Adobe Photoshop</h3>
<p>If you use the &#8220;Save for web&#8230;&#8221; function it&#8217;s possible to create a web optimized version from your image that is small enough and has a quality which is good enough for the Internet. In our example we used the preset &#8220;High Quality&#8221; which is equal to 60% quality. The result is a smaller file with a file-size of 95KB.</p>
<h3>Adobe Fireworks</h3>
<p>Fireworks is my favorite web image editor because of the unique feature to have bitmap and vector elements in a single file. We did an export with 80% quality and the compressed version has a file-size of 85KB.<br />
<span id="more-964"></span></p>
<h3>GIMP (free Image Editor)</h3>
<p>Both Adobe products are not free and are only available for Wndows or Mac. If you need a free editor you should try Gimp, an Image editor which many functions like the other commercial products mentioned before. The editor has also a &#8220;Safe for web&#8221; function and we used and 86% quality for our export file which becomes a size of 87KB. If you use GIMP to down-size your photos from your digital camera you should check the option &#8220;Strip EXIF&#8221;, removing the photo&#8217;s meta data will make the file smaller for another ~10KB.</p>
<h3><a href="http://www.web-development-blog.com/archives/image-manipulations-with-imagemagick/">ImageMagick</a> (command line tools)</h3>
<p>The last option is a tool we used via the command line. Using the following command the file is down-sized using an 80% quality (file size after conversion is 89KB):</p>
<p><code>convert original_100.jpg -quality 80 imagemagick_80.jpg</code>  </p>
<p>Sure this method works different from the other methods but the good point is that you can use this code in your PHP scripts or just from the command line of your web server.</p>
<h3>Original image and compressed copies</h3>
<p>Check the images below and note that the quality for the compressed images (file 2-5) is very similar.</p>

<a href='http://www.web-development-blog.com/wp-content/uploads/2010/03/original_100.jpg' rel='shadowbox[album-964];player=img;' title='Original 100%'><img width="150" height="150" src="http://www.web-development-blog.com/wp-content/uploads/2010/03/original_100-150x150.jpg" class="attachment-thumbnail" alt="Original 100%" title="Original 100%" /></a>
<a href='http://www.web-development-blog.com/wp-content/uploads/2010/03/photoshop_60.jpg' rel='shadowbox[album-964];player=img;' title='Adobe Photoshop 60%'><img width="150" height="150" src="http://www.web-development-blog.com/wp-content/uploads/2010/03/photoshop_60-150x150.jpg" class="attachment-thumbnail" alt="Adobe Photoshop 60%" title="Adobe Photoshop 60%" /></a>
<a href='http://www.web-development-blog.com/wp-content/uploads/2010/03/fireworks_80.jpg' rel='shadowbox[album-964];player=img;' title='Adobe Fireworks 80%'><img width="150" height="150" src="http://www.web-development-blog.com/wp-content/uploads/2010/03/fireworks_80-150x150.jpg" class="attachment-thumbnail" alt="Adobe Fireworks 80%" title="Adobe Fireworks 80%" /></a>
<a href='http://www.web-development-blog.com/wp-content/uploads/2010/03/imagemagick_80.jpg' rel='shadowbox[album-964];player=img;' title='Imagemagick 80%'><img width="150" height="150" src="http://www.web-development-blog.com/wp-content/uploads/2010/03/imagemagick_80-150x150.jpg" class="attachment-thumbnail" alt="Imagemagick 80%" title="Imagemagick 80%" /></a>
<a href='http://www.web-development-blog.com/wp-content/uploads/2010/03/gimp_86.jpg' rel='shadowbox[album-964];player=img;' title='GIMP 86%'><img width="150" height="150" src="http://www.web-development-blog.com/wp-content/uploads/2010/03/gimp_86-150x150.jpg" class="attachment-thumbnail" alt="GIMP 86%" title="GIMP 86%" /></a>

<p>The results after compression is very similar and the file size is between 85KB (fireworks) and 95KB (Photoshop). If you&#8217;re looking to down-size another 5-10%, you should try <a href="http://developer.yahoo.com/yslow/smushit/" rel="nofollow">Smush.it</a> a free service from Yahoo. They offer a tool which is able to optimize your images for 5-10% smaller file size without to lower the grade of quality.</p>
<h3>Optimize your JPEG images with ImageMagick and PHP</h3>
<p>If you need to optimize the images for your existing website, the following code might be useful:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/home/some_directory/'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the directory with your files</span>
<span style="color: #000088;">$compr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the quality precentage</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> PATHINFO_EXTENSION<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(jpg|jpeg)$/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'convert %s -quality %d %s'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$compr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> 
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Just enter the path to the the directory you like to optimize safe the code as a PHP script and execute the file from the command line of browser. Note only the JPEG files are getting compressed.</p>
<p>Optimize your images top make them load faster, but be careful don&#8217;t compress them too much. <strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.web-development-blog.com/archives/image-manipulations-with-imagemagick/" rel="bookmark" title="May 5, 2009">Image manipulations with Imagemagick</a></li>
<li><a href="http://www.web-development-blog.com/archives/upload-images-for-usage-in-tinymce/" rel="bookmark" title="September 25, 2008">Upload images for usage in TinyMCE</a></li>
<li><a href="http://www.web-development-blog.com/archives/tutorial-ftp-upload-via-curl/" rel="bookmark" title="October 11, 2007">Tutorial: FTP Upload via cURL</a></li>
</ul>
<p><!-- Similar Posts took 3.705 ms --></p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.web-development-blog.com/archives/best-methods-to-optimize-jpeg-images-for-websites/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Image manipulations with Imagemagick</title>
		<link>http://www.web-development-blog.com/archives/image-manipulations-with-imagemagick/</link>
		<comments>http://www.web-development-blog.com/archives/image-manipulations-with-imagemagick/#comments</comments>
		<pubDate>Tue, 05 May 2009 20:05:08 +0000</pubDate>
		<dc:creator>Olaf</dc:creator>
				<category><![CDATA[PHP scripts]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[image manipulation]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.web-development-blog.com/?p=294</guid>
		<description><![CDATA[A very powerful tool for creating and manipulating images is ImageMagick. With this tools you can create drawings, modify existing images or just process images. The tool is available for Linux, windows and Mac based systems and is free available. Using the command line is Imagemagick the optimal tool to use image functions within your [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>A very powerful tool for creating and manipulating images is ImageMagick. With this tools you can create drawings, modify existing images or just process images. The tool is available for Linux, windows and Mac based systems and is free available. Using the command line is Imagemagick the optimal tool to use image functions within your script or application.</p>
<p>Use Imagemagick to watermark your images, to create fancy e-cards or just to convert images into other formats. Basic operations are very easy like</p>
<p><code>convert resize 50% image.jpg new.png</code></p>
<p>This simple command will resize your jpg image and safe a copy as some new image in .png format. Just imagine how much code you need with the GD library. As a webmaster you will find ImageMagick with most of the web hosting accounts.</p>
<p><a rel="nofollow" href="http://www.packtpub.com/imagemagick/book/mid/3009085ym5z4" target="_blank"><img class="alignleft" style="margin-left: 5px; margin-right: 5px;" title="ImageMagick Tricks" src="http://images.packtpub.com/images/100x123/1904811868.png" alt="" width="97" height="123" /></a>Check Google if you need example code and resources. If you can’t find the information you should try the book &#8220;<a rel="nofollow" href="http://www.packtpub.com/imagemagick/book/mid/3009085ym5z4" target="_blank">ImageMagick tips and tricks</a>&#8220;. This book full of information and tutorials is a good start to learn all basic functions of this powerful tool.</p>
<p>Inside the book you find instructions how to install ImageMagick on different platform and there also basic instructions on how-to install additional fonts. If you’re interested in this feature you should read <a rel="nofollow" href="http://russia.shaps.hawaii.edu/software/add-to-im.html" target="_blank">this article</a> too.</p>
<p>You will find real word examples for each command line tool. Each function has a few lessons of each chapter to train each function with a real world example:<span id="more-294"></span></p>
<h3>Convert and mogrify</h3>
<p>Both functions are used for transformations, while the convert creates a new image is the mogrify function used to change existing images. For examples:</p>
<p>crop an existing image and safe a cropped new version<br />
<code>convert sample.png crop 110x70+60+50  cropped.jpg</code></p>
<p>draw a line on white background inside a new image<br />
<code>mogrify size 80x100 xcwhite draw 'line 10,10 70,90' line.bmp</code></p>
<h3>Composite and montage</h3>
<p>These both functions are used to group or assemble multiple image sequences together like:</p>
<p>Mask an existing logo image with some background and safe it into the result image<br />
<code>composite -compose CopyOpacity logo_mask.png background.png result.png</code></p>
<p>Other functions like identify, display, import and conjure are explained too, check the book or the IM website for more information.</p>
<p>The book is written to use ImageMagick with php. Use above tools in your PHP code like:</p>
<p><code>$command = 'convert example.jpg new.png';<br />
exec($command);</code></p>
<p>Instead of the PHP function exec it’s also possible to process the commands with functions like system, passthru or shell_exec.</p>
<p>After you got all the basic lessons you get some more practice:</p>
<ul>
<li>How to call ImageMagick Command-line Utilities within PHP code</li>
<li>How to Save the Result of an Online Image Processing Task</li>
<li>How to Start Sessions for our Visitors</li>
<li>Building a Confirmation-Code Box</li>
<li>Online Image Water Marking</li>
<li><strong>A complete E-card application</strong><br />
Learn how to add different text styles to your e-cards. The tutorial includes the complete code for the following features:</p>
<ul>
<li>Image gallery</li>
<li>Image upload / remote copy</li>
<li>custom text for the e-cards</li>
<li>fomat text on images</li>
<li>send the finished  e-card by e-mail</li>
</ul>
</li>
</ul>
<p>While reading the book you should check <a rel="nofollow" href="http://www.packtpub.com/support/book/imagemagick" target="_blank">this page</a> for example code, screenshots and additional information. If you’re not sure if this book is written for you try this <a rel="nofollow" href="http://www.packtpub.com/files/ImageMagick-Convert-and-Mogrify-Sample-Chapter.pdf" target="_blank">example chapter</a>. The book was released in 2006 but is still &#8220;compatible&#8221; with current version of ImageMagick.</p>
<h3>More ImageMagick resources</h3>
<ul>
<li><a href="http://www.imagemagick.org/script/index.php">The ImageMagick homepage</a></li>
<li><a href="http://www.imagemagick.org/Usage/">Examples of ImageMagick Usage</a></li>
<li><a href="http://valokuva.org/?cat=1"><strong>Imagick</strong> PHP code tutortials</a></li>
</ul>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.web-development-blog.com/archives/best-methods-to-optimize-jpeg-images-for-websites/" rel="bookmark" title="March 22, 2010">Best methods to optimize JPEG images for websites</a></li>
<li><a href="http://www.web-development-blog.com/archives/database-management-with-phpmyadmin/" rel="bookmark" title="May 12, 2008">Database Management with phpMyAdmin</a></li>
<li><a href="http://www.web-development-blog.com/archives/css-navigation-bar-with-stylish-web2-0-elements/" rel="bookmark" title="February 27, 2007">CSS navigation bar with stylish web2.0 elements</a></li>
</ul>
<p><!-- Similar Posts took 3.603 ms --></p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.web-development-blog.com/archives/image-manipulations-with-imagemagick/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->