Command Line to PHP exec

Discussion in 'PHP' started by cyclotron, Mar 15, 2009.

  1. #1
    I need to convert this command line:

    command='convert -delay 20 $original'
    command="$command -background lightblue -bordercolor lightblue -border 5x2"
    
    for i in `seq 100 -4 0;`; do
      command="$command \\( -clone 0 -splice ${i}x0+0+0 "
      command="$command -wave 10x100 -chop ${i}x0+0+0 \\)"
    done
    
    # remove page offsets and delet the original image
    command="$command +repage -delete 0 -loop 0 $finished"
    
    eval $command
    Code (markup):
    Into a PHP exec command..

    for example:(from a different command line)

    system("exec 2>&1; /usr/local/bin/convert -dispose previous -delay 30 \
    bla bla bla bla $finished");
    Code (markup):
    First person to do this for me, working can get $15 paypal :)
     
    cyclotron, Mar 15, 2009 IP
  2. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I haven't tested the script but what is the problem exactly? Getting the output?

    $oput = system("exec 2>&1; /usr/local/bin/convert -dispose previous -delay 30 \
    bla bla bla bla $finished");
    print $oput;
    PHP:
    That what you're looking to do?

    Regards,
    Dennis M.
     
    Dennis M., Mar 15, 2009 IP
  3. cyclotron

    cyclotron Active Member

    Messages:
    213
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    73
    #3
    There is no problem. I just need to implement that first quote into PHP.
    So the user uploads an image and the output is spat out. I already have all this from previous image effects.

    I just need it in PHP format so to stpeak for example (from a diff effect)

     
    cyclotron, Mar 15, 2009 IP
  4. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't think you can pass multiple commands in one call to system(). What do you need the "exec 2>&1;" for? Why not just tack 2>&1 on the end of your convert command?
     
    SmallPotatoes, Mar 16, 2009 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    Is it supposed to create 20+ images ?

    <?
    
    $original = '/paht/to/original.jpg';
    $finished = 'path/to/finished.jpg';
    
    $command = "convert -delay 20 $original -background lightblue -bordercolor lightblue -border 5x2";
    
    for($i = 100; $i >= 0; $i -= 4)
    {
    	$command .= " \\( -clone 0 -splice {$i}x0+0+0 ";
    	$command .= " -wave 10x100 -chop {$i}x0+0+0 \\)";
    }
    
    // remove page offsets and delet the original image
    $command .= " +repage -delete 0 -loop 0 $finished";
    
    exec($command);
    
    ?>
    Code (markup):
     
    joebert, Mar 16, 2009 IP
  6. meannn

    meannn Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I dont know what is exec exactly :)
     
    meannn, Mar 16, 2009 IP
  7. cyclotron

    cyclotron Active Member

    Messages:
    213
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    73
    #7
    How would you do this for statement??

    for i in `seq 10 -2 -8; seq -10 2 8`; do
    command="$command \\( -clone 0 -wave ${i}x150 \\)"
    done
     
    cyclotron, Mar 16, 2009 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    //Edit -- I goofed.
     
    joebert, Mar 16, 2009 IP
  9. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #9
    Whoops, missed that second seq call.

    <?
    $command = '';
    
    foreach(explode("\n", `seq 10 -2 -8; seq -10 2 8`) as $i)
    {
    	$command .= " \\( -clone 0 -wave {$i}x150 \\)";
    }
    
    echo $command;
    ?>
    Code (markup):
     
    joebert, Mar 16, 2009 IP
  10. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #10
    Task finished. :)
     
    joebert, Mar 17, 2009 IP