<?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>Monday By Noon &#187; ImageMagick</title>
	<atom:link href="http://mondaybynoon.com/tag/imagemagick/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>&#8226; Crop and Resize Images with GD or ImageMagick (v1.1)</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20071217%2Fcrop-and-resize-images-with-gd-or-imagemagick-v11%2F&#038;seed_title=%26%238226%3B+Crop+and+Resize+Images+with+GD+or+ImageMagick+%28v1.1%29</link>
		<comments>http://mondaybynoon.com/20071217/crop-and-resize-images-with-gd-or-imagemagick-v11/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 08:12:20 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Favorites]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[Cropper UI]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/</guid>
		<description><![CDATA[A new GD version has been released to complement the ImageMagick crop and resize with JavaScript and PHP. Crop and resize images from within your browser.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=113&c=165472176' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=113&c=165472176' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>Over the past couple weeks, <a href="/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comments">conversation has picked up quite a bit</a> surrounding the <a href="/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comments">Crop &amp; Resize with JavaScript, PHP, and ImageMagick</a> demo I put together nearly a year ago. There were quite a few requests made in the comments, and there were even some developers beginning to offer their very own code. I&#8217;ve always meant to revisit the example and beef up the feature set a bit, and I&#8217;ve finally been able to do just that.</p>
<h2>Crop and Resize with GD</h2>
<p>Above all, the most asked question was &#8220;<a href="/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-7477">why only ImageMagick</a>&#8220;? I really don&#8217;t have a solid answer for that, other than the project itself was a way for me to get into using <a href="http://www.imagemagick.org/">ImageMagick</a> in a bit more detail than I ever had. I&#8217;m very happy to say that this version (as well as any future versions) now has equivalent ImageMagick <em>and GD</em> installations. You can choose one or the other in both the demo and download sections.</p>
<p><a class="demo" href="/examples/crop-resize/1.1/gd/">Demo: GD Crop and Resize v1.1</a></p>
<p><a class="demo" href="/examples/crop-resize/1.1/imagemagick/">Demo: ImageMagick Crop and Resize v1.1</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>Converting to <a href="http://www.boutell.com/gd/">GD</a> wasn&#8217;t a major undertaking thanks to the helpful comments on version 1.0. It did take some time getting the slider to properly convey dimensions that would result in an accurate recreation of the image. One thing I have noticed is that the GD version seems to result in lower quality output when compared directly to ImageMagick. If you&#8217;ve got a server with both GD and ImageMagick installed, take a minute to use the same image in both demos to see what the differences are. I plan on looking into this much further, but if you&#8217;re a bit more knowledgeable on the subject, I&#8217;d love to hear what you have to say. Could the answer be that ImageMagick is simply a superior piece of software? I noticed that GD gives you the option to control the quality of images when using certain functions, so I left image output at 90% for the time being (the default is 75%).</p>
<p>If you have any positive or negative experiences with the new GD version, please feel free to post your findings either below, or in an email to me. I&#8217;d be greatly appreciative of any data that comes through.</p>
<h3>Updates to the server side</h3>
<p>There were a number of fixes that needed to be done to the server side of things straight away. First and foremost was Linux dependency. I must admit, a Windows server didn&#8217;t cross my mind when I was working on version 1.0, so I tried to polish things up a bit in that regard. The <code>mv</code> lines have been replaced, as well as an update or two elsewhere. There could very well be some more Windows-specific issues to be dealt with, unfortunately I don&#8217;t have any Windows servers at my disposal to test with. Feedback in this area will be particularly helpful.</p>
<p>A small series of updates I made was to the file upload process itself. The example now only accepts files with a MIME type of <code>image/jpeg</code>. Future versions will allow for more image formats, but I&#8217;d like to do some more research before including it. There are also some checks on the filenames themselves, as there were some issues with particular circumstances in version 1.0.</p>
<p>There was some logic repair regarding the <code>$maxWidth</code> and <code>$maxHeight</code> variables you can set in the first step. As per request, <code>$minWidth</code> and <code>$minHeight</code> have also been added. This should allow you to really narrow down what image dimensions will result using these variables in conjunction with the <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a>. One issue that has not been included yet is taking the minimum and maximum values set in the first step into account when users have reached the resize stage of version 1.1. This will be handled in a future release.</p>
<p>Finally, the last noticeable feature to be added server side was the inclusion of <a href="/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-25838">image rotation</a>. When the final image is presented, image rotations of 90, 180, and 270 degrees will be available as well. You&#8217;re able to pull apart the code to retrieve which image you&#8217;d like to use, and can also include auto-generation using a form whenever you&#8217;d like. This was a larger hill to climb when it came to GD as none of the servers I have access to had PHP compiled with GD bundled, therefore giving me no access to <a href="http://www.php.net/imagerotate"><code>imagerotate()</code></a>. As reflected in the source, <a title="Alternative PHP function for imagerotate()" href="http://www.php.net/manual/en/function.imagerotate.php#73446">a function was written as an alternative</a>, and appears to work just fine. It checks to see if <code>imagerotate()</code> is available before taking the extra <abbr title="Central Processing Unit">CPU</abbr> cycles doing it &#8216;by hand&#8217;.</p>
<p><span id="more-113"></span></p>
<h3>Updates to the <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a></h3>
<p>I can&#8217;t credit <a href="http://www.defusion.org.uk/">Dave Spurr</a> enough for his <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Cropper UI</a> that powers the entire front end of the cropping mechanism this installation provides. He had made a number of updates after my version 1.0 release, so first things first I went ahead and upgraded to his most recent version.</p>
<p>The second most asked for feature was a specific alteration to the Cropper UI itself. Whether it be minimum dimensions, maximum dimensions, or something else, it seemed like many people would like to use the script, but the openness of the Cropper UI was in fact a limitation. I made an effort to indicate that Dave Spurr included many of the requested features right out the box and documented them well on his website. To help with the version 1.1 demo, I&#8217;ve included a few Cropper UI instances to demonstrate its robustness. When you check out the demo, you&#8217;ll see a new option to choose the crop type you&#8217;d like to use. I&#8217;ve included the following by default:</p>
<dl>
<dt>Basic crop</dt>
<dd>Includes the most basic version of the Cropper UI. Unrestricted as far as crop dimension is concerned.</dd>
<dt>Ratio (16:9)</dt>
<dd>A 16:9 ratio will be applied to the Cropper UI. There are no restrictions for width or height.</dd>
<dt>Minimum Dimensions (200&#215;200)</dt>
<dd>The Cropper UI will require a minimum 200px by 200px crop area and will not allow anything less.</dd>
<dt>Minimum Dimensions (200&#215;200) with Ratio (1:1)</dt>
<dd>The Cropper UI will require a minimum 200px by 200px crop area and will not allow anything less. It will also apply a 1 to 1 ratio when adjusting the crop area.</dd>
<dt>Maximum Dimensions (200&#215;200)</dt>
<dd>The Cropper UI will require a maximum 200px by 200px crop area and will not allow anything less.</dd>
<dt>Maximum Dimensions (200&#215;200) with Ratio (1:1)</dt>
<dd>The Cropper UI will require a maximum 200px by 200px crop area and will not allow anything less. It will also apply a 1 to 1 ratio when adjusting the crop area.</dd>
<dt>Fixed Dimensions (200&#215;200)</dt>
<dd>You&#8217;re provided with a crop area at a fixed size of 200px by 200px. The drag handles are also removed as an added convenience.</dd>
<dt>Minimum Dimensions (100&#215;100) &amp; Maximum Dimensions (200&#215;200)</dt>
<dd>With this option, you&#8217;re limited to a crop area range scaling from 100px by 100px to 200px by 200px.</dd>
</dl>
<p>The Cropper UI is quite impressive in and of itself as you can see by the number of options you can apply by changing some values. For example, one thing I didn&#8217;t include in the demo is a Cropper UI that is limited to minimum and maximum dimensions as well as an aspect ratio of 1:1. You can easily invoke a Cropper UI with these attributes by creating a new file (<code>lib/init_cropper/min_max_ratio.js</code> for example) and inserting the following:</p>
<pre class="sh_javascript"><code>function onEndCrop(coords, dimensions) {
	$('cropX').value = coords.x1;
	$('cropY').value = coords.y1;
	$('cropWidth').value = dimensions.width;
	$('cropHeight').value = dimensions.height;
}

Event.observe( window, 'load', function() {
	new Cropper.Img(
		'cropImage', {
			ratioDim: { x: 1, y: 1 },
			minWidth: 200,
			minHeight: 200,
			maxWidth: 300,
			maxHeight: 300,
			onEndCrop: onEndCrop
		}
	);
});</code></pre>
<p>Swapping in this JavaScript would invoke a new Cropper UI for your image with a minimum dimension of 200px by 200px, a maximum dimension of 300px by 300px, as well as an aspect ratio of 1:1. Going further, you&#8217;re also able to specify a minimum or maximum for a height or width alone. This will result in a Cropper UI with handles only on the top and bottom if you wish. I would definitely suggest checking out the official website for <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">Dave Spurr&#8217;s Cropper UI</a> for more details</p>
<h3>Download &amp; installation instructions</h3>
<p>Installation is very straightforward. Download links to follow.</p>
<ol>
<li>Download the GD or ImageMagick version</li>
<li>Extract</li>
<li>Upload to your webserver</li>
<li><em>Give write permissions</em> to the <code>working</code> folder and subfolders</li>
<li>Begin using the demo</li>
</ol>
<p><a class="zipDownload" href="/examples/crop-resize/1.1/download/crop-resize-gd-1.1.zip">Download GD Crop and Resize v1.1 (.zip)</a></p>
<p><a class="zipDownload" href="/examples/crop-resize/1.1/download/crop-resize-imagemagick-1.1.zip">Download ImageMagick Crop and Resize v1.1 (.zip)</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>Many times, if you&#8217;re experiencing odd behavior such as pages turning up blank, there is an issue with write permissions on your server. The demo will need write access to the directory in which it is stored as well as the <code>working</code> folder and all folders within it. Errors with the code itself will more than likely be output to the screen. If that happens, please feel free to post your errors at your earliest convenience.</p>
<h3>What about AJAX?</h3>
<p>Another request that popped up more than once was a request for an AJAX version, something that didn&#8217;t require the page to reload. I thought about working out something such as that but quickly dismissed it, at least for now. My intention with this project was to provide something which would be used by the widest audience possible. Too many times have I seen examples too far into their own development to prevent me from writing something from scratch. In my opinion, an AJAX version of this example would prevent easy adoption and inclusion for many developers. AJAX may be a possibility for a future version, but I&#8217;d like to seriously consider as many angles as possible. This directly relates to the (lack of) design when looking at the demonstration. I wanted to keep things minimal in order to create the least work for anyone who wants to try incorporating this into something they&#8217;ve written.</p>
<p>I hope at the very least, the GD version presents itself as useful to at least a few people over the coming months. I do plan continuing work on future version, I simply hope it doesn&#8217;t take as long as this revision has. Please provide any comments you&#8217;d like, especially bug reports, and enjoy the demo!</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=113&c=969282143' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=113&c=969282143' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20071217/crop-and-resize-images-with-gd-or-imagemagick-v11/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>&#8226; Crop &amp; Resize with JavaScript, PHP, and ImageMagick</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20070122%2Fcrop-resize-with-javascript-php-and-imagemagick%2F&#038;seed_title=%26%238226%3B+Crop+%26amp%3B+Resize+with+JavaScript%2C+PHP%2C+and+ImageMagick</link>
		<comments>http://mondaybynoon.com/20070122/crop-resize-with-javascript-php-and-imagemagick/#comments</comments>
		<pubDate>Mon, 22 Jan 2007 11:32:24 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/</guid>
		<description><![CDATA[This demo was put together in an effort to make very basic image editing easier for less technically inclined users.  The main intention is to provided it as a component to include in a variety of applications including custom content management systems or Web applications.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=61&c=62792334' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=61&c=62792334' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p class="update"><strong>Update:</strong> <a href="/2007/12/17/crop-and-resize-images-with-gd-or-imagemagick-v11/">A new version</a> of this example and demonstration has been released. Version 1.1 includes a <strong>GD</strong> version of the script as well as a number of functional improvements worth checking out.</p>
<p class="update"><strong>Update:</strong> There has been significant discussion in the comments regarding a GD version of this script. I have re-released v1.0 of this example as a GD version as well as an ImageMagick version. <del>You can find both downloads below</del> <ins>The download has been removed in preparation of version 1.1 due for release on December 17, 2007</ins>. They behave function exactly the same as one another. Thanks for all the contributions (<a href="/2007/01/22/crop-resize-with-javascript-php-and-imagemagick/#comment-39674">Stefan Leever</a> and others) and requests!</p>
<p>Image management is often a big part of a comprehensive <abbr title="Content Management System">CMS</abbr>, and in my personal experience, has been one of the more difficult areas to make really easy for people to use.  Those that are technically inclined are often able to successfully format an image to their liking if given proper instruction.  On the other hand there are many who find image editing to be difficult, intimidating, and/or confusing.</p>
<p><a class="viewDemo" href="/examples/image_crop_resize/">View JavaScript Crop &amp; Resize Demo</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<p>In an effort to better the situation, I put together a demo which gives the end user the ability to upload, crop, and resize their image from within their Web browser.  The intention, on my end, would be to use it for server-side image pre-processing before the image is used by a client in their <abbr title="Content Management System">CMS</abbr> for their website.</p>
<h2>What powers JavaScript cropping &amp; resizing</h2>
<p>This demo wouldn&#8217;t be possible without a number of scripts that can not go without mention.  First and foremost, the entire client side process is based on the <a href="http://prototypejs.org/">Prototype JavaScript Library</a>.  Prototype has just been updated to version 1.5.0 and it acts as the foundation for both the crop and resize stages of the demo.</p>
<p>Another essential piece of this demo is <a href="http://script.aculo.us/">script.aculo.us</a>, a collection of effects addons for Prototype.  It provides some really excellent <abbr title="User Interface">UI</abbr> tools to work with as well as various animation effects.  Both the crop and resize stages use script.aculo.us features.</p>
<h4>JavaScript Image Cropper UI by Dave Spurr</h4>
<p>In my opinion, the most comprehensive aspect of this JavaScript image crop and resize demo is the cropping stage.  The <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a> by Dave Spurr is a script that deserves the spotlight in the demo.  It was written using both <a href="http://prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">script.aculo.us</a> and it is the one piece that really brings the demo together.</p>
<p>Dave&#8217;s JavaScript Image Cropper UI has many more capabilities than the basic version included in the demo.  If you check out his documentation he includes cropper user interfaces that can inherit various options such as retaining an aspect ratio, min/max width/height, and also display a crop preview if desired.  The <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/">JavaScript Image Cropper UI</a> by Dave Spurr is a feat in and of itself and should be given proper recognition.</p>
<h2>Server requirements</h2>
<p>The provided demo was written for a Linux based Web server running <a href="http://www.php.net/">PHP</a> and having <a href="http://www.imagemagick.org/">ImageMagick</a> installed.  It should run on a Windows based server with minimal adjustments, such as including the path to your ImageMagick install for each command.</p>
<p><a href="http://www.imagemagick.org/">ImageMagick</a> is a powerful command line image editor which performs all of the actual image transformations server-side.  Installation is usually quite easy after following directions written for your Web server configuration.</p>
<p><span id="more-61"></span></p>
<h4>Installation notes</h4>
<p>After you&#8217;ve downloaded the demo, extract the files to a common directory and upload that folder to your server.  After uploading, the directory will need to be given write permissions.  Failing to do so will destroy the functionality of the demo as uploads won&#8217;t be saved and there would be no way to create the adjusted images.</p>
<p><a class="zipDownload" href="/examples/image_crop_resize/download/mbn_crop_resize_v1.0.zip">Download ImageMagick Crop &amp; Resize (.zip)</a></p>
<p class="update">The demos and downloads have been removed temporarily due to a security issue. Replacements will be linked as soon as possible. Thank you for your patience. Please discontinue use as soon as possible until a revision has been posted.</p>
<h5>Closing thoughts about cropping and resizing with JavaScript</h5>
<p>This demo was put together in an effort to make very basic image editing easier for less technically inclined users.  The main intention is to provide it as a component to include in a variety of applications including custom content management systems or Web applications.</p>
<p>I hope the demo proves to be useful, but I absolutely welcome any comments and criticisms readers may have.  Please take a minute to post your thoughts below so that the demo can be in constant revision to ensure it&#8217;s effectiveness.</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=61&c=1798713284' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=61&c=1798713284' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20070122/crop-resize-with-javascript-php-and-imagemagick/feed/</wfw:commentRss>
		<slash:comments>104</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/56 queries in 0.064 seconds using apc
Object Caching 634/707 objects using apc

Served from: www.mondaybynoon.com @ 2012-02-09 06:48:05 -->
