<?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>-= n8v =- &#187; GD</title>
	<atom:link href="http://n8v.enteuxis.org/tags/gd/feed/" rel="self" type="application/rss+xml" />
	<link>http://n8v.enteuxis.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 27 Sep 2011 00:52:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-beta2-18055</generator>
		<item>
		<title>Getting PHP&#8217;s GD module to work with IIS</title>
		<link>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/</link>
		<comments>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 21:26:38 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[JPEG]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=106</guid>
		<description><![CDATA[Grrr, this cost me about 10 hours, and was hard to research, so I&#8217;m documenting it here for The Good Of Everyone: Problem I work with PHP on a bunch of different web servers. In this case I needed to resize photos (JPEGs) from Microsoft SQL Server (MSSQL) blobs on a Windows web server running [...]]]></description>
			<content:encoded><![CDATA[<p>Grrr, this cost me about 10 hours, and was hard to research, so I&#8217;m documenting it here for The Good Of Everyone:</p>

<h3>Problem</h3>

<p>I work with PHP on a bunch of different web servers.  In this case I needed to resize photos (JPEGs) from Microsoft SQL Server (MSSQL) blobs on a Windows web server running IIS.  I got stuff working on my local Windows development machine (under Apache, <a href="http://www.apachefriends.org/en/xampp.html">XAMPP </a>rocks BTW), but when I moved to the production server:</p>

<ul>
    <li>the script would silently fail with a 500 error whenever I called a GD function, specifically <code><a href="http://us2.php.net/manual/en/function.imagecreatefromstring.php">imagecreatefromstring()</a></code></li>
    <li>The most common IIS and GD error appears to be when PHP can&#8217;t find the GD DLL at all, which produces a nice message like 


<blockquote>Fatal error: Call to undefined function: imagecreatefromstring() in c:\inetpub\wwwroot\test2.php on line 7
PHP Warning: Unable to load dynamic library &#8216;c:\php\ext\php_gd2.dll&#8217; &#8211; The specified procedure could not be found. in Unknown on line 0 
</blockquote>

This was NOT my problem.  My script kept failing silently, with no output after I called the first GD function.</li>
    <li>IIS has no real error log like Apache.  When my script silently failed, nothing was logged in the Application Event log, PHP&#8217;s <var>error.log</var> or the pathetic <var>c:\WINDOWS\system32\LogFiles\HTTPERR\httperr*.log</var>.
<a href="http://blog.monstuff.com/archives/000179.html">Googling hard</a>, I found I <em>might</em> have luck looking for <a href="http://technet.microsoft.com/en-us/library/cc756146.aspx">&#8220;Worker Process Recycling Events&#8221;</a>, which is apparently Microsoft&#8217;s IIS term for that confusing word &#8220;error&#8221;, but I didn&#8217;t go far down that path.
</li>
    <li>Running my script from the command line using PHP didn&#8217;t produce any visible error either</li>

</ul>

<p>IIS sucks.  Apache&#8217;s error log is <strong>way</strong> better.</p>

<h3>Solutions</h3>

<p>I had to do both these things:</p>

<ul>
    <li><a href="http://www.vbulletin.com/forum/archive/index.php/t-111622.html">Copy the php_gd2.dll to C:\WINDOWS\system32</a>.  Ridiculous, but I have had to do it before with other PHP modules to have them really work.  After I did that, the script would work for <em>small</em> JPEG images.</li>
    <li>Increase the memory_limit in php.ini from 16MB to 32MB, so any whole high-res JPEG from the database will fit uncompressed in PHP&#8217;s memory</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

