?
Solved

HELP IN IMAGE MAGICK

Posted on 2009-04-21
23
Medium Priority
?
627 Views
Last Modified: 2012-05-06
Hi,

i want to know how to run a image magic code in php/

in shell its working properly.
convert /home/xtended/public_html/rose.gif /home/xtended/public_html/gradient.jpg /home/xtended/public_html/jo.gif

i want the same to be executed in php

i tried the following

exec("/usr/local/bin/convert /home/xtended/public_html/rose.gif /home/xtended/public_html/gradient.jpg /home/xtended/public_html/jo.gif",$out) or die("bad command");

only the die command is executed.


0
Comment
Question by:whspider
  • 10
  • 8
  • 5
23 Comments
 

Author Comment

by:whspider
ID: 24193028
my imagemagick version is 6.4.9

php version is 5.2.8
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24193041
so you are trying to run this convert command from php

from shell which user account are you using to execute that convert programm ?? root ??

then you will have to give php script to run that command ...
0
 
LVL 8

Expert Comment

by:mostart
ID: 24193108
what does "var_dump($out)" tell you ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:whspider
ID: 24193206
it gives the following output

array(0) { }
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24193221
if that command runs file from shell, then its a permission issue .. ( i belived)

from shell can you execute that command as a normal user ?? [ not root ]
0
 
LVL 8

Expert Comment

by:mostart
ID: 24193240
try to add "-verbose" to the convert command and see what it tells you then.
Is there anything being done with the images in your command ?
0
 

Author Comment

by:whspider
ID: 24193245
fosiul01

from shell am using the root account but if you see my command am exectuting it for the account xtended.

using shell jo.gif is getting created in home/xtended/public_html....

am new to this... how do i write a php script for this?
0
 

Author Comment

by:whspider
ID: 24193269
it gives the following

array(3) { [0]=> string(88) "/home/xtended/public_html/rose.gif GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" [1]=> string(82) "/home/xtended/public_html/gradient.jpg JPEG 70x40 70x40+0+0 8-bit DirectClass 936b" [2]=> string(125) "/home/xtended/public_html/rose.gif=>/home/xtended/public_html/jo.gif[0] GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" }

am joing the first 2 images and putting themin jo.gif
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24193286
Ok let me try to explain first, then see what happended

from shell when you are executing by root, it has access to eveyr home directory which include xtended

i am gussing xtended is a user of your sytem.


also i am gussing, you are tryign to exeute this command from web site such as

http://localhost/convert.php

if this yes, then
when you are trying to execute this command from http://localhost/convert.php

1. the user would be apache
2. apache normaly would not have permission to read file from /home/extended
3. apache normaly would not have permission to run /usr/local/bin/convert  [ but this one i need check ]


let me know if my guessing is right   , then will try next ....
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24193297
ok try with @mostart solutoin, there is no point of giving 2 different kind of solution

i will keep monitor, if it does not solve the probem then i will take it further
0
 

Author Comment

by:whspider
ID: 24193298
yes am able to execute the same command in shell by loging as a user also
0
 

Author Comment

by:whspider
ID: 24193311
am still facing the same prob....
0
 
LVL 8

Accepted Solution

by:
mostart earned 1200 total points
ID: 24193465
sorry you do need to give us more information in order to help you with this.

If this is what you got by adding the verbose argument:
array(3) { [0]=> string(88) "/home/xtended/public_html/rose.gif GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" [1]=> string(82) "/home/xtended/public_html/gradient.jpg JPEG 70x40 70x40+0+0 8-bit DirectClass 936b" [2]=> string(125) "/home/xtended/public_html/rose.gif=>/home/xtended/public_html/jo.gif[0] GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" }

it tells us the command at least is being executed. So can you tell us if there is an image being created after all ?

The "or die.." part of your script is probably useless as "exec" will probably not return as you expect it to do.
Try checking "return_var" instead (http://de3.php.net/manual/en/function.exec.php)

exec("/usr/local/bin/convert -verbose /home/xtended/public_html/rose.gif /home/xtended/public_html/gradient.jpg /home/xtended/public_html/jo.gif 2>&1",$out,$ret) ;
 
# check $ret later for return value of convert program..
 
var_dump($out);

Open in new window

0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24194705
@author

i have downoad the software in mysystem

and i tryed this command

convert /home/fosiul/rose.GIF /home/fosiul/gradient.JPG /home/fosiul/jo.GIF

this workes perfectly as root

but from php, it does not aswell, as i am suspecting its permission issue , but @mostart has different view.

anyway, can you just do one thing to make sure

<?php
exec("/usr/bin/convert -verbose /home/fosiul/rose.GIF /home/fosiul/gradient.JPG /home/fosiul/jo.GIF",$out) or die("bad command");
?>

put  usr/bin/convert -verbose  ( change the path as your need)

i am executing this command like this  http://localhost/index.php


if you are doing the same thing

can you check the error log for aapche

i am using  redhat 5,
so its

/var/log/httpd/error_log

and in my one i am seeing its saying, permission denyed,

let me know
0
 
LVL 8

Expert Comment

by:mostart
ID: 24194745
well this:

array(3) { [0]=> string(88) "/home/xtended/public_html/rose.gif GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" [1]=> string(82) "/home/xtended/public_html/gradient.jpg JPEG 70x40 70x40+0+0 8-bit DirectClass 936b" [2]=> string(125) "/home/xtended/public_html/rose.gif=>/home/xtended/public_html/jo.gif[0] GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" }

for sure is output of convert program (verbose option lists details about image files that are opened).
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24194805
I dont know how he is execeting that command

is he executing  that from Shell or from php file ....

suppose if i executing this command from shell , i get the following output

 convert -verbose /home/fosiul/rose.GIF /home/fosiul/gradient.JPG /home/fosiul/jo.GIF

/home/fosiul/rose.GIF GIF 132x193 132x193+0+0 8-bit PseudoClass 256c 6.42kb
/home/fosiul/gradient.JPG JPEG 132x193 132x193+0+0 8-bit DirectClass 25.2kb
/home/fosiul/rose.GIF=>/home/fosiul/jo.GIF[0] GIF 132x193 132x193+0+0 8-bit PseudoClass 256c 16kb


but if i execute that commadn( -verbose)  from php file, i get permission denyed. ( which is normal )

0
 
LVL 8

Expert Comment

by:mostart
ID: 24194921
yes you are right but the output he posted was a php var_dump output:


array(3) { [0]=> string(88) "/home/xtended/public_html/rose.gif GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" ....
0
 
LVL 29

Assisted Solution

by:fosiul01
fosiul01 earned 800 total points
ID: 24195075
ommm Ok you are right...
the output posted in PHp,

i am getting error this error

array(3) { [0]=>  string(91) "convert: unable to open image `/apache/rose.GIF': Permission denied @ blob.c/OpenBlob/2439." [1]=>  string(95) "convert: unable to open image `/apache/gradient.JPG': Permission denied @ blob.c/OpenBlob/2439." [2]=>  string(88) "convert: missing an image filename `apache/jo.GIF' @ convert.c/ConvertImageCommand/2775." }

so he must be give permission on /home/xtended/public_html/ to read for apache

ok this quesiton is all YOurs now!!

Thanks anyway
0
 

Author Comment

by:whspider
ID: 24201420
hi am getting the same error

array(4) { [0]=> string(88) "/home/xtended/public_html/rose.gif GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" [1]=> string(82) "/home/xtended/public_html/gradient.jpg JPEG 70x40 70x40+0+0 8-bit DirectClass 936b" [2]=> string(125) "/home/xtended/public_html/rose.gif=>/home/xtended/public_html/jo.gif[0] GIF 128x128 128x128+0+0 8-bit PseudoClass 256c 2.73kb" [3]=> string(107) "convert: unable to open image `/home/xtended/public_html/jo.gif': Permission denied @ blob.c/OpenBlob/2411." }

the jo.gif is the image that is generated dynamically.....it says permission denied.actually jo.gif is the output which is being produced...it will be generated only after the command is executed.....

how doi solve this.....  
0
 

Author Comment

by:whspider
ID: 24201441
am gettin prob with th jo.gif only.......
0
 

Author Comment

by:whspider
ID: 24201446
when i give 2>&1 in the command i get this extra line

[3]=> string(107) "convert: unable to open image `/home/xtended/public_html/jo.gif': Permission denied @ blob.c/OpenBlob/2411." }
0
 

Author Comment

by:whspider
ID: 24201511
thanks i solved it.....It was permission problem only......
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24202072
Hi sorry due to night , did not see your post

and good to see your problem was solved
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question