File: getnumbercolors.php

package info (click to toggle)
php4-imagick 0.9.11-0.2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 720 kB
  • ctags: 755
  • sloc: ansic: 4,373; php: 1,574; sh: 1,226; makefile: 82; awk: 27
file content (28 lines) | stat: -rw-r--r-- 930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?
        $handle = imagick_readimage( getcwd() . "/image.jpg" ) ;
        if ( imagick_iserror( $handle ) )
        {
                $reason      = imagick_failedreason( $handle ) ;
                $description = imagick_faileddescription( $handle ) ;

                print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ;
		exit ;
        }

	//
	//  If you want a histogram of the color distribution written to a
	//  file, specify the file name as the second parameter.
	//

	$numb_colors = imagick_getnumbercolors( $handle, "/dev/null" ) ;
	if ( imagick_iserror( $handle ) )
	{
                $reason      = imagick_failedreason( $handle ) ;
                $description = imagick_faileddescription( $handle ) ;

                print "imagick_getnumbercolors failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ;
		exit ;
	}

	print "Number of colors: $numb_colors<BR>\n" ;
?>