L
L
ld06872021-05-29 15:24:46
PHP
ld0687, 2021-05-29 15:24:46

How to execute multiline command in PHP?

Good afternoon!

I have a team

convert 1.jpg -resize 700x \
\( -clone 0 -resize 720x1280^ -gravity center -extent 720x1280 -blur 0x8 -blur 0x8 \) \
+swap -gravity Center -compose over -composite \
1.jpg


in the console it works great. But when trying to execute it from PHP via exec(), shell_exec() etc. I get an error -
sh: 2: (: not found
sh: 3: +swap: not found
sh: 4: 1.jpg: not found


tell me how to "feed" this command from php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ld0687, 2021-05-29
@ld0687

It turns out that line breaks do not need to be escaped, but parentheses do.

convert 1.jpg -resize 700x \( -clone 0 -resize 720x1280^ -gravity center -extent 720x1280 -blur 0x8 -blur 0x8 \) +swap -gravity Center -compose over -composite 1.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question