00stuff Posted September 30, 2011 Share Posted September 30, 2011 Hi guys I am trying to use image magick with php to draw an image but when i run the script it doens't show anything. All I get is an a blank page. Does anyone know if I am doing this right. Here is my code. <?php echo "<pre>"; system("type convert"); echo "</pre>"; ?> <br /> <br /> <br /> <br /> <br /> <?php exec("/usr/bin/convert -size 200x200 xc:black -stroke black -strokewidth 1 \\ -fill white -draw \"circle 100,100 100,10 \" \\ -fill black -draw \"circle 100,100 100,30 \" \\ -fill blue -draw \"circle 100,100 100,50 \" \\ -fill red -draw \"circle 100,100 100,70 \" \\ -fill yellow -draw \"circle 100,100 100,90 \" \\ -fill none -draw \"circle 100,100 100,20 \" \\ -fill none -draw \"circle 100,100 100,60 \" \\ -fill none -draw \"circle 100,100 100,80 \" \\ -fill none -draw \"circle 100,100 100,95 \" \\ -stroke white -fill none \\ -draw \"circle 100,100 100,40 \" circle.png"); ?> My results are these: convert is /usr/bin/convert I really need some help with this. I haven't been able to find anything online. Quote Link to comment https://forums.phpfreaks.com/topic/248202-trying-to-use-image-magick-with-php-but-get-a-blank-page/ Share on other sites More sharing options...
requinix Posted September 30, 2011 Share Posted September 30, 2011 1. exec() does not output anything. 2. You told convert to put the image to a file so there's no output from there either. Was circle.png created correctly? Quote Link to comment https://forums.phpfreaks.com/topic/248202-trying-to-use-image-magick-with-php-but-get-a-blank-page/#findComment-1274520 Share on other sites More sharing options...
00stuff Posted September 30, 2011 Author Share Posted September 30, 2011 Yes, I just checked. The image was created successfully. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/248202-trying-to-use-image-magick-with-php-but-get-a-blank-page/#findComment-1274523 Share on other sites More sharing options...
requinix Posted September 30, 2011 Share Posted September 30, 2011 Two options: 1. If you actually need an image file, like you're updating something infrequently, then only (re)create the image when it needs to be (re)created. As in, not on every page load like it will do now. Then add an referencing it to actually see it on the page. 2. Use passthru to call convert and make the program output the image data instead of save it to a file. Put this passthru() call it one script somewhere with appropriate header()s, then use an to reference that script. header("Content-Type: image/png"); // according to whatever convert creates passthru("/usr/bin/convert..."); ?> Just know that the image.php will create the image every single time it's called, so if the image doesn't change a lot (or at all) then this is wasteful. Quote Link to comment https://forums.phpfreaks.com/topic/248202-trying-to-use-image-magick-with-php-but-get-a-blank-page/#findComment-1274532 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.