<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Image Manipulation using PHP and ImageMagicK</title>
	<atom:link href="http://nodstrum.com/2007/02/06/imagemagick_manipulation/feed/" rel="self" type="application/rss+xml" />
	<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/</link>
	<description>A coders playground.</description>
	<pubDate>Thu, 20 Nov 2008 23:28:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: wodka</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-9016</link>
		<dc:creator>wodka</dc:creator>
		<pubDate>Mon, 10 Nov 2008 13:02:44 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-9016</guid>
		<description>Wow! Thank you very much. I had exactly the same problem. Your solution saved me a lot of time :)</description>
		<content:encoded><![CDATA[<p>Wow! Thank you very much. I had exactly the same problem. Your solution saved me a lot of time <img src='http://nodstrum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shafique</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8877</link>
		<dc:creator>shafique</dc:creator>
		<pubDate>Sat, 08 Nov 2008 22:40:38 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8877</guid>
		<description>SOLVED!!!!!!

See the following link:
http://www.daniweb.com/forums/thread116143.html

And here's my solution (I uninstalled IM and reinstalled it into my home directory, that's why the paths are different from what I listed before. But this has nothing to do with what the problem was. I also changed the user from www to www2 - I added the www2 user and made a change in the httpd.conf file - but again this was part of troubleshooting and had nothing to do with the problem):

Code:
putenv("MAGICK_HOME=" .$_ENV["MAGICK_HOME"]. "/Users/shafique/ImageMagick-6.4.5/");
exec('echo $MAGICK_HOME',$array);
putenv("PATH=" .$_ENV["PATH"]. "/Users/shafique/ImageMagick-6.4.5/bin");
exec('echo $PATH',$array);
putenv("DYLD_LIBRARY_PATH=" .$_ENV["DYLD_LIBRARY_PATH"]. "/Users/shafique/ImageMagick-6.4.5/lib");
exec('echo $DYLD_LIBRARY_PATH',$array);
echo "".print_r($array)."";
exec('/Users/shafique/ImageMagick-6.4.5/bin/convert /Users/www2/IMG_0041.JPG /Users/www2/41.png 2&#62;&#38;1', $array);


So the problem was that my environment variables would not stay set they way that I had set them after installing IM; I have to set them each time I run the php code, as above. Note that simply using:

Code:
exec( 'export $DYLD_LIBRARY_PATH="/Users/shafique/ImageMagick-6.4.5/lib" ',$array);


(as per the IM installation instructions) will NOT work; the environment variable will NOT stay set this way (at least on my Leopard 10.5 MacBook Pro). Note also it necessary that both the input and output files be in a directory that is accessible to all (I did chmod a+rw /Users/www2).

I hope this helps others!</description>
		<content:encoded><![CDATA[<p>SOLVED!!!!!!</p>
<p>See the following link:<br />
<a href="http://www.daniweb.com/forums/thread116143.html" rel="nofollow">http://www.daniweb.com/forums/thread116143.html</a></p>
<p>And here&#8217;s my solution (I uninstalled IM and reinstalled it into my home directory, that&#8217;s why the paths are different from what I listed before. But this has nothing to do with what the problem was. I also changed the user from www to www2 - I added the www2 user and made a change in the httpd.conf file - but again this was part of troubleshooting and had nothing to do with the problem):</p>
<p>Code:<br />
putenv(&#8221;MAGICK_HOME=&#8221; .$_ENV["MAGICK_HOME"]. &#8220;/Users/shafique/ImageMagick-6.4.5/&#8221;);<br />
exec(&#8217;echo $MAGICK_HOME&#8217;,$array);<br />
putenv(&#8221;PATH=&#8221; .$_ENV["PATH"]. &#8220;/Users/shafique/ImageMagick-6.4.5/bin&#8221;);<br />
exec(&#8217;echo $PATH&#8217;,$array);<br />
putenv(&#8221;DYLD_LIBRARY_PATH=&#8221; .$_ENV["DYLD_LIBRARY_PATH"]. &#8220;/Users/shafique/ImageMagick-6.4.5/lib&#8221;);<br />
exec(&#8217;echo $DYLD_LIBRARY_PATH&#8217;,$array);<br />
echo &#8220;&#8221;.print_r($array).&#8221;";<br />
exec(&#8217;/Users/shafique/ImageMagick-6.4.5/bin/convert /Users/www2/IMG_0041.JPG /Users/www2/41.png 2&gt;&amp;1&#8242;, $array);</p>
<p>So the problem was that my environment variables would not stay set they way that I had set them after installing IM; I have to set them each time I run the php code, as above. Note that simply using:</p>
<p>Code:<br />
exec( &#8216;export $DYLD_LIBRARY_PATH=&#8221;/Users/shafique/ImageMagick-6.4.5/lib&#8221; &#8216;,$array);</p>
<p>(as per the IM installation instructions) will NOT work; the environment variable will NOT stay set this way (at least on my Leopard 10.5 MacBook Pro). Note also it necessary that both the input and output files be in a directory that is accessible to all (I did chmod a+rw /Users/www2).</p>
<p>I hope this helps others!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shafique</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8869</link>
		<dc:creator>shafique</dc:creator>
		<pubDate>Sat, 08 Nov 2008 19:53:47 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8869</guid>
		<description>Hello HW,

Thanks for the suggestion about the access rights. The PHP user operates as "_www". Changing permissions recursively on the IM directory to give all users rwx permissions, which I did, should have taken care of any permissions issues. I ran some tests using php script to see what kind of errors were being returned, and here's what I came up with:

Here's the testing code:

$array=array();
echo "";
exec("/Applications/ImageMagick-6.4.4/bin/convert IMG_0041.JPG 41.png 2&#62;&#38;1", $array);
echo "".print_r($array)."";
echo ""; 

and here's the error that the above script generated:

Array
(
    [0] =&#62; dyld: Library not loaded: /ImageMagick-6.4.4/lib/libMagickCore.1.dylib
    [1] =&#62;   Referenced from: /Applications/ImageMagick-6.4.4/bin/convert
    [2] =&#62;   Reason: image not found
)

What's odd is that running the following command from the command line in a terminal window:

/Applications/ImageMagick-6.4.4/bin/convert IMG_0041.JPG 41.png 2&#62;&#38;1

works just fine. I'm thinking to focus on the first error:

[0] =&#62; dyld: Library not loaded: /ImageMagick-6.4.4/lib/libMagickCore.1.dylib

It seems that as a terminal user the library loads, but as "_www" it does not. Since the permissions are fine, maybe the paths need to be changed for the "_www" Are path settings different for different users? Your thoughts?</description>
		<content:encoded><![CDATA[<p>Hello HW,</p>
<p>Thanks for the suggestion about the access rights. The PHP user operates as &#8220;_www&#8221;. Changing permissions recursively on the IM directory to give all users rwx permissions, which I did, should have taken care of any permissions issues. I ran some tests using php script to see what kind of errors were being returned, and here&#8217;s what I came up with:</p>
<p>Here&#8217;s the testing code:</p>
<p>$array=array();<br />
echo &#8220;&#8221;;<br />
exec(&#8221;/Applications/ImageMagick-6.4.4/bin/convert IMG_0041.JPG 41.png 2&gt;&amp;1&#8243;, $array);<br />
echo &#8220;&#8221;.print_r($array).&#8221;";<br />
echo &#8220;&#8221;; </p>
<p>and here&#8217;s the error that the above script generated:</p>
<p>Array<br />
(<br />
    [0] =&gt; dyld: Library not loaded: /ImageMagick-6.4.4/lib/libMagickCore.1.dylib<br />
    [1] =&gt;   Referenced from: /Applications/ImageMagick-6.4.4/bin/convert<br />
    [2] =&gt;   Reason: image not found<br />
)</p>
<p>What&#8217;s odd is that running the following command from the command line in a terminal window:</p>
<p>/Applications/ImageMagick-6.4.4/bin/convert IMG_0041.JPG 41.png 2&gt;&amp;1</p>
<p>works just fine. I&#8217;m thinking to focus on the first error:</p>
<p>[0] =&gt; dyld: Library not loaded: /ImageMagick-6.4.4/lib/libMagickCore.1.dylib</p>
<p>It seems that as a terminal user the library loads, but as &#8220;_www&#8221; it does not. Since the permissions are fine, maybe the paths need to be changed for the &#8220;_www&#8221; Are path settings different for different users? Your thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Human Wannabe</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8719</link>
		<dc:creator>Human Wannabe</dc:creator>
		<pubDate>Thu, 06 Nov 2008 17:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-8719</guid>
		<description>shafique: you may want to check the access rights &#38; permisions you have for PHP vs terminal user</description>
		<content:encoded><![CDATA[<p>shafique: you may want to check the access rights &amp; permisions you have for PHP vs terminal user</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shafique</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-7937</link>
		<dc:creator>shafique</dc:creator>
		<pubDate>Fri, 24 Oct 2008 22:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-7937</guid>
		<description>Hello, I'm also having problems executing "convert" using PHP.

First the path was wrong, and the system command gave me a return value of 127. Then I fixed the path to the convert command (/Applications/ImageMagick-6.4.4/bin/convert), and I fixed the paths to the input and output filenames. Here is the code I'm using:

&#60;?php
$resizefile = "/Applications/ImageMagick-6.4.4/bin/convert /Users/shafiquejamal/outsideofwebdir/uploads/IMG_0041.JPG /Users/shafiquejamal/outsideofwebdir/uploads/41.png";

echo $resizefile;
$last_line = system($resizefile , $retval);

// Printing additional info
echo '

Last line of the output: ' . $last_line . '
Return value: ' . $retval;
?&#62;

The return value is 5, when I execute this; it does not convert the file. BUT When I copy and past the resize command exactly (without quotes) into the terminal window, it works just fine - it converts the file. It just doesn't work from php (i.e. the php script executed from the brower does not do anything). I'm running MAC OS X Leopard 10.5.5 on a MacBook Pro (Intel), and using ImageMagick-6.4.4 I've changed permissions on the source and target folders using chmod a+rw {paths}, and checked that everyone can read and write to those directories.</description>
		<content:encoded><![CDATA[<p>Hello, I&#8217;m also having problems executing &#8220;convert&#8221; using PHP.</p>
<p>First the path was wrong, and the system command gave me a return value of 127. Then I fixed the path to the convert command (/Applications/ImageMagick-6.4.4/bin/convert), and I fixed the paths to the input and output filenames. Here is the code I&#8217;m using:</p>
<p>&lt;?php<br />
$resizefile = &#8220;/Applications/ImageMagick-6.4.4/bin/convert /Users/shafiquejamal/outsideofwebdir/uploads/IMG_0041.JPG /Users/shafiquejamal/outsideofwebdir/uploads/41.png&#8221;;</p>
<p>echo $resizefile;<br />
$last_line = system($resizefile , $retval);</p>
<p>// Printing additional info<br />
echo &#8216;</p>
<p>Last line of the output: &#8216; . $last_line . &#8216;<br />
Return value: &#8216; . $retval;<br />
?&gt;</p>
<p>The return value is 5, when I execute this; it does not convert the file. BUT When I copy and past the resize command exactly (without quotes) into the terminal window, it works just fine - it converts the file. It just doesn&#8217;t work from php (i.e. the php script executed from the brower does not do anything). I&#8217;m running MAC OS X Leopard 10.5.5 on a MacBook Pro (Intel), and using ImageMagick-6.4.4 I&#8217;ve changed permissions on the source and target folders using chmod a+rw {paths}, and checked that everyone can read and write to those directories.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-1686</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 31 Jul 2008 09:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-1686</guid>
		<description>works like a charm. Found another tutorial on the imagemagick website that shows how to generate multiple images and put them together as a prgressive gif making look like a slide show. I'll try and find the link to it again and post it here</description>
		<content:encoded><![CDATA[<p>works like a charm. Found another tutorial on the imagemagick website that shows how to generate multiple images and put them together as a prgressive gif making look like a slide show. I&#8217;ll try and find the link to it again and post it here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-1095</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 19 May 2008 15:15:01 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-1095</guid>
		<description>Hi All,

I am still building my image magick functions to handle all kinds of image manipulation from standard resizing and cropping to creating polaroid effects.  ImageMagick works great and has handled a 45Mb jpg file without a problem (except for the delay :-)).  The only thing that gets me is that I don't need to run it as a system command, locally or on the host.  I also use passthrough so it doesn't save new files and stuff.

Once I have the code I will try to remember to post it.  It is fairly big as it handles a lot of error checking.

Great site, clean simple and straight to the point - you rock!</description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>I am still building my image magick functions to handle all kinds of image manipulation from standard resizing and cropping to creating polaroid effects.  ImageMagick works great and has handled a 45Mb jpg file without a problem (except for the delay :-)).  The only thing that gets me is that I don&#8217;t need to run it as a system command, locally or on the host.  I also use passthrough so it doesn&#8217;t save new files and stuff.</p>
<p>Once I have the code I will try to remember to post it.  It is fairly big as it handles a lot of error checking.</p>
<p>Great site, clean simple and straight to the point - you rock!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-321</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Wed, 15 Aug 2007 09:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-321</guid>
		<description>Hi Ian,
I do not see why not... if you try it can you let all of us here know?

Cheers,
Jamie.</description>
		<content:encoded><![CDATA[<p>Hi Ian,<br />
I do not see why not&#8230; if you try it can you let all of us here know?</p>
<p>Cheers,<br />
Jamie.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ian</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-320</link>
		<dc:creator>ian</dc:creator>
		<pubDate>Wed, 15 Aug 2007 06:37:32 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-320</guid>
		<description>can ImageMagicK handle a 12MB jpeg file?</description>
		<content:encoded><![CDATA[<p>can ImageMagicK handle a 12MB jpeg file?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: skywalker</title>
		<link>http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-134</link>
		<dc:creator>skywalker</dc:creator>
		<pubDate>Thu, 05 Apr 2007 09:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://nodstrum.com/2007/02/06/imagemagick_manipulation/#comment-134</guid>
		<description>it's me again, i forgot to mention that ImageMagick has thumbnail and resize functions and a lot more. 

convert -thumbnail 100x100 img-from img-to

yep, one line.

Anywaz, keep up the good work!.</description>
		<content:encoded><![CDATA[<p>it&#8217;s me again, i forgot to mention that ImageMagick has thumbnail and resize functions and a lot more. </p>
<p>convert -thumbnail 100&#215;100 img-from img-to</p>
<p>yep, one line.</p>
<p>Anywaz, keep up the good work!.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
