Page 1 of 1

Small problem in query: syntax error near unexpected token (

Posted: 2013-10-07T09:07:03-07:00
by class3f
I wrote a command to create four thumbnail of the original image. I run a command in PHP using exec:

Code: Select all

convert /images/*.* 
( -clone 0--1 -strip -thumbnail "68x51^>" -background white -gravity center -extent 68x51 -quality 80 +adjoin -scene 1 -write /images/%d_68x51.jpg -delete 0--1 ) 
( -clone 0--1 -strip -thumbnail "104x78^>" -background white -gravity center -extent 104x78 -quality 80 +adjoin -scene 1 -write /images/%d_104x78.jpg -delete 0--1 ) 
( -clone 0--1 -strip -thumbnail "360x270^>" -background white -gravity center -extent 360x270 -quality 80 +adjoin -scene 1 -write /images/%d_360x270.jpg -delete 0--1 ) 
-strip -thumbnail "1024x768>" -quality 80 +adjoin -scene 1 /images/%d_1024x768.jpg
It seems that is fine, but unfortunately I get the message:

Code: Select all

-bash: syntax error near unexpected token `('
Why is this happening? what's the problem? how to fix it?

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T09:22:44-07:00
by snibgo
I'm not a bash or PHP expert, but I think you need to tell it this is a single command, not a number of commands. For a bash script, you need a "\" character at the end of each line except the last.

You realise, I suppose, that if you successfully run the command twice, you will get a load of weird images in the same directory.

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T09:24:55-07:00
by Bonzo
On Linux you need to escape the ( ) with a \ so it becomes \( \)

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T09:38:47-07:00
by class3f
Thanks for your help, the server made ​​a request. I have another question: Why the query is not removed the original image? I have four thumbnails and full size image...

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T10:51:29-07:00
by fmw42
You did not tell it to delete the originals only the cloned copies of the original. Add -delete 0--2 (I think) before the output or before -scene 1. That way you save the output and delete all the original input images.

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T11:16:05-07:00
by snibgo
class3f may not realise that "-delete" removes images from convert's internal list. It does not delete files.

Re: Small problem in query: syntax error near unexpected tok

Posted: 2013-10-07T11:55:08-07:00
by fmw42
snibgo wrote:class3f may not realise that "-delete" removes images from convert's internal list. It does not delete files.

Yes, by delete, I assume he meant does not write them to output. I presume he did not mean delete from the OS directory.