eric02138 Posted January 25, 2007 Share Posted January 25, 2007 Hi -Longtime listener, firsttime caller:I'm having some trouble making a thumbnailing program work. I'm calling Imagemagick directly using system(), since the GD Library and Imagick aren't available to me. But when I try to add parenthesis, my code stops working.The interesting thing is, the output of the code works great on the command line. It just won't fire from within PHP. So the following script works in PHP:****************************************<?php$maxsize = 250;$filepath = "/proj/ramwww/images/article_images/rachel.jpg";$suffix = "_thm";$basename = "/proj/ramwww/images/article_images/rachel";$cmd = "convert $filepath -level 0,90%,1.1 -thumbnail '" . $maxsize. "x" . $maxsize . ">' " . $basename . $suffix . ".jpg";echo $cmd . "<br />";$output = system($cmd);?> **********************************************...but when I try to add a nice drop shadow, it bombs:**********************************************<?php$maxsize = 250;$filepath = "/proj/ramwww/images/article_images/rachel.jpg";$suffix = "_thm";$basename = "/proj/ramwww/images/article_images/rachel";$cmd = "convert $filepath -level 0,90%,1.1 -thumbnail '" . $maxsize. "x" . $maxsize . ">' \( +clone -background black -shadow 80x2+3+3 \)-repage +2+2 +swap -background white -mosaic " . $basename . $suffix . ".jpg";echo $cmd . "<br />";$output = system($cmd);?>********************************************Strangely when I run the output in a shell manually, it works:********************************************$ convert /proj/ramwww/images/article_images/rachel.jpg -level 0,90%,1.1 -thumbnail '250x250>' \( +clone -background black -shadow 80x2+3+3 \) -repage +2+2 +swap -background white -mosaic /proj/ramwww/images/article_images/rachel_thm.jpg********************************************Has anyone experienced this problem when executing command line scripts? Any ideas?Thanks,Eric Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/ Share on other sites More sharing options...
utexas_pjm Posted January 25, 2007 Share Posted January 25, 2007 escape them.[code]<?php$cmd = 'echo ()';$output = system($cmd);//doesn't work$cmd = 'echo \(\)';$output = system($cmd);// tada?>[/code]Best,Patrick Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/#findComment-169260 Share on other sites More sharing options...
effigy Posted January 25, 2007 Share Posted January 25, 2007 You need the ability to see (1) any output from STDERR, and (2) the return value. Have a look at [url=http://www.phpfreaks.com/forums/index.php/topic,122119.0.html]this[/url] topic. Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/#findComment-169264 Share on other sites More sharing options...
eric02138 Posted January 25, 2007 Author Share Posted January 25, 2007 Patrick -I thought I had commented the parenthesis using "\(" and "\)". Am I missing something?Effigy - I've changed my code to pipe the output of STDERR to STDOUT (using "2>&1") and echo'ed the output of the command. But still, nothing is returned as output:*********************************************************$cmd = "convert $filepath -level 0,90%,1.1 -thumbnail '" . $maxsize. "x" . $maxsize . ">' \( +clone -background black -shadow 80x2+3+3 \)-repage +2+2 +swap -background white -mosaic " . $basename . $suffix. ".jpg 2>&1";echo $cmd . "<br />";$output = system($cmd);echo "output is: " . $ouput . "<br />";********************************************************Again, I'm a bit of a unix newbie, so I might be missing something here, too.Thanks guys!Eric Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/#findComment-169274 Share on other sites More sharing options...
eric02138 Posted January 25, 2007 Author Share Posted January 25, 2007 Excuse me - there were "BR" tags at the end of the lines with "echo". Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/#findComment-169277 Share on other sites More sharing options...
eric02138 Posted January 25, 2007 Author Share Posted January 25, 2007 SOLVED!The command was:convert /proj/ramwww/images/article_images/rachel.jpg -level 0,90%,1.1 -thumbnail '250x250>' \( +clone -background black -shadow 80x2+3+3 \) -repage +2+2 +swap -background white -mosaic /proj/ramwww/images/article_images/rachel_thm.jpgwhen it should have been:convert /proj/ramwww/images/article_images/rachel.jpg -level 0,90%,1.1 -thumbnail 250x250\> \( +clone -background black -shadow 80x2+3+3 \) -repage +2+2 +swap -background white -mosaic /proj/ramwww/images/article_images/rachel_thm.jpgSome extraneous quotes and a missing backslash can make a world of difference.Thanks to Patrick and Effigy for the help! Link to comment https://forums.phpfreaks.com/topic/35717-system-does-not-work-when-command-contains-parenthesis/#findComment-169304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.