linux command issue

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

linux command issue

Post by javismiles »

hi my friends
i keep going through commands that used to work in windows and dont in linux now,
i have solved most of them, cant make this one, this one adds a shadow to the text, works in windows great, its failing in linux, any ideas why?
all this is from php

$command ='convert -background none -fill "'.$thecolor.'" -font '.$font_selection.' -pointsize '.$thesize.' -gravity '.$thealign.' label:"'.$thetext.'" ( -clone 0 -background black -shadow '.$valsh.' ) -compose DstOver -composite -compose Over -rotate '.$theangle.' '.$target_image.'';

thank u very much
jav
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

this is a clearer example of the command from php in linux

convert -background none -fill "#457654" -font type/arial.ttf -pointsize 20 -gravity West label:"hola" ( -clone 0 -background black -shadow "100x1+2+2)") -compose DstOver -composite -compose Over -rotate 0 e2.png

this works perfect in windows, but not in linux from php
any ideas?
thank u
jav
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

if i try it in the bash


[root@mediaserver site]# convert -background none -fill "#457654" -font type/arial/arial_normal.ttf -pointsize 20 -gravity West label:"hola" ( -clone 0 -background black -shadow "100x1+2+2") -compose DstOver -composite -compose Over -rotate 0 e2.png

-bash: syntax error near unexpected token `('
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: linux command issue

Post by fmw42 »

In unix, you need to use \ to escape the parens \( .... \)

Also there must a space after the ( and before the )
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

if i take the parenthesis away like this

convert -background none -fill "#457654" -font type/arial/arial_normal.ttf -pointsize 20 -gravity West label:"hola" -clone 0 -background black -shadow "100x1+2+2" -compose DstOver -composite -compose Over -rotate 0 e2555.png

then it executes and works but the result of course is wrong as it applies the shadow to the entire word and not to the edge

so the parenthesis are the problem, how do we keep the parenthesis in linux without the bash complaining?
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

yes it works
putting the \ before the (

thank u! :))
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

having similar problem with this one, i put \ in front of the ( but still not working,
i suspect the % signs maybe? what do u think

$command = 'convert '.$source_image.' -fill green -colorize 15% -alpha opaque -sigmoidal-contrast 4x15% -blur 1,0.5 \( +clone -fill white -colorize 100 -background "#cccccc" -vignette 0x35-30-30 \) -compose multiply -composite -quality 70 '.$target_image ;
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

another one that fails and is very simple

$command = "convert ".$source_image." ".$clutimage." -clut ".$target_image ;

this works from the bash
but not from php
any ideas?
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

ok in the first one i showed that doesnt work we have found out that it works if we remove

-alpha opaque

any ideas why?
it works from the bash with -alpha opaque
but from php we need to remove that to make it work, the -alpha opaque

any ideas?
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

so in two of our commands
it seems that it doesnt like from php using

-alpha opaque

and also

-clut

any ideas?
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

apart from

-alpha opaque

and

-clut
giving problems in linux

the other problem i have is this that im using to produce black and white image, in windows works great
-channel R -evaluate multiply .8 -channel G -evaluate multiply .1 -channel B -evaluate multiply .1 +channel -separate -compose add -flatten
but in linux it produces a red image very strange
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: linux command issue

Post by javismiles »

oki another problem

in another of the commands, it only works when we remove -auto-level
any ideas?

so all these commands worked in windows perfect, but in linux they only work if we remove

in one of them removing
-alpha opaque

in another removing
-auto-level

in another removing
-clut

why is this, is this because a library is missing, i dont think so because most of this execute in the bash, not in php, so is it a syntax problem but its so simple
what could it be?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: linux command issue

Post by anthony »

javismiles wrote:having similar problem with this one, i put \ in front of the ( but still not working,
i suspect the % signs maybe? what do u think

$command = 'convert '.$source_image.' -fill green -colorize 15% -alpha opaque -sigmoidal-contrast 4x15% -blur 1,0.5 \( +clone -fill white -colorize 100 -background "#cccccc" -vignette 0x35-30-30 \) -compose multiply -composite -quality 70 '.$target_image ;

NOTE -colorize only takes a percent value, so the '%' flag is not used.

However % has no special meaning to either PHP or linux. so you do not have to double or escape them.
It is # < > ( ) [ ] { } ; & * and all quotes that have a special meaning for shells.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: linux command issue

Post by anthony »

javismiles wrote:another one that fails and is very simple

$command = "convert ".$source_image." ".$clutimage." -clut ".$target_image ;

this works from the bash
but not from php
any ideas?
Actually you have removed all spaces between arguments in the command, so the shell sees...

convert sourceclut-cluttarget

Assuming $source_image = "source" etc...

The shell would pass that to the convert and convert would see only one long argument that does not make sense!

I really suggest you try to get a log of your PHP error returns!!!

See some rough notes I made about this, for another project
http://www.ict.griffith.edu.au/~anthony ... /php.hints
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: linux command issue

Post by anthony »

javismiles wrote:in another of the commands, it only works when we remove -auto-level
any ideas?
Sounds like your version of IM is older than the addition of these operators.

What does convert -version say

Look at convert -list command
and convert -list alpha
etc...

To see what you can list using
convert -list list
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply