Fred's ImageMagick Scripts

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
ozdevs
Posts: 1
Joined: 2015-09-23T13:05:35-07:00
Authentication code: 1151

Fred's ImageMagick Scripts

Post by ozdevs »

Hi Fred,

First of all, thanks a lot for sharing all helpful scripts for ImageMagic! I will have a question about 'embroidery effect'.

I uploaded the embroidery file into my server and ran the following bash and similar variations but always failed. It creates the effect but only gray color background but other colors on the CNBC logo. My IM version is 6.7 and tested some of other scripts you shared and worked.


COMMAND I USE:
bash /var/www/html/dashboard/embroidery -n 8 -p 1 -t 2 -i 0 -C 0 /var/www/html/uploads/cnbc.jpg /var/www/html/cnbc3.jpg


INPUT FILE: The input file I used here is the same you are using:
http://www.fmwconcepts.com/imagemagick/ ... s/cnbc.jpg

OUTPUT FILE:
http://52.25.162.129/cnbc3.jpg

Could you please tell me if I am missing something? Your help highly appreciated!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

There was a typo in my argument trapping. It worked fine with the defaults and no arguments specified, but failed when -p was specified. I have fixed that and uploaded a new script. Download that and let me know if that still fails. If so what is your exact version of IM from

convert -version
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

I am also facing the problem with the embroidery image conversion. When I am trying to apply the embroidery effect, only background is converting into the embroidery and rest of the image part became the black. I am using the same cnbc image.http://www.fmwconcepts.com/imagemagick/ ... s/cnbc.jpg.
Please provide me the solution of this issue.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

What is your exact command line? What error messages? What is your version of IM and platform? On what web site is this being used? Did you upgrade the script after I fixed the -p argument as mentioned above?
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

I am using the below logic with the php.
<?php
$path_to_script= dirname(__FILE__)."/embroidery.sh";
exec("$path_to_script -n 8 -p 1 -t 2 -i 0 -C 0 cnbc.jpg cnbc_1.jpg");
exit;
?>

Platform : Linux
Imagemagick version : ImageMagick 6.9.0-3 Q16 x86_64 2015-01-09
I am using the latest embroidery script.
There is no any error message.

Only background converted into embroidery other than that all parts converted into black color.
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

I got below error with junk data. So I have posted error message here.
"sort: write failed: standard output: Broken pipe sort: write error"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

I do not understand your PHP syntax. Try this

<?php
exec("/fullpath2/embroidery -n 8 -p 1 -t 2 /fullpath2/cnbc.jpg /fullpath2/result.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

Do you get any error messages?
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

Yes, We got the same error. Below is the error which we have found with your provided script.

Error:-
sort: write failed: standard output: Broken pipe
sort: write error

Below is the final output after applying the embroidery effect.
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

Do you have the unix command sort available?

What do you get from

Code: Select all

convert cnbc.jpg -format "%c" histogram:info: |\
sort -k 1 -nr | head -n 8 | sed -n "s/^.*\(#.*\) .*$/\1/p"
or

Code: Select all

convert cnbc.jpg -format "%c" histogram:info: | sort -k 1 -nr | head -n 8 | sed -n "s/^.*\(#.*\) .*$/\1/p"
I get

Code: Select all

#FFFFFF
#0A0B0D
#00A13A
#5C4F94
#0070B6
#F5AD00
#BA2342
#E36612
What web site is this for?
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

We found the same colors from the provided the script.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

makwana.ajay wrote:We found the same colors from the provided the script.
Are you saying that the sort worked fine? If so, then I am at a loss to know why the script fails for you, esp, if you have modifed the PATH to include the path to convert.

exec("$path_to_script -n 8 -p 1 -t 2 -i 0 -C 0 cnbc.jpg cnbc_1.jpg");
Are you running the script where the images reside? If not, then you need the path to the images.

try

Code: Select all

exec("bash $path_to_script -n 8 -p 1 -t 2 -i 0 -C 0 cnbc.jpg cnbc_1.jpg");
Does that help?

try editing the sort line in the script at 419/420 to be

Code: Select all

colorArr=(`convert $dir/tmpI.mpc -format "%c" histogram:info:- | sort -k 1 -nr | head -n $numcolors | sed -n "s/^.*\(#.*\) .*$/\1/p"`
Does that make a difference?

Can you test in a terminal window (even on another computer) to see if that works? That will tell us if it is your PHP environment.
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

Hello,
Thank you for your prompt reply and solution. Now the solution works fine with the command prompt but still there is some issue when try to execute the script from the PHP.
Below are the some server configuration.
System :- Linux dnb.com 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64
Apache Version :- Apache/2.2.15 (CentOS)
PHP Version :- 5.3.3

Please look into that and help us to work it with php script.

Thanks a lot.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

Sorry, but I do not know how to configure PHP.

Try

<?php
exec(""bash $path_to_script -n 8 -p 1 -t 2 -i 0 -C 0 cnbc.jpg cnbc_1.jpg 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

Do you get any messages?
makwana.ajay
Posts: 13
Joined: 2015-12-07T07:42:02-07:00
Authentication code: 1151

Re: Fred's ImageMagick Scripts

Post by makwana.ajay »

Yes, we are getting message given below.

sort: write failed: standard output: Broken pipe
sort: write error
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fred's ImageMagick Scripts

Post by fmw42 »

Does this work?

<?php
exec("convert cnbc.jpg -format '%c' histogram:info:- | sort -k 1 -nr | head -n 8 | sed -n 's/^.*\(#.*\) .*$/\1/p' 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

or

<?php
exec("convert cnbc.jpg -format '%c' histogram:info:- | sort -k 1 | head -n 8 | sed -n 's/^.*\(#.*\) .*$/\1/p' 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Post Reply