Confused with PHP

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?".
Post Reply
marky
Posts: 5
Joined: 2015-09-30T08:07:51-07:00
Authentication code: 1151

Confused with PHP

Post by marky »

Sorry but I'm new to all of this!

Using Powershell I can find if PDF pages have colour using:

$colour = convert "$PDF" -colorspace HSL -channel G -separate -format %[fx:mean] info:
echo $colour

0 = B/W
>0 = colour

All is well.

I want to do this on my hosted website using PHP but don't know how!

Thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Confused with PHP

Post by snibgo »

I don't do PHP, but the IM PHP forum viewforum.php?f=10 has plenty of examples to get you started. The "exec()" method seems to be easiest.
snibgo's IM pages: im.snibgo.com
marky
Posts: 5
Joined: 2015-09-30T08:07:51-07:00
Authentication code: 1151

Re: Confused with PHP

Post by marky »

Thank you. To get a clearer idea I am using

exec('/usr/bin/convert "logo1.bmp" -colorspace HSL -channel G -separate -thumbnail 200x200 -format %[fx:mean] info: ');
I cannot get the 'info' bit returned. I have already looked through the area you mentioned but could not find anything?
marky
Posts: 5
Joined: 2015-09-30T08:07:51-07:00
Authentication code: 1151

Re: Confused with PHP

Post by marky »

Ok, got it!

exec('/usr/bin/convert "logogrey.bmp" -colorspace HSL -channel G -separate -format %[fx:mean] info:',$return_info );
echo $return_info[0];

It was the [0] bit as it;s an array being returned.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Confused with PHP

Post by Bonzo »

An alternate method:

Code: Select all

$colour = exec('/usr/bin/convert "logogrey.bmp" -colorspace HSL -channel G -separate -format %[fx:mean] info:' );
Post Reply