deathdeyfer2002 Posted January 2, 2010 Share Posted January 2, 2010 All- I'm trying to automatically resize all of the images on my webpage. I currently have them stored in an array. I can access the array from the following code for ($imagecounter = 0; $imagecounter < $pic_count; $imagecounter++) { $currentimage = $folder[$imagecounter]; echo "<img src='/Movies/$currentimage' >"; } That goes through all of the images and displays them as pictures. I wanted to use the function from Imagemagik: mogrify . From the command line it resized the images without any trouble using the following code mogrify -resize 200x125 Left1.png I have been trying to incorporate this into PHP to have it do this automatically. Here is what I tried and it appears to be failing everytime $command = '"mogrify -resize 468.75x200"/home/deathdefyer2002/imageA.jpg exec($command); Please help. Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/ Share on other sites More sharing options...
RussellReal Posted January 2, 2010 Share Posted January 2, 2010 exec('mogrify -resize 468.75x200 /home/deathdefyer2002/imageA.jpg'); try that Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987244 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 Thanks for the reply.... Actually just tried that with NO luck. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987248 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 try $command = 'mogrify -resize 468.75x200 /home/deathdefyer2002/imageA.jpg'; $output = exec($command); var_dump($output); and tell us what you see Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987250 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 When I reload the page, It seems to be loading for a little bit but nothing new is being displayed. I entered exec('mogrify -resize 468.75x200 /home/deathdefyer2002/imageA.jpg'); I am testing the code by using the following: echo "<img src='/home/deathdefyer2002/imageA.jpg' >"; Every refresh and the image never changes. Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987253 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 Sorry I overlooked the "CODE" part in the last posing. When I run the code I get string(0) "" Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987256 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 try this out $command = 'mogrify -resize 468.75x200 /home/deathdefyer2002/imageA.jpg'; $output = array(); exec($command, $output); var_dump($output); also this echo "<img src='/home/deathdefyer2002/imageA.jpg' >"; is that the right path, it should a http path and not your linux path Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987261 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 I went ahead and updated the code and I still receive the following output string(0) "" The Imgsrc line appears to be working just fine. It IS displaying the image, but with the original dimensions. If I run the mogrify command on the command line and refesh the page, it does change the resolution. If you beleive that the IMG SRC could be the problem, then I will go ahead and update that to the HTML path. Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987265 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 not too sure, but could be a permission issue as your php script will run as restricted user you might even want to change the command to a absolute path like for example $command = '/usr/bin/mogrify -resize 468.75x200 /home/deathdefyer2002/imageA.jpg'; the above is just an example your command could be located at a different location, you can find the location on the shell by typing which mogrify hope its helpful that should show you the full path of the command. Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987267 Share on other sites More sharing options...
The Little Guy Posted January 2, 2010 Share Posted January 2, 2010 Also, you just need one size parameter when doing resize imagemagick can figure the rest out and resize nicely! you should also place your file name in single quotes: Try this: $command = "mogrify -resize x200 '/home/deathdefyer2002/imageA.jpg'" shell_exec($command); Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987273 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 I went ahead and updated the path to the file. That didn't help at all. I also changed the resolution to X200. Also this didn't do anything. Any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987279 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 the only thing i could suggest is to add these lines on top of your script and see if any errors are outputted not too sure how helpful it would be ini_set('display_errors', '1'); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987285 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 I added that and I get a BUNCH of the following error repeated over and over again Notice: Undefined index: quantity in /var/www/webfiles/Movies/Movies1.php on line 159 Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987293 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 Yes it would show you alot of errors do you have any errors pertaining to that exec function ? Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987297 Share on other sites More sharing options...
deathdeyfer2002 Posted January 2, 2010 Author Share Posted January 2, 2010 Nope just that error over and over again Quote Link to comment https://forums.phpfreaks.com/topic/186951-image-magik/#findComment-987314 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.