Book/imagick-Phpdoc专题

图像处理(ImageMagick)

目录

类摘要

Imagick

class Imagick <span class="oointerface">implements <span class="interfacename">Iterator {

public bool adaptiveBlurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool adaptiveResizeImage ( <span class="methodparam">int $columns , int $rows [, bool $bestfit = false [, bool $legacy<span class="initializer"> = false ]] )

public bool adaptiveSharpenImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool adaptiveThresholdImage ( <span class="methodparam">int $width , int $height , int $offset )

public bool addImage ( <span class="methodparam">Imagick $source )

public bool addNoiseImage ( <span class="methodparam">int $noise_type [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool affineTransformImage ( <span class="methodparam">ImagickDraw $matrix )

public bool animateImages ( <span class="methodparam">string $x_server )

public bool annotateImage ( <span class="methodparam">ImagickDraw $draw_settings , <span class="type">float $x , <span class="type">float $y , <span class="type">float $angle , <span class="methodparam">string $text )

public Imagick appendImages ( <span class="methodparam">bool $stack )

public bool autoLevelImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public Imagick averageImages ( <span class="methodparam">void )

public bool blackThresholdImage ( <span class="methodparam">mixed $threshold )

public bool blueShiftImage ([ <span class="methodparam">float $factor<span class="initializer"> = 1.5 ] )

public bool blurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel ] )

public bool borderImage ( <span class="methodparam">mixed $bordercolor , <span class="type">int $width , <span class="methodparam">int $height )

public bool brightnessContrastImage ( <span class="methodparam">float $brightness , float $contrast [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool charcoalImage ( <span class="methodparam">float $radius , float $sigma )

public bool chopImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

public bool clampImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool clear ( <span class="methodparam">void )

public bool clipImage ( <span class="methodparam">void )

public void clipImagePath ( <span class="methodparam">string $pathname , string $inside )

public bool clipPathImage ( <span class="methodparam">string $pathname , bool $inside )

public Imagick clone ( <span class="methodparam">void )

public bool clutImage ( <span class="methodparam">Imagick $lookup_table [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public Imagick coalesceImages ( <span class="methodparam">void )

public bool colorFloodfillImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y )

public bool colorizeImage ( <span class="methodparam">mixed $colorize , mixed $opacity [, <span class="type">bool $legacy = false ] )

public bool colorMatrixImage ( <span class="methodparam">array $color_matrix<span class="initializer"> = Imagick::CHANNEL_DEFAULT )

public Imagick combineImages ( <span class="methodparam">int $channelType )

public bool commentImage ( <span class="methodparam">string $comment )

public array compareImageChannels ( <span class="methodparam">Imagick $image , int $channelType , <span class="type">int $metricType )

public Imagick compareImageLayers ( <span class="methodparam">int $method )

public array compareImages ( <span class="methodparam">Imagick $compare , int $metric )

bool <span class="methodname">compositeImage ( <span class="methodparam">Imagick $composite_object , <span class="type">int $composite , <span class="methodparam">int $x , <span class="methodparam">int $y [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_ALL ] )

public <span class="methodname">__construct ([ <span class="methodparam">mixed $files ] )

public bool contrastImage ( <span class="methodparam">bool $sharpen )

public bool contrastStretchImage ( <span class="methodparam">float $black_point , <span class="type">float $white_point [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool convolveImage ( <span class="methodparam">array $kernel [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public int <span class="methodname">count ([ <span class="type">int $mode = 0 ] )

bool cropImage ( int $width , <span class="type">int $height , <span class="methodparam">int $x , <span class="methodparam">int $y )

bool <span class="methodname">cropThumbnailImage ( <span class="methodparam">int $width , int $height )

public Imagick current ( <span class="methodparam">void )

public bool cycleColormapImage ( <span class="methodparam">int $displace )

public bool decipherImage ( <span class="methodparam">string $passphrase )

public Imagick deconstructImages ( <span class="methodparam">void )

public bool deleteImageArtifact ( <span class="methodparam">string $artifact )

public bool deleteImageProperty ( <span class="methodparam">string $name )

public bool deskewImage ( <span class="methodparam">float $threshold )

public bool despeckleImage ( <span class="methodparam">void )

public bool destroy ( <span class="methodparam">void )

public bool displayImage ( <span class="methodparam">string $servername )

public bool displayImages ( <span class="methodparam">string $servername )

public bool distortImage ( <span class="methodparam">int $method , array $arguments , <span class="type">bool $bestfit )

bool drawImage ( ImagickDraw $draw )

public bool edgeImage ( <span class="methodparam">float $radius )

public bool embossImage ( <span class="methodparam">float $radius , float $sigma )

public bool encipherImage ( <span class="methodparam">string $passphrase )

public bool enhanceImage ( <span class="methodparam">void )

public bool equalizeImage ( <span class="methodparam">void )

public bool evaluateImage ( <span class="methodparam">int $op , <span class="methodparam">float $constant [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public array exportImagePixels ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $width , int $height , string $map , int $STORAGE )

public bool extentImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

public bool filter ( <span class="type">ImagickKernel $ImagickKernel [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_UNDEFINED ] )

public Imagick flattenImages ( <span class="methodparam">void )

public bool flipImage ( <span class="methodparam">void )

public bool floodFillPaintImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $target , <span class="type">int $x , <span class="type">int $y , <span class="type">bool $invert [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool flopImage ( <span class="methodparam">void )

public bool forwardFourierTransformimage ( <span class="methodparam">bool $magnitude )

public bool frameImage ( <span class="methodparam">mixed $matte_color , <span class="type">int $width , <span class="methodparam">int $height , int $inner_bevel , <span class="type">int $outer_bevel )

public bool functionImage ( <span class="methodparam">int $function , array $arguments [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public Imagick fxImage ( <span class="methodparam">string $expression [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool gammaImage ( <span class="methodparam">float $gamma [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool gaussianBlurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public int <span class="methodname">getColorspace ( <span class="methodparam">void )

public int <span class="methodname">getCompression ( <span class="methodparam">void )

public int <span class="methodname">getCompressionQuality ( <span class="methodparam">void )

public <span class="modifier">static string <span class="methodname">getCopyright ( <span class="methodparam">void )

public string getFilename ( <span class="methodparam">void )

public string getFont ( <span class="methodparam">void )

public string getFormat ( <span class="methodparam">void )

public int <span class="methodname">getGravity ( <span class="methodparam">void )

public <span class="modifier">static string <span class="methodname">getHomeURL ( <span class="methodparam">void )

public Imagick getImage ( <span class="methodparam">void )

int <span class="methodname">getImageAlphaChannel ( <span class="methodparam">void )

public string getImageArtifact ( <span class="methodparam">string $artifact )

public string getImageAttribute ( <span class="methodparam">string $key )

public <span class="type">ImagickPixel <span class="methodname">getImageBackgroundColor ( <span class="methodparam">void )

public string getImageBlob ( <span class="methodparam">void )

public array getImageBluePrimary ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getImageBorderColor ( <span class="methodparam">void )

public int <span class="methodname">getImageChannelDepth ( <span class="methodparam">int $channel )

public float getImageChannelDistortion ( <span class="methodparam">Imagick $reference , <span class="type">int $channel , <span class="methodparam">int $metric )

public float getImageChannelDistortions ( <span class="methodparam">Imagick $reference , <span class="type">int $metric [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public array getImageChannelExtrema ( <span class="methodparam">int $channel )

public array getImageChannelKurtosis ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public array getImageChannelMean ( <span class="methodparam">int $channel )

public array getImageChannelRange ( <span class="methodparam">int $channel )

public array getImageChannelStatistics ( <span class="methodparam">void )

public Imagick getImageClipMask ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getImageColormapColor ( <span class="methodparam">int $index )

public int <span class="methodname">getImageColors ( <span class="methodparam">void )

public int <span class="methodname">getImageColorspace ( <span class="methodparam">void )

public int <span class="methodname">getImageCompose ( <span class="methodparam">void )

public int <span class="methodname">getImageCompression ( <span class="methodparam">void )

public int <span class="methodname">getImageCompressionQuality ( <span class="methodparam">void )

public int <span class="methodname">getImageDelay ( <span class="methodparam">void )

public int <span class="methodname">getImageDepth ( <span class="methodparam">void )

public int <span class="methodname">getImageDispose ( <span class="methodparam">void )

public float getImageDistortion ( <span class="methodparam">MagickWand $reference , <span class="type">int $metric )

public array getImageExtrema ( <span class="methodparam">void )

public string getImageFilename ( <span class="methodparam">void )

public string getImageFormat ( <span class="methodparam">void )

public float getImageGamma ( <span class="methodparam">void )

public array getImageGeometry ( <span class="methodparam">void )

public int <span class="methodname">getImageGravity ( <span class="methodparam">void )

public array getImageGreenPrimary ( <span class="methodparam">void )

public int <span class="methodname">getImageHeight ( <span class="methodparam">void )

public array getImageHistogram ( <span class="methodparam">void )

public int <span class="methodname">getImageIndex ( <span class="methodparam">void )

public int <span class="methodname">getImageInterlaceScheme ( <span class="methodparam">void )

public int <span class="methodname">getImageInterpolateMethod ( <span class="methodparam">void )

public int <span class="methodname">getImageIterations ( <span class="methodparam">void )

public int <span class="methodname">getImageLength ( <span class="methodparam">void )

public bool getImageMatte ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getImageMatteColor ( <span class="methodparam">void )

public string getImageMimeType ( <span class="methodparam">void )

public int <span class="methodname">getImageOrientation ( <span class="methodparam">void )

public array getImagePage ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getImagePixelColor ( <span class="methodparam">int $x , <span class="methodparam">int $y )

public string getImageProfile ( <span class="methodparam">string $name )

public array getImageProfiles ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" [, <span class="methodparam">bool $include_values = true ]] )

public array getImageProperties ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" [, <span class="methodparam">bool $include_values = true ]] )

public string getImageProperty ( <span class="methodparam">string $name )

public array getImageRedPrimary ( <span class="methodparam">void )

public Imagick getImageRegion ( <span class="methodparam">int $width , int $height , int $x , int $y )

public int <span class="methodname">getImageRenderingIntent ( <span class="methodparam">void )

array <span class="methodname">getImageResolution ( <span class="methodparam">void )

public string getImagesBlob ( <span class="methodparam">void )

public int <span class="methodname">getImageScene ( <span class="methodparam">void )

public string getImageSignature ( <span class="methodparam">void )

public int <span class="methodname">getImageSize ( <span class="methodparam">void )

public int <span class="methodname">getImageTicksPerSecond ( <span class="methodparam">void )

public float getImageTotalInkDensity ( <span class="methodparam">void )

public int <span class="methodname">getImageType ( <span class="methodparam">void )

int <span class="methodname">getImageUnits ( <span class="methodparam">void )

public int <span class="methodname">getImageVirtualPixelMethod ( <span class="methodparam">void )

public array getImageWhitePoint ( <span class="methodparam">void )

public int <span class="methodname">getImageWidth ( <span class="methodparam">void )

public int <span class="methodname">getInterlaceScheme ( <span class="methodparam">void )

public int <span class="methodname">getIteratorIndex ( <span class="methodparam">void )

public int <span class="methodname">getNumberImages ( <span class="methodparam">void )

public string getOption ( <span class="methodparam">string $key )

public <span class="modifier">static string <span class="methodname">getPackageName ( <span class="methodparam">void )

public array getPage ( <span class="methodparam">void )

public <span class="type">ImagickPixelIterator <span class="methodname">getPixelIterator ( <span class="methodparam">void )

public <span class="type">ImagickPixelIterator <span class="methodname">getPixelRegionIterator ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $columns , int $rows )

public float getPointSize ( <span class="methodparam">void )

public <span class="modifier">static int <span class="methodname">getQuantum ( <span class="methodparam">void )

public <span class="modifier">static array <span class="methodname">getQuantumDepth ( <span class="methodparam">void )

public <span class="modifier">static array <span class="methodname">getQuantumRange ( <span class="methodparam">void )

public <span class="modifier">static string <span class="methodname">getRegistry ( <span class="type">string $key )

public <span class="modifier">static string <span class="methodname">getReleaseDate ( <span class="methodparam">void )

public <span class="modifier">static int <span class="methodname">getResource ( <span class="type">int $type )

public <span class="modifier">static int <span class="methodname">getResourceLimit ( <span class="methodparam">int $type )

public array getSamplingFactors ( <span class="methodparam">void )

public array getSize ( <span class="methodparam">void )

public int <span class="methodname">getSizeOffset ( <span class="methodparam">void )

public <span class="modifier">static array <span class="methodname">getVersion ( <span class="methodparam">void )

public bool haldClutImage ( <span class="methodparam">Imagick $clut [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool hasNextImage ( <span class="methodparam">void )

public bool hasPreviousImage ( <span class="methodparam">void )

public <span class="type">stringfalse <span class="methodname">identifyFormat ( <span class="methodparam">string $embedText )

public array identifyImage ([ <span class="methodparam">bool $appendRawOutput = false ] )

public bool implodeImage ( <span class="methodparam">float $radius )

public bool importImagePixels ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $width , int $height , string $map , int $storage , <span class="type">array $pixels )

public bool inverseFourierTransformImage ( <span class="methodparam">Imagick $complement , <span class="type">bool $magnitude )

public bool labelImage ( <span class="methodparam">string $label )

public bool levelImage ( <span class="methodparam">float $blackPoint , float $gamma , <span class="type">float $whitePoint [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool linearStretchImage ( <span class="methodparam">float $blackPoint , float $whitePoint )

public bool liquidRescaleImage ( <span class="methodparam">int $width , int $height , float $delta_x , <span class="type">float $rigidity )

public <span class="modifier">static array <span class="methodname">listRegistry ( <span class="methodparam">void )

public bool magnifyImage ( <span class="methodparam">void )

public bool mapImage ( <span class="methodparam">Imagick $map , bool $dither )

public bool matteFloodfillImage ( <span class="methodparam">float $alpha , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y )

public bool medianFilterImage ( <span class="methodparam">float $radius )

public Imagick mergeImageLayers ( <span class="methodparam">int $layer_method )

public bool minifyImage ( <span class="methodparam">void )

public bool modulateImage ( <span class="methodparam">float $brightness , float $saturation , <span class="type">float $hue )

public Imagick montageImage ( <span class="methodparam">ImagickDraw $draw , string $tile_geometry , <span class="type">string $thumbnail_geometry , <span class="methodparam">int $mode , <span class="methodparam">string $frame )

public Imagick morphImages ( <span class="methodparam">int $number_frames )

public bool morphology ( <span class="methodparam">int $morphologyMethod , <span class="type">int $iterations , <span class="methodparam">ImagickKernel $ImagickKernel [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public Imagick mosaicImages ( <span class="methodparam">void )

public bool motionBlurImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $angle [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool negateImage ( <span class="methodparam">bool $gray [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

bool newImage ( int $cols , int $rows , mixed $background [, <span class="type">string $format ] )

public bool newPseudoImage ( <span class="methodparam">int $columns , int $rows , string $pseudoString )

public bool nextImage ( <span class="methodparam">void )

public bool normalizeImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool oilPaintImage ( <span class="methodparam">float $radius )

public bool opaquePaintImage ( <span class="methodparam">mixed $target , mixed $fill , float $fuzz , <span class="type">bool $invert [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool optimizeImageLayers ( <span class="methodparam">void )

public bool orderedPosterizeImage ( <span class="methodparam">string $threshold_map [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool paintFloodfillImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool paintOpaqueImage ( <span class="methodparam">mixed $target , mixed $fill , float $fuzz [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool paintTransparentImage ( <span class="methodparam">mixed $target , float $alpha , <span class="type">float $fuzz )

public bool pingImage ( <span class="methodparam">string $filename )

public bool pingImageBlob ( <span class="methodparam">string $image )

public bool pingImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $fileName ] )

public bool polaroidImage ( <span class="methodparam">ImagickDraw $properties , <span class="type">float $angle )

public bool posterizeImage ( <span class="methodparam">int $levels , bool $dither )

public bool previewImages ( <span class="methodparam">int $preview )

public bool previousImage ( <span class="methodparam">void )

public bool profileImage ( <span class="methodparam">string $name , string $profile )

public bool quantizeImage ( <span class="methodparam">int $numberColors , int $colorspace , <span class="type">int $treedepth , <span class="methodparam">bool $dither , bool $measureError )

public bool quantizeImages ( <span class="methodparam">int $numberColors , int $colorspace , <span class="type">int $treedepth , <span class="methodparam">bool $dither , bool $measureError )

public array queryFontMetrics ( <span class="methodparam">ImagickDraw $properties , <span class="type">string $text [, <span class="methodparam">bool $multiline ] )

public <span class="modifier">static array <span class="methodname">queryFonts ([ <span class="type">string $pattern = "*" ] )

public <span class="modifier">static array <span class="methodname">queryFormats ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" ] )

public bool radialBlurImage ( <span class="methodparam">float $angle [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool raiseImage ( <span class="methodparam">int $width , int $height , int $x , int $y , bool $raise )

public bool randomThresholdImage ( <span class="methodparam">float $low , float $high [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool readImage ( <span class="methodparam">string $filename )

bool <span class="methodname">readImageBlob ( <span class="methodparam">string $image [, string $filename ] )

public bool readImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $fileName = null ] )

public bool readImages ( <span class="methodparam">array $filenames )

public bool recolorImage ( <span class="methodparam">array $matrix )

public bool reduceNoiseImage ( <span class="methodparam">float $radius )

public bool remapImage ( <span class="methodparam">Imagick $replacement , <span class="type">int $DITHER )

public bool removeImage ( <span class="methodparam">void )

public string removeImageProfile ( <span class="methodparam">string $name )

public bool render ( <span class="methodparam">void )

public bool resampleImage ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution , <span class="methodparam">int $filter , float $blur )

public bool resetImagePage ( <span class="methodparam">string $page )

public bool resizeImage ( <span class="methodparam">int $columns , int $rows , int $filter , float $blur [, <span class="type">bool $bestfit = false [, <span class="type">bool $legacy = false ]] )

public bool rollImage ( <span class="methodparam">int $x , <span class="methodparam">int $y )

public bool rotateImage ( <span class="methodparam">mixed $background , float $degrees )

public bool rotationalBlurImage ( <span class="methodparam">float $angle [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool roundCorners ( <span class="methodparam">float $x_rounding , float $y_rounding [, <span class="type">float $stroke_width = 10 [, <span class="type">float $displace = 5 [, <span class="type">float $size_correction = -6 ]]] )

public bool sampleImage ( <span class="methodparam">int $columns , int $rows )

public bool scaleImage ( <span class="methodparam">int $cols , <span class="methodparam">int $rows [, bool $bestfit<span class="initializer"> = false [, <span class="methodparam">bool $legacy<span class="initializer"> = false ]] )

public bool segmentImage ( <span class="methodparam">int $COLORSPACE , float $cluster_threshold , <span class="type">float $smooth_threshold [, <span class="methodparam">bool $verbose<span class="initializer"> = false ] )

public bool selectiveBlurImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $threshold [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool separateImageChannel ( <span class="methodparam">int $channel )

public bool sepiaToneImage ( <span class="methodparam">float $threshold )

public bool setBackgroundColor ( <span class="methodparam">mixed $background )

public bool setColorspace ( <span class="methodparam">int $COLORSPACE )

public bool setCompression ( <span class="methodparam">int $compression )

public bool setCompressionQuality ( <span class="methodparam">int $quality )

public bool setFilename ( <span class="methodparam">string $filename )

public bool setFirstIterator ( <span class="methodparam">void )

public bool setFont ( <span class="methodparam">string $font )

public bool setFormat ( <span class="methodparam">string $format )

public bool setGravity ( <span class="methodparam">int $gravity )

public bool setImage ( <span class="methodparam">Imagick $replace )

public bool setImageAlphaChannel ( <span class="methodparam">int $mode )

public bool setImageArtifact ( <span class="methodparam">string $artifact , string $value )

public bool setImageAttribute ( <span class="methodparam">string $key , string $value )

public bool setImageBackgroundColor ( <span class="methodparam">mixed $background )

public bool setImageBias ( <span class="methodparam">float $bias )

public void setImageBiasQuantum ( <span class="methodparam">string $bias )

public bool setImageBluePrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool setImageBorderColor ( <span class="methodparam">mixed $border )

public bool setImageChannelDepth ( <span class="methodparam">int $channel , int $depth )

public bool setImageClipMask ( <span class="methodparam">Imagick $clip_mask )

public bool setImageColormapColor ( <span class="methodparam">int $index , ImagickPixel $color )

public bool setImageColorspace ( <span class="methodparam">int $colorspace )

public bool setImageCompose ( <span class="methodparam">int $compose )

bool <span class="methodname">setImageCompression ( <span class="methodparam">int $compression )

bool <span class="methodname">setImageCompressionQuality ( <span class="methodparam">int $quality )

public bool setImageDelay ( <span class="methodparam">int $delay )

public bool setImageDepth ( <span class="methodparam">int $depth )

public bool setImageDispose ( <span class="methodparam">int $dispose )

public bool setImageExtent ( <span class="methodparam">int $columns , int $rows )

public bool setImageFilename ( <span class="methodparam">string $filename )

bool <span class="methodname">setImageFormat ( <span class="methodparam">string $format )

public bool setImageGamma ( <span class="methodparam">float $gamma )

public bool setImageGravity ( <span class="methodparam">int $gravity )

public bool setImageGreenPrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool setImageIndex ( <span class="methodparam">int $index )

public bool setImageInterlaceScheme ( <span class="methodparam">int $interlace_scheme )

public bool setImageInterpolateMethod ( <span class="methodparam">int $method )

public bool setImageIterations ( <span class="methodparam">int $iterations )

public bool setImageMatte ( <span class="methodparam">bool $matte )

public bool setImageMatteColor ( <span class="methodparam">mixed $matte )

public bool setImageOpacity ( <span class="methodparam">float $opacity )

public bool setImageOrientation ( <span class="methodparam">int $orientation )

public bool setImagePage ( <span class="methodparam">int $width , int $height , int $x , int $y )

public bool setImageProfile ( <span class="methodparam">string $name , string $profile )

public bool setImageProperty ( <span class="methodparam">string $name , string $value )

public bool setImageRedPrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool setImageRenderingIntent ( <span class="methodparam">int $rendering_intent )

public bool setImageResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

public bool setImageScene ( <span class="methodparam">int $scene )

public bool setImageTicksPerSecond ( <span class="methodparam">int $ticks_per_second )

public bool setImageType ( <span class="methodparam">int $image_type )

public bool setImageUnits ( <span class="methodparam">int $units )

public bool setImageVirtualPixelMethod ( <span class="methodparam">int $method )

public bool setImageWhitePoint ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool setInterlaceScheme ( <span class="methodparam">int $interlace_scheme )

public bool setIteratorIndex ( <span class="methodparam">int $index )

public bool setLastIterator ( <span class="methodparam">void )

public bool setOption ( <span class="methodparam">string $key , string $value )

public bool setPage ( <span class="methodparam">int $width , int $height , int $x , int $y )

public bool setPointSize ( <span class="methodparam">float $point_size )

public bool setProgressMonitor ( <span class="methodparam">callable $callback )

public <span class="modifier">static bool <span class="methodname">setRegistry ( <span class="type">string $key , <span class="methodparam">string $value )

public bool setResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

public <span class="modifier">static bool <span class="methodname">setResourceLimit ( <span class="methodparam">int $type , <span class="methodparam">int $limit )

public bool setSamplingFactors ( <span class="methodparam">array $factors )

public bool setSize ( <span class="methodparam">int $columns , int $rows )

public bool setSizeOffset ( <span class="methodparam">int $columns , int $rows , int $offset )

public bool setType ( <span class="methodparam">int $image_type )

public bool shadeImage ( <span class="methodparam">bool $gray , float $azimuth , <span class="type">float $elevation )

public bool shadowImage ( <span class="methodparam">float $opacity , float $sigma , <span class="type">int $x , <span class="type">int $y )

public bool sharpenImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool shaveImage ( <span class="methodparam">int $columns , int $rows )

public bool shearImage ( <span class="methodparam">mixed $background , float $x_shear , <span class="type">float $y_shear )

public bool sigmoidalContrastImage ( <span class="methodparam">bool $sharpen , float $alpha , <span class="type">float $beta [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool sketchImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $angle )

public Imagick smushImages ( <span class="methodparam">bool $stack , int $offset )

public bool solarizeImage ( <span class="methodparam">int $threshold )

public bool sparseColorImage ( <span class="methodparam">int $SPARSE_METHOD , <span class="type">array $arguments [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

public bool spliceImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

public bool spreadImage ( <span class="methodparam">float $radius )

public bool statisticImage ( <span class="methodparam">int $type , <span class="methodparam">int $width , int $height [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public Imagick steganoImage ( <span class="methodparam">Imagick $watermark_wand , <span class="type">int $offset )

public bool stereoImage ( <span class="methodparam">Imagick $offset_wand )

bool <span class="methodname">stripImage ( <span class="methodparam">void )

public Imagick subImageMatch ( <span class="methodparam">Imagick $Imagick [, array &$offset [, <span class="type">float &$similarity ]] )

bool <span class="methodname">swirlImage ( <span class="type">float $degrees )

Imagick <span class="methodname">textureImage ( <span class="type">Imagick $texture_wand )

public bool thresholdImage ( <span class="methodparam">float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool thumbnailImage ( <span class="methodparam">int $columns , int $rows [, bool $bestfit = false [, bool $fill<span class="initializer"> = false [, <span class="methodparam">bool $legacy<span class="initializer"> = false ]]] )

public bool tintImage ( <span class="methodparam">mixed $tint , mixed $opacity [, <span class="type">bool $legacy = false ] )

public string __toString ( <span class="methodparam">void )

public Imagick transformImage ( <span class="methodparam">string $crop , string $geometry )

public bool transformImageColorspace ( <span class="methodparam">int $colorspace )

public bool transparentPaintImage ( <span class="methodparam">mixed $target , float $alpha , <span class="type">float $fuzz , <span class="methodparam">bool $invert )

public bool transposeImage ( <span class="methodparam">void )

public bool transverseImage ( <span class="methodparam">void )

public bool trimImage ( <span class="methodparam">float $fuzz )

public bool uniqueImageColors ( <span class="methodparam">void )

public bool unsharpMaskImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $amount , <span class="methodparam">float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public bool valid ( <span class="methodparam">void )

public bool vignetteImage ( <span class="methodparam">float $blackPoint , float $whitePoint , <span class="type">int $x , <span class="type">int $y )

public bool waveImage ( <span class="methodparam">float $amplitude , float $length )

public bool whiteThresholdImage ( <span class="methodparam">mixed $threshold )

bool <span class="methodname">writeImage ([ <span class="type">string $filename = NULL ] )

public bool writeImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $format ] )

public bool writeImages ( <span class="methodparam">string $filename , bool $adjoin )

public bool writeImagesFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $format ] )

}

Image methods and global methods

The Imagick class has the ability to hold and operate on multiple images simultaneously. This is achieved through an internal stack. There is always an internal pointer that points at the current image. Some functions operate on all images in the Imagick class, but most operate only on the current image in the internal stack. As a convention, method names can contain the word Image to denote they affect only the current image in the stack.

Class Methods

Because there are so many methods, here is a handy list of methods, somewhat reduced to their general purpose:

Image effects Get methods Set methods Read/write images Other
Imagick::adaptiveBlurImage Imagick::getCompression Imagick::setBackgroundColor Imagick::__construct Imagick::clear
Imagick::adaptiveResizeImage Imagick::getFilename Imagick::setCompressionQuality Imagick::addImage Imagick::clone
Imagick::adaptiveSharpenImage Imagick::getFormat Imagick::setCompression Imagick::appendImages Imagick::current
Imagick::adaptiveThresholdImage Imagick::getImageBackgroundColor Imagick::setFilename Imagick::getFilename Imagick::destroy
Imagick::addNoiseImage Imagick::getImageBlob Imagick::getImagesBlob Imagick::setFormat Imagick::getFormat
Imagick::affinetransformimage Imagick::getImageBluePrimary Imagick::setImageBackgroundColor Imagick::getImageFilename Imagick::getHomeURL
Imagick::annotateImage Imagick::getImageBorderColor Imagick::setFirstIterator Imagick::getImageFormat Imagick::commentImage
Imagick::averageImages Imagick::getImageChannelDepth Imagick::setImageBias Imagick::getImage Imagick::getNumberImages
Imagick::blackThresholdImage Imagick::getImageChannelDistortion Imagick::setImageBluePrimary Imagick::setImageFilename Imagick::getReleaseDate
Imagick::blurImage Imagick::getImageChannelExtrema Imagick::setImageBorderColor Imagick::setImageFormat Imagick::getVersion
Imagick::borderImage Imagick::getImageChannelMean Imagick::setImageChannelDepth Imagick::readImageFile Imagick::hasNextImage
Imagick::charcoalImage Imagick::getImageChannelStatistics Imagick::setImageColormapColor Imagick::readImage Imagick::hasPreviousImage
Imagick::chopImage Imagick::getImageColormapColor Imagick::setImageColorSpace Imagick::writeImages Imagick::labelImage
Imagick::clipImage Imagick::getImageColorspace Imagick::setImageCompose Imagick::writeImage Imagick::newImage
Imagick::clipPathImage Imagick::getImageColors Imagick::setImageCompression   Imagick::newPseudoImage
Imagick::coalesceImages Imagick::getImageCompose Imagick::setImageDelay   Imagick::nextImage
Imagick::colorFloodFillImage Imagick::getImageDelay Imagick::setImageDepth   Imagick::pingImageBlob
Imagick::colorizeImage Imagick::getImageDepth Imagick::setImageDispose   Imagick::pingImageFile
Imagick::combineImages Imagick::getImageDispose Imagick::setImageDispose   Imagick::pingImage
Imagick::compareImageChannels Imagick::getImageDistortion Imagick::setImageExtent   Imagick::previousImage
Imagick::compareImageLayers Imagick::getImageExtrema Imagick::setImageFilename   Imagick::profileImage
Imagick::compositeImage Imagick::getImageFilename Imagick::setImageFormat   Imagick::queryFormats
Imagick::contrastImage Imagick::getImageFormat Imagick::setImageGamma   Imagick::removeImageProfile
Imagick::contrastStretchImage Imagick::getImageGamma Imagick::setImageGreenPrimary   Imagick::removeImage
Imagick::convolveImage Imagick::getImageGeometry Imagick::setImageIndex   Imagick::setFirstIterator
Imagick::cropImage Imagick::getImageGreenPrimary Imagick::setImageInterpolateMethod   Imagick::setImageIndex
Imagick::cycleColormapImage Imagick::getImageHeight Imagick::setImageIterations   Imagick::valid
Imagick::deconstructImages Imagick::getImageHistogram Imagick::setImageMatteColor   Imagick::getCopyright
Imagick::drawImage Imagick::getImageIndex Imagick::setImageMatte    
Imagick::edgeImage Imagick::getImageInterlaceScheme Imagick::setImagePage    
Imagick::embossImage Imagick::getImageInterpolateMethod Imagick::setImageProfile    
Imagick::enhanceImage Imagick::getImageIterations Imagick::setImageProperty    
Imagick::equalizeImage Imagick::getImageMatteColor Imagick::setImageRedPrimary    
Imagick::evaluateImage Imagick::getImageMatte Imagick::setImageRenderingIntent    
Imagick::flattenImages Imagick::getImagePage Imagick::setImageResolution    
Imagick::flipImage Imagick::getImagePixelColor Imagick::setImageScene    
Imagick::flopImage Imagick::getImageProfile Imagick::setImageTicksPerSecond    
  Imagick::getImageProperty Imagick::setImageType    
Imagick::fxImage Imagick::getImageRedPrimary Imagick::setImageUnits    
Imagick::gammaImage Imagick::getImageRegion Imagick::setImageVirtualPixelMethod    
Imagick::gaussianBlurImage Imagick::getImageRenderingIntent Imagick::setImageWhitepoint    
Imagick::implodeImage Imagick::getImageResolution Imagick::setInterlaceScheme    
Imagick::levelImage Imagick::getImageScene Imagick::setOption    
Imagick::linearStretchImage Imagick::getImageSignature Imagick::setPage    
Imagick::magnifyImage Imagick::getImageTicksPerSecond Imagick::setResolution    
Imagick::matteFloodFillImage Imagick::getImageTotalInkDensity Imagick::setResourceLimit    
Imagick::medianFilterImage Imagick::getImageType Imagick::setSamplingFactors    
Imagick::minifyImage Imagick::getImageUnits Imagick::setSizeOffset    
Imagick::modulateImage Imagick::getImageVirtualPixelMethod Imagick::setSize    
Imagick::montageImage Imagick::getImageWhitepoint Imagick::setType    
Imagick::morphImages Imagick::getImageWidth      
Imagick::mosaicImages Imagick::getImage      
Imagick::motionBlurImage Imagick::getInterlaceScheme      
Imagick::negateImage Imagick::getNumberImages      
Imagick::normalizeImage Imagick::getOption      
Imagick::oilPaintImage Imagick::getPackageName      
Imagick::optimizeImageLayers Imagick::getPage      
Imagick::paintOpaqueImage Imagick::getPixelIterator      
Imagick::paintTransparentImage Imagick::getPixelRegionIterator      
Imagick::posterizeImage Imagick::getQuantumDepth      
Imagick::radialBlurImage Imagick::getQuantumRange      
Imagick::raiseImage Imagick::getResourceLimit      
Imagick::randomThresholdImage Imagick::getResource      
Imagick::reduceNoiseImage Imagick::getSamplingFactors      
Imagick::render Imagick::getSizeOffset      
Imagick::resampleImage Imagick::getSize      
Imagick::resizeImage Imagick::identifyImage      
Imagick::rollImage Imagick::getImageSize      
Imagick::rotateImage        
Imagick::sampleImage        
Imagick::scaleImage        
Imagick::separateImageChannel        
Imagick::sepiaToneImage        
Imagick::shadeImage        
Imagick::shadowImage        
Imagick::sharpenImage        
Imagick::shaveImage        
Imagick::shearImage        
Imagick::sigmoidalContrastImage        
Imagick::sketchImage        
Imagick::solarizeImage        
Imagick::spliceImage        
Imagick::spreadImage        
Imagick::steganoImage        
Imagick::stereoImage        
Imagick::stripImage        
Imagick::swirlImage        
Imagick::textureImage        
Imagick::thresholdImage        
Imagick::thumbnailImage        
Imagick::tintImage        
Imagick::transverseImage        
Imagick::trimImage        
Imagick::uniqueImageColors        
Imagick::unsharpMaskImage        
Imagick::vignetteImage        
Imagick::waveImage        
Imagick::whiteThresholdImage        

Imagick::adaptiveBlurImage

Adds adaptive blur filter to image

说明

public bool Imagick::adaptiveBlurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Adds an adaptive blur filter to image. The intensity of an adaptive blur depends is dramatically decreased at edge of the image, whereas a standard blur is uniform across the image. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel. Provide a value of 0 and the radius will be chosen automagically.

sigma
The standard deviation of the Gaussian, in pixels.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using <span class="function">Imagick::adaptiveBlurImage:

Adaptively blur an image, then display to the browser.

<?php

header('Content-type: image/jpeg');

$image = new Imagick('test.jpg');

$image->adaptiveBlurImage(5,3);
echo $image;

?>

以上例程的输出类似于:

Output of example : Using Imagick::adaptiveBlurImage()

参见

  • Imagick::blurImage
  • Imagick::motionBlurImage
  • Imagick::radialBlurImage

Imagick::adaptiveResizeImage

Adaptively resize image with data dependent triangulation

说明

public bool Imagick::adaptiveResizeImage ( <span class="methodparam">int $columns , int $rows [, bool $bestfit = false [, bool $legacy<span class="initializer"> = false ]] )

Adaptively resize image with data-dependent triangulation. Avoids blurring across sharp color changes. Most useful when used to shrink images slightly to a slightly smaller "web size"; may not look good when a full-sized image is adaptively resized to a thumbnail. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

Note: 参数 bestfit 的特性在 Imagick 3.0.0 中已改变。在此版本以前,当目标尺寸设为 400x400 时,原尺寸为 200x150 的图像将不会被改变。自 Imagick 3.0.0 起,源图像将会被放大到 400x300 因为这将更好的适合目标尺寸。当使用参数 bestfit 时,必须同时给出宽度和高度。

参数

columns
The number of columns in the scaled image.

rows
The number of rows in the scaled image.

bestfit
Whether to fit the image inside a bounding box.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Added optional fit parameter.
PECL imagick 2.1.0 This method now supports proportional scaling. Pass zero as either parameter for proportional scaling.

范例

示例 #1 Using <span class="function">Imagick::adaptiveResizeImage

Resize an image to a standard size for the web. This method works best when resizing to a size only slightly smaller than the previous image size.

<?php
header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');
$image->adaptiveResizeImage(1024,768);

echo $image;
?>

参见

  • Imagick::chopImage
  • Imagick::cropImage
  • Imagick::magnifyImage
  • Imagick::minifyImage
  • Imagick::resizeImage
  • Imagick::scaleImage
  • Imagick::shaveImage
  • Imagick::thumbnailImage
  • Imagick::trimImage

Imagick::adaptiveSharpenImage

Adaptively sharpen the image

说明

public bool Imagick::adaptiveSharpenImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Adaptively sharpen the image by sharpening more intensely near image edges and less intensely far from edges. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel. Use 0 for auto-select.

sigma
The standard deviation of the Gaussian, in pixels.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 A Imagick::adaptiveSharpenImage example

Adaptively sharpen the image with radius 2 and sigma 1.

<?php
try {
    $image = new Imagick('image.png');
    $image->adaptiveSharpenImage(2,1);
} catch(ImagickException $e) {
    echo 'Error: ' , $e->getMessage();
    die();
}
header('Content-type: image/png');
echo $image;
?>

参见

  • Imagick::sharpenImage

Imagick::adaptiveThresholdImage

Selects a threshold for each pixel based on a range of intensity

说明

public bool Imagick::adaptiveThresholdImage ( <span class="methodparam">int $width , int $height , int $offset )

Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn't contain distinctive peaks.

参数

width
Width of the local neighborhood.

height
Height of the local neighborhood.

offset
The mean offset

返回值

成功时返回 true

范例

示例 #1 <span class="function">Imagick::adaptiveThresholdImage

<?php
function adaptiveThresholdImage($imagePath, $width, $height, $adaptiveOffset) {
    $imagick = new \Imagick(realpath($imagePath));
    $adaptiveOffsetQuantum = intval($adaptiveOffset * \Imagick::getQuantum());
    $imagick->adaptiveThresholdImage($width, $height, $adaptiveOffsetQuantum);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::addImage

Adds new image to Imagick object image list

说明

public bool Imagick::addImage ( <span class="methodparam">Imagick $source )

Adds new image to Imagick object from the current position of the source object. After the operation iterator position is moved at the end of the list.

参数

source
The source Imagick object

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::addNoiseImage

Adds random noise to the image

说明

public bool Imagick::addNoiseImage ( <span class="methodparam">int $noise_type [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Adds random noise to the image.

参数

noise_type
The type of the noise. Refer to this list of noise constants.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 Imagick::addNoiseImage

<?php
function addNoiseImage($noiseType, $imagePath, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->addNoiseImage($noiseType, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::affineTransformImage

Transforms an image

说明

public bool Imagick::affineTransformImage ( <span class="methodparam">ImagickDraw $matrix )

Transforms an image as dictated by the affine matrix.

参数

matrix
The affine matrix

返回值

成功时返回 true

范例

示例 #1 Imagick::affineTransformImage

<?php
function affineTransformImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $draw = new \ImagickDraw();

    $angle = deg2rad(40);

    $affineRotate = array(
        "sx" => cos($angle), "sy" => cos($angle), 
        "rx" => sin($angle), "ry" => -sin($angle), 
        "tx" => 0, "ty" => 0,
    );

    $draw->affine($affineRotate);

    $imagick->affineTransformImage($draw);

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::animateImages

Animates an image or images

说明

public bool Imagick::animateImages ( <span class="methodparam">string $x_server )

This method animates the image onto a local or remote X server. This method is not available on Windows. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

x_server
X server address

返回值

成功时返回 true

参见

  • Imagick::displayImage

Imagick::annotateImage

Annotates an image with text

说明

public bool Imagick::annotateImage ( <span class="methodparam">ImagickDraw $draw_settings , <span class="type">float $x , <span class="type">float $y , <span class="type">float $angle , <span class="methodparam">string $text )

Annotates an image with text.

参数

draw_settings
The ImagickDraw object that contains settings for drawing the text

x
Horizontal offset in pixels to the left of text

y
Vertical offset in pixels to the baseline of text

angle
The angle at which to write the text

text
The string to draw

返回值

成功时返回 true

范例

示例 #1 Using Imagick::annotateImage:

Annotate text on an empty image

<?php
/* Create some objects */
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'gray' );

/* New image */
$image->newImage(800, 75, $pixel);

/* Black text */
$draw->setFillColor('black');

/* Font properties */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 30 );

/* Create text */
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox jumps over the lazy dog');

/* Give image a format */
$image->setImageFormat('png');

/* Output the image with headers */
header('Content-type: image/png');
echo $image;

?>

参见

  • ImagickDraw::annotation
  • ImagickDraw::setFont

Imagick::appendImages

Append a set of images

说明

public Imagick Imagick::appendImages ( <span class="methodparam">bool $stack )

Append a set of images into one larger image.

参数

stack
Whether to stack the images vertically. By default (or if false is specified) images are stacked left-to-right. If stack is true, images are stacked top-to-bottom.

返回值

Returns Imagick instance on success.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::appendImages example

<?php

/* Create new imagick object */
$im = new Imagick();

/* create red, green and blue images */
$im->newImage(100, 50, "red");
$im->newImage(100, 50, "green");
$im->newImage(100, 50, "blue");

/* Append the images into one */
$im->resetIterator();
$combined = $im->appendImages(true);

/* Output the image */
$combined->setImageFormat("png");
header("Content-Type: image/png");
echo $combined;
?>

以上例程的输出类似于:

Output of example : Imagick::appendImages()

Imagick::autoLevelImage

Description

说明

public bool Imagick::autoLevelImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Adjusts the levels of a particular image channel by scaling the minimum and maximum values to the full quantum range.

参数

channel
Which channel should the auto-levelling should be done on.

返回值

成功时返回 true

范例

示例 #1 Imagick::autoLevelImage

<?php
function autoLevelImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->autoLevelImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::averageImages

Average a set of images

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public Imagick Imagick::averageImages ( <span class="methodparam">void )

Average a set of images.

返回值

Returns a new Imagick object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::blackThresholdImage

Forces all pixels below the threshold into black

说明

public bool Imagick::blackThresholdImage ( <span class="methodparam">mixed $threshold )

Is like Imagick::thresholdImage() but forces all pixels below the threshold into black while leaving all pixels above the threshold unchanged.

参数

threshold
The threshold below which everything turns black

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as a parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::blackThresholdImage

<?php
function blackThresholdImage($imagePath, $thresholdColor) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->blackthresholdimage($thresholdColor);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::blueShiftImage

Description

说明

public bool Imagick::blueShiftImage ([ <span class="methodparam">float $factor<span class="initializer"> = 1.5 ] )

Mutes the colors of the image to simulate a scene at nighttime in the moonlight.

参数

factor

返回值

成功时返回 true

范例

示例 #1 Imagick::blueShiftImage

<?php
function blueShiftImage($imagePath, $blueShift) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->blueShiftImage($blueShift);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::blurImage

Adds blur filter to image

说明

public bool Imagick::blurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel ] )

Adds blur filter to image. Optional third parameter to blur a specific channel.

参数

radius
Blur radius

sigma
Standard deviation

channel
The Channeltype constant. When not supplied, all channels are blurred.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::blurImage:

Blur an image, then display to the browser.

<?php

header('Content-type: image/jpeg');

$image = new Imagick('test.jpg');

$image->blurImage(5,3);
echo $image;

?>

参见

  • Imagick::adaptiveBlurImage
  • Imagick::motionBlurImage
  • Imagick::radialBlurImage

Imagick::borderImage

Surrounds the image with a border

说明

public bool Imagick::borderImage ( <span class="methodparam">mixed $bordercolor , <span class="type">int $width , <span class="methodparam">int $height )

Surrounds the image with a border of the color defined by the bordercolor ImagickPixel object.

参数

bordercolor
ImagickPixel object or a string containing the border color

width
Border width

height
Border height

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::borderImage

<?php
function borderImage($imagePath, $color, $width, $height) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->borderImage($color, $width, $height);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::brightnessContrastImage

Description

说明

public bool Imagick::brightnessContrastImage ( <span class="methodparam">float $brightness , float $contrast [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Change the brightness and/or contrast of an image. It converts the brightness and contrast parameters into slope and intercept and calls a polynomical function to apply to the image.

参数

brightness

contrast

channel

返回值

成功时返回 true

范例

示例 #1 <span class="function">Imagick::brightnessContrastImage

<?php
function brightnessContrastImage($imagePath, $brightness, $contrast, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->brightnessContrastImage($brightness, $contrast, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::charcoalImage

Simulates a charcoal drawing

说明

public bool Imagick::charcoalImage ( <span class="methodparam">float $radius , float $sigma )

Simulates a charcoal drawing.

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel

sigma
The standard deviation of the Gaussian, in pixels

返回值

成功时返回 true

范例

示例 #1 Imagick::charcoalImage

<?php
function charcoalImage($imagePath, $radius, $sigma) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->charcoalImage($radius, $sigma);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::chopImage

Removes a region of an image and trims

说明

public bool Imagick::chopImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

Removes a region of an image and collapses the image to occupy the removed portion.

参数

width
Width of the chopped area

height
Height of the chopped area

x
X origo of the chopped area

y
Y origo of the chopped area

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::chopImage:

Example of using Imagick::chopImage

<?php
/* Create some objects */
$image = new Imagick();
$pixel = new ImagickPixel( 'gray' );

/* New image */
$image->newImage(400, 200, $pixel);

/* Chop image */
$image->chopImage(200, 200, 0, 0);

/* Give image a format */
$image->setImageFormat('png');

/* Output the image with headers */
header('Content-type: image/png');
echo $image;

?>

参见

  • Imagick::cropImage

Imagick::clampImage

Description

说明

public bool Imagick::clampImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Restricts the color range from 0 to the quantum depth.

参数

channel

返回值

成功时返回 true, 或者在失败时返回 false

Imagick::clear

Clears all resources associated to Imagick object

说明

public bool Imagick::clear ( <span class="methodparam">void )

Clears all resources associated to Imagick object

返回值

成功时返回 true

Imagick::clipImage

Clips along the first path from the 8BIM profile

说明

public bool Imagick::clipImage ( <span class="methodparam">void )

Clips along the first path from the 8BIM profile, if present.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::clipImagePath

Description

说明

public void Imagick::clipImagePath ( <span class="methodparam">string $pathname , string $inside )

Clips along the named paths from the 8BIM profile, if present. Later operations take effect inside the path. Id may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.

Warning

本函数还未编写文档,仅有参数列表。

参数

pathname

inside

返回值

Imagick::clipPathImage

Clips along the named paths from the 8BIM profile

说明

public bool Imagick::clipPathImage ( <span class="methodparam">string $pathname , bool $inside )

Clips along the named paths from the 8BIM profile, if present. Later operations take effect inside the path. It may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.

参数

pathname
The name of the path

inside
If true later operations take effect inside clipping path. Otherwise later operations take effect outside clipping path.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::clone

Makes an exact copy of the Imagick object

说明

public Imagick Imagick::clone ( <span class="methodparam">void )

Makes an exact copy of the Imagick object.

Warning

This function has been DEPRECATED as of imagick 3.1.0 in favour of using the clone keyword.

范例

示例 #1 Imagick object cloning in different versions of imagick

<?php
// Cloning an Imagick object in imagick 2.x and 3.0:
$newImage = $image->clone();

// Cloning an Imagick object from 3.1.0 on:
$newImage = clone $image;
?>

返回值

A copy of the Imagick object is returned.

更新日志

版本 说明
PECL imagick 3.1.0 The method was deprecated in favour of the clone keyword.

Imagick::clutImage

Replaces colors in the image

说明

public bool Imagick::clutImage ( <span class="methodparam">Imagick $lookup_table [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Replaces colors in the image from a color lookup table. Optional second parameter to replace colors in a specific channel. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

lookup_table
Imagick object containing the color lookup table

channel
The Channeltype constant. When not supplied, default channels are replaced.

返回值

成功时返回 true

范例

示例 #1 Using Imagick::clutImage:

Replace colors in the image from a color lookup table.

<?php
$image = new Imagick('test.jpg');
$clut = new Imagick();
$clut->newImage(1, 1, new ImagickPixel('black'));
$image->clutImage($clut);
$image->writeImage('test_out.jpg');
?>

参见

  • Imagick::adaptiveBlurImage
  • Imagick::motionBlurImage
  • Imagick::radialBlurImage

Imagick::coalesceImages

Composites a set of images

说明

public Imagick Imagick::coalesceImages ( <span class="methodparam">void )

Composites a set of images while respecting any page offsets and disposal methods. GIF, MIFF, and MNG animation sequences typically start with an image background and each subsequent image varies in size and offset. Returns a new Imagick object where each image in the sequence is the same size as the first and composited with the next image in the sequence.

返回值

Returns a new Imagick object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::colorFloodfillImage

Changes the color value of any pixel that matches target

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::colorFloodfillImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y )

Changes the color value of any pixel that matches target and is an immediate neighbor.

参数

fill
ImagickPixel object containing the fill color

fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color for the purposes of the floodfill.

bordercolor
ImagickPixel object containing the border color

x
X start position of the floodfill

y
Y start position of the floodfill

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as first and third parameter. Previous versions allow only an ImagickPixel object.

Imagick::colorizeImage

Blends the fill color with the image

说明

public bool Imagick::colorizeImage ( <span class="methodparam">mixed $colorize , mixed $opacity [, <span class="type">bool $legacy = false ] )

Blends the fill color with each pixel in the image.

参数

colorize
ImagickPixel object or a string containing the colorize color

opacity
ImagickPixel object or an float containing the opacity value. 1.0 is fully opaque and 0.0 is fully transparent.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter and a float representing the opacity value as the second parameter. Previous versions allow only an ImagickPixel objects.

范例

示例 #1 Imagick::colorizeImage

<?php
function colorizeImage($imagePath, $color, $opacity) {
    $imagick = new \Imagick(realpath($imagePath));
    $opacity = $opacity / 255.0;
    $opacityColor = new \ImagickPixel("rgba(0, 0, 0, $opacity)");
    $imagick->colorizeImage($color, $opacityColor);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::colorMatrixImage

Description

说明

public bool Imagick::colorMatrixImage ( <span class="methodparam">array $color_matrix<span class="initializer"> = Imagick::CHANNEL_DEFAULT )

Apply color transformation to an image. The method permits saturation changes, hue rotation, luminance to alpha, and various other effects. Although variable-sized transformation matrices can be used, typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA (or RGBA with offsets). The matrix is similar to those used by Adobe Flash except offsets are in column 6 rather than 5 (in support of CMYKA images) and offsets are normalized (divide Flash offset by 255)

参数

color_matrix

返回值

成功时返回 true

范例

示例 #1 Imagick::colorMatrixImage

<?php
function colorMatrixImage($imagePath, $colorMatrix) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setImageOpacity(1);

    //A color matrix should look like:
    //    $colorMatrix = [
    //        1.5, 0.0, 0.0, 0.0, 0.0, -0.157,
    //        0.0, 1.0, 0.5, 0.0, 0.0, -0.157,
    //        0.0, 0.0, 1.5, 0.0, 0.0, -0.157,
    //        0.0, 0.0, 0.0, 1.0, 0.0,  0.0,
    //        0.0, 0.0, 0.0, 0.0, 1.0,  0.0,
    //        0.0, 0.0, 0.0, 0.0, 0.0,  1.0
    //    ];

    $background = new \Imagick();
    $background->newPseudoImage($imagick->getImageWidth(), $imagick->getImageHeight(),  "pattern:checkerboard");

    $background->setImageFormat('png');

    $imagick->setImageFormat('png');
    $imagick->colorMatrixImage($colorMatrix);

    $background->compositeImage($imagick, \Imagick::COMPOSITE_ATOP, 0, 0);

    header("Content-Type: image/png");
    echo $background->getImageBlob();
}

?>

Imagick::combineImages

Combines one or more images into a single image

说明

public Imagick Imagick::combineImages ( <span class="methodparam">int $channelType )

Combines one or more images into a single image. The grayscale value of the pixels of each image in the sequence is assigned in order to the specified channels of the combined image. The typical ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.

参数

channelType
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::commentImage

Adds a comment to your image

说明

public bool Imagick::commentImage ( <span class="methodparam">string $comment )

Adds a comment to your image.

参数

comment
The comment to add

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::commentImage:

Commenting an image and retrieving the comment:

<?php

/* Create new Imagick object */
$im = new imagick();

/* Create an empty image */
$im->newImage(100, 100, new ImagickPixel("red"));

/* Add comment to the image */
$im->commentImage("Hello World!");

/* Display the comment */
echo $im->getImageProperty("comment");

?>

Imagick::compareImageChannels

Returns the difference in one or more images

说明

public array Imagick::compareImageChannels ( <span class="methodparam">Imagick $image , int $channelType , <span class="type">int $metricType )

Compares one or more images and returns the difference image.

参数

image
Imagick object containing the image to compare.

channelType
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

metricType
One of the metric type constants.

返回值

Array consisting of new_wand and distortion.

错误/异常

错误时抛出 ImagickException。

Imagick::compareImageLayers

Returns the maximum bounding region between images

说明

public Imagick Imagick::compareImageLayers ( <span class="methodparam">int $method )

Compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

method
One of the layer method constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using <span class="function">Imagick::compareImageLayers

Comparing image layers

<?php
/* create new imagick object */
$im = new Imagick("test.gif");

/* optimize the image layers */
$result = $im->compareImageLayers(imagick::LAYERMETHOD_COALESCE);

/* work on the $result */
?>

参见

  • Imagick::optimizeImageLayers
  • Imagick::writeImages
  • Imagick::writeImage

Imagick::compareImages

Compares an image to a reconstructed image

说明

public array Imagick::compareImages ( <span class="methodparam">Imagick $compare , int $metric )

Returns an array containing a reconstructed image and the difference between images.

参数

compare
An image to compare to.

metric
Provide a valid metric type constant. Refer to this list of metric constants.

返回值

Returns an array containing a reconstructed image and the difference between images.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::compareImages:

Compare images and display the reconstructed image

<?php

$image1 = new imagick("image1.png");
$image2 = new imagick("image2.png");

$result = $image1->compareImages($image2, Imagick::METRIC_MEANSQUAREERROR);
$result[0]->setImageFormat("png");

header("Content-Type: image/png");
echo $result[0];

?>

Imagick::compositeImage

把一张图合并到一张图

说明

bool <span class="methodname">Imagick::compositeImage ( <span class="methodparam">Imagick $composite_object , <span class="type">int $composite , <span class="methodparam">int $x , <span class="methodparam">int $y [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_ALL ] )

把一张图合并到另一张图的指定位置

参数

composite_object
用于合并的图片的Imagick对象

composite
合并操作,定义操作常量。 具体请查看 合并操作常量列表

x
相对图像顶点左上位置(0,0)的横坐标

y
相对图像顶点左上位置(0,0)的纵坐标

channel
通过传入一个通道常量,来开启通道模式。为了支持多个通道,可以通过二进制运算的操作来合并多个通道常量。(Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators)可以参考这个列表 通道常量列表.

返回值

成功时返回 true

Imagick::__construct

The Imagick constructor

说明

public <span class="methodname">Imagick::__construct ([ <span class="methodparam">mixed $files ] )

Creates an Imagick instance for a specified image or set of images.

参数

files
The path to an image to load or an array of paths. Paths can include wildcards for file names, or can be URLs.

返回值

Returns a new Imagick object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::contrastImage

Change the contrast of the image

说明

public bool Imagick::contrastImage ( <span class="methodparam">bool $sharpen )

Enhances the intensity differences between the lighter and darker elements of the image. Set sharpen to a value other than 0 to increase the image contrast otherwise the contrast is reduced.

参数

sharpen
The sharpen value

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::contrastImage

<?php
function contrastImage($imagePath, $contrastType) {
    $imagick = new \Imagick(realpath($imagePath));
    if ($contrastType != 2) {
        $imagick->contrastImage($contrastType);
    }

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::contrastStretchImage

Enhances the contrast of a color image

说明

public bool Imagick::contrastStretchImage ( <span class="methodparam">float $black_point , <span class="type">float $white_point [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

black_point
The black point.

white_point
The white point.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Imagick::CHANNEL_ALL. Refer to this list of channel constants.

返回值

成功时返回 true

Imagick::convolveImage

Applies a custom convolution kernel to the image

说明

public bool Imagick::convolveImage ( <span class="methodparam">array $kernel [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Applies a custom convolution kernel to the image.

参数

kernel
The convolution kernel

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::convolveImage

<?php
function convolveImage($imagePath, $bias, $kernelMatrix) {
    $imagick = new \Imagick(realpath($imagePath));    
    //$edgeFindingKernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1,];
    $imagick->setImageBias($bias * \Imagick::getQuantum());
    $imagick->convolveImage($kernelMatrix);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::count

Get the number of images

说明

public int <span class="methodname">Imagick::count ([ <span class="methodparam">int $mode<span class="initializer"> = 0 ] )

Returns the number of images.

参数

mode
An unused argument. Currently there is a non-particularly well defined feature in PHP where calling count() on a countable object might (or might not) require this method to accept a parameter. This parameter is here to be conformant with the interface of countable, even though the param is not used.

返回值

Returns the number of images.

Imagick::cropImage

截图图片的一块区域

说明

bool <span class="methodname">Imagick::cropImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

截图图片的一块区域

参数

width
截图的宽度

height
截图的高度

x
裁剪区域左上角的 X 轴坐标(以原图的左上角为原点)

y
裁剪区域左上角的 X 轴坐标(以原图的左上角为原点)

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::cropImage

<?php
function cropImage($imagePath, $startX, $startY, $width, $height) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->cropImage($width, $height, $startX, $startY);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::cropThumbnailImage

创建缩略图

说明

bool <span class="methodname">Imagick::cropThumbnailImage ( <span class="methodparam">int $width , int $height )

首先将图片放大或者缩小,然后从图片的中间裁剪到指定的的大小。

参数

width
缩略图的宽

height
缩略图的高

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::current

Returns a reference to the current Imagick object

说明

public Imagick Imagick::current ( <span class="methodparam">void )

Returns reference to the current imagick object with image pointer at the correct sequence.

返回值

Returns self on success.

错误/异常

错误时抛出 ImagickException。

Imagick::cycleColormapImage

Displaces an image's colormap

说明

public bool Imagick::cycleColormapImage ( <span class="methodparam">int $displace )

Displaces an image's colormap by a given number of positions. If you cycle the colormap a number of times you can produce a psychedelic effect.

参数

displace
The amount to displace the colormap.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::decipherImage

Deciphers an image

说明

public bool Imagick::decipherImage ( <span class="methodparam">string $passphrase )

Deciphers image that has been enciphered before. The image must be enciphered using Imagick::encipherImage. 此方法在Imagick基于ImageMagick 6.3.9以上版本编译时可用。

参数

passphrase
The passphrase

返回值

成功时返回 true

参见

  • Imagick::encipherImage

Imagick::deconstructImages

Returns certain pixel differences between images

说明

public Imagick Imagick::deconstructImages ( <span class="methodparam">void )

Compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers.

返回值

Returns a new Imagick object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::deleteImageArtifact

Delete image artifact

说明

public bool Imagick::deleteImageArtifact ( <span class="methodparam">string $artifact )

Deletes an artifact associated with the image. The difference between image properties and image artifacts is that properties are public and artifacts are private. 此方法在Imagick基于ImageMagick 6.5.7以上版本编译时可用。

参数

artifact
The name of the artifact to delete

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::setImageArtifact
  • Imagick::getImageArtifact

Imagick::deleteImageProperty

Description

说明

public bool Imagick::deleteImageProperty ( <span class="methodparam">string $name )

Deletes an image property.

参数

name
The name of the property to delete.

返回值

成功时返回 true

Imagick::deskewImage

Removes skew from the image

说明

public bool Imagick::deskewImage ( <span class="methodparam">float $threshold )

This method can be used to remove skew from for example scanned images where the paper was not properly placed on the scanning surface. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

threshold
Deskew threshold

返回值

范例

示例 #1 Imagick::deskewImage

<?php
function deskewImage($threshold) {
    $imagick = new \Imagick(realpath("images/NYTimes-Page1-11-11-1918.jpg"));
    $deskewImagick = clone $imagick;

    //This is the only thing required for deskewing.
    $deskewImagick->deskewImage($threshold);

    //The rest of this example is to make the result obvious - because
    //otherwise the result is not obvious.
    $trim = 9;

    $deskewImagick->cropImage($deskewImagick->getImageWidth() - $trim, $deskewImagick->getImageHeight(), $trim, 0);
    $imagick->cropImage($imagick->getImageWidth() - $trim, $imagick->getImageHeight(), $trim, 0);
    $deskewImagick->resizeimage($deskewImagick->getImageWidth() / 2, $deskewImagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1);
    $imagick->resizeimage($imagick->getImageWidth() / 2, $imagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1);
    $newCanvas = new \Imagick();
    $newCanvas->newimage($imagick->getImageWidth() + $deskewImagick->getImageWidth() + 20, $imagick->getImageHeight(), 'red', 'jpg');
    $newCanvas->compositeimage($imagick, \Imagick::COMPOSITE_COPY, 5, 0);
    $newCanvas->compositeimage($deskewImagick, \Imagick::COMPOSITE_COPY, $imagick->getImageWidth() + 10, 0);

    header("Content-Type: image/jpg");
    echo $newCanvas->getImageBlob();
}

?>

Imagick::despeckleImage

Reduces the speckle noise in an image

说明

public bool Imagick::despeckleImage ( <span class="methodparam">void )

Reduces the speckle noise in an image while preserving the edges of the original image.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::despeckleImage

<?php
function despeckleImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->despeckleImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::destroy

Destroys the Imagick object

说明

public bool Imagick::destroy ( <span class="methodparam">void )

Destroys the Imagick object and frees all resources associated with it. This method is deprecated in favour of Imagick::clear.

返回值

成功时返回 true

Imagick::displayImage

Displays an image

说明

public bool Imagick::displayImage ( <span class="methodparam">string $servername )

This method displays an image on a X server.

参数

servername
The X server name

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::displayImages

Displays an image or image sequence

说明

public bool Imagick::displayImages ( <span class="methodparam">string $servername )

Displays an image or image sequence on a X server.

参数

servername
The X server name

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::distortImage

Distorts an image using various distortion methods

说明

public bool Imagick::distortImage ( <span class="methodparam">int $method , array $arguments , <span class="type">bool $bestfit )

Distorts an image using various distortion methods, by mapping color lookups of the source image to a new destination image usually of the same size as the source image, unless 'bestfit' is set to true.

If 'bestfit' is enabled, and distortion allows it, the destination image is adjusted to ensure the whole source 'image' will just fit within the final destination image, which will be sized and offset accordingly. Also in many cases the virtual offset of the source image will be taken into account in the mapping.

此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

method
The method of image distortion. See distortion constants

arguments
The arguments for this distortion method

bestfit
Attempt to resize destination to fit distorted source

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::distortImage:

Distort an image and display to the browser.

<?php
/* Create new object */
$im = new Imagick();

/* Create new checkerboard pattern */
$im->newPseudoImage(100, 100, "pattern:checkerboard");

/* Set the image format to png */
$im->setImageFormat('png');

/* Fill new visible areas with transparent */
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

/* Activate matte */
$im->setImageMatte(true);

/* Control points for the distortion */
$controlPoints = array( 10, 10, 
                        10, 5,

                        10, $im->getImageHeight() - 20,
                        10, $im->getImageHeight() - 5,

                        $im->getImageWidth() - 10, 10,
                        $im->getImageWidth() - 10, 20,

                        $im->getImageWidth() - 10, $im->getImageHeight() - 10,
                        $im->getImageWidth() - 10, $im->getImageHeight() - 30);

/* Perform the distortion */                       
$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);

/* Ouput the image */
header("Content-Type: image/png");
echo $im;
?>

以上例程的输出类似于:

Output of example : Using Imagick::distortImage()

参见

  • Imagick::blurImage
  • Imagick::motionBlurImage
  • Imagick::radialBlurImage

Imagick::drawImage

把 ImagickDraw 对象渲染到当前图片上

说明

bool <span class="methodname">Imagick::drawImage ( <span class="methodparam">ImagickDraw $draw )

把 ImagickDraw 对象渲染到当前图片上。

参数

draw
被渲染到图片上的 ImagickDraw 对象(在经过各种绘画操作之后的 ImagickDraw 对象)

返回值

成功时返回 true

Imagick::edgeImage

Enhance edges within the image

说明

public bool Imagick::edgeImage ( <span class="methodparam">float $radius )

Enhance edges within the image with a convolution filter of the given radius. Use radius 0 and it will be auto-selected.

参数

radius
The radius of the operation.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::edgeImage

<?php
function edgeImage($imagePath, $radius) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->edgeImage($radius);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::embossImage

Returns a grayscale image with a three-dimensional effect

说明

public bool Imagick::embossImage ( <span class="methodparam">float $radius , float $sigma )

Returns a grayscale image with a three-dimensional effect. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and it will choose a suitable radius for you.

参数

radius
The radius of the effect

sigma
The sigma of the effect

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::embossImage

<?php
function embossImage($imagePath, $radius, $sigma) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->embossImage($radius, $sigma);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::encipherImage

Enciphers an image

说明

public bool Imagick::encipherImage ( <span class="methodparam">string $passphrase )

Converts plain pixels to enciphered pixels. The image is not readable until it has been deciphered using <span class="function">Imagick::decipherImage 此方法在Imagick基于ImageMagick 6.3.9以上版本编译时可用。

参数

passphrase
The passphrase

返回值

成功时返回 true

参见

  • Imagick::decipherImage

Imagick::enhanceImage

Improves the quality of a noisy image

说明

public bool Imagick::enhanceImage ( <span class="methodparam">void )

Applies a digital filter that improves the quality of a noisy image.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::enhanceImage

<?php
function enhanceImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->enhanceImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::equalizeImage

Equalizes the image histogram

说明

public bool Imagick::equalizeImage ( <span class="methodparam">void )

Equalizes the image histogram.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::equalizeImage

<?php
function equalizeImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->equalizeImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::evaluateImage

Applies an expression to an image

说明

public bool Imagick::evaluateImage ( <span class="methodparam">int $op , <span class="methodparam">float $constant [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Applys an arithmetic, relational, or logical expression to an image. Use these operators to lighten or darken an image, to increase or decrease contrast in an image, or to produce the "negative" of an image.

参数

op
The evaluation operator

constant
The value of the operator

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

范例

示例 #1 Using Imagick::evaluateImage

Using evaluateImage to reduce opacity in an image.

<?php
// Create new object with the image
$im = new Imagick('example-alpha.png');

// Reduce the alpha by 50%
$im->evaluateImage(Imagick::EVALUATE_DIVIDE, 2, Imagick::CHANNEL_ALPHA);

// Output the image
header("Content-Type: image/png");
echo $im;
?>

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::exportImagePixels

Exports raw image pixels

说明

public array Imagick::exportImagePixels ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $width , int $height , string $map , int $STORAGE )

Exports image pixels into an array. The map defines the ordering of the exported pixels. The size of the returned array is width * height * strlen(map). 此方法在Imagick基于ImageMagick 6.4.7以上版本编译时可用。

参数

x
X-coordinate of the exported area

y
Y-coordinate of the exported area

width
Width of the exported aread

height
Height of the exported area

map
Ordering of the exported pixels. For example "RGB". Valid characters for the map are R, G, B, A, O, C, Y, M, K, I and P.

STORAGE
Refer to this list of pixel type constants

范例

示例 #1 Using <span class="function">Imagick::exportImagePixels

Export image pixels into an array

<?php

/* Create new object */
$im = new Imagick();

/* Create new image */
$im->newPseudoImage(0, 0, "magick:rose");

/* Export the image pixels */
$pixels = $im->exportImagePixels(10, 10, 2, 2, "RGB", Imagick::PIXEL_CHAR);

/* Output */
var_dump($pixels);
?>

以上例程会输出:

array(12) {
  [0]=>
  int(72)
  [1]=>
  int(64)
  [2]=>
  int(57)
  [3]=>
  int(69)
  [4]=>
  int(59)
  [5]=>
  int(43)
  [6]=>
  int(124)
  [7]=>
  int(120)
  [8]=>
  int(-96)
  [9]=>
  int(91)
  [10]=>
  int(84)
  [11]=>
  int(111)
}

返回值

Returns an array containing the pixels values.

错误/异常

错误时抛出 ImagickException。

Imagick::extentImage

Set image size

说明

public bool Imagick::extentImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

Comfortability method for setting image size. The method sets the image size and allows setting x,y coordinates where the new area begins. 此方法在Imagick基于ImageMagick 6.3.1以上版本编译时可用。

Caution

Prior to ImageMagick 6.5.7-8 (1623), $x was positive when shifting to the left and negative when shifting to the right, and $y was positive when shifting an image up and negative when shifting an image down. Somewhere betwen ImageMagick 6.3.7 (1591) and ImageMagick 6.5.7-8 (1623), the axes of $x and $y were flipped, so that $x was negative when shifting to the left and positive when shifting to the right, and $y was negative when shifting an image up and positive when shifting an image down. Somewhere between ImageMagick 6.5.7-8 (1623) and ImageMagick 6.6.9-7 (1641), the axes of $x and $y were flipped back to pre-ImageMagick 6.5.7-8 (1623) functionality.

参数

width
The new width

height
The new height

x
X position for the new size

y
Y position for the new size

返回值

成功时返回 true

参见

  • Imagick::resizeImage
  • Imagick::thumbnailImage
  • Imagick::cropImage

Imagick::filter

Description

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::filter ( <span class="methodparam">ImagickKernel $ImagickKernel [, <span class="type">int $channel = Imagick::CHANNEL_UNDEFINED ] )

Applies a custom convolution kernel to the image.

参数

ImagickKernel
An instance of ImagickKernel that represents either a single kernel or a linked series of kernels.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 Imagick::filter

<?php
function filter($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $matrix = [
        [-1, 0, -1],
        [0,  5,  0],
        [-1, 0, -1],
    ];

    $kernel = \ImagickKernel::fromMatrix($matrix);
    $strength = 0.5;    
    $kernel->scale($strength, \Imagick::NORMALIZE_KERNEL_VALUE);    
    $kernel->addUnityKernel(1 - $strength);

    $imagick->filter($kernel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::flattenImages

Merges a sequence of images

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public Imagick Imagick::flattenImages ( <span class="methodparam">void )

Merges a sequence of images. This is useful for combining Photoshop layers into a single image.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::flipImage

Creates a vertical mirror image

说明

public bool Imagick::flipImage ( <span class="methodparam">void )

Creates a vertical mirror image by reflecting the pixels around the central x-axis.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::flipImage

<?php
function flipImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->flipImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::floodFillPaintImage

Changes the color value of any pixel that matches target

说明

public bool Imagick::floodFillPaintImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $target , <span class="type">int $x , <span class="type">int $y , <span class="type">bool $invert [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Changes the color value of any pixel that matches target and is an immediate neighbor. This method is a replacement for deprecated <span class="function">Imagick::paintFloodFillImage. 此方法在Imagick基于ImageMagick 6.3.8以上版本编译时可用。

参数

fill
ImagickPixel object or a string containing the fill color

fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color.

target
ImagickPixel object or a string containing the target color to paint

x
X start position of the floodfill

y
Y start position of the floodfill

invert
If true paints any pixel that does not match the target color.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 Imagick::floodfillPaintImage example

<?php

/* Create new imagick object */
$im = new Imagick();

/* create red, green and blue images */
$im->newImage(100, 50, "red");
$im->newImage(100, 50, "green");
$im->newImage(100, 50, "blue");

/* Append the images into one */
$im->resetIterator();
$combined = $im->appendImages(true);

/* Save the intermediate image for comparison */
$combined->writeImage("floodfillpaint_intermediate.png");

/* The target pixel to paint */
$x = 1;
$y = 1;

/* Get the color we are painting */
$target = $combined->getImagePixelColor($x, $y);

/* Paints pixel in position 1,1 black and all neighboring 
   pixels that match the target color */
$combined->floodfillPaintImage("black", 1, $target, $x, $y, false);

/* Save the result */
$combined->writeImage("floodfillpaint_result.png");
?>

以上例程的输出类似于:

Output of example : Imagick::floodfillPaintImage() Output of example : Imagick::floodfillPaintImage()

Imagick::flopImage

Creates a vertical mirror image

说明

public bool Imagick::flopImage ( <span class="methodparam">void )

Creates a vertical mirror image by reflecting the pixels around the central y-axis.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::flopImage

<?php
function flopImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->flopImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::forwardFourierTransformImage

Description

说明

public bool Imagick::forwardFourierTransformimage ( bool $magnitude )

Implements the discrete Fourier transform (DFT) of the image either as a magnitude / phase or real / imaginary image pair.

参数

magnitude
If true, return as magnitude / phase pair otherwise a real / imaginary image pair.

返回值

成功时返回 true

范例

示例 #1 <span class="function">Imagick::forwardFourierTransformImage

<?php
//Utility function for forwardTransformImage
function createMask() {
    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(0);
    $draw->setStrokeColor('rgb(255, 255, 255)');
    $draw->setFillColor('rgb(255, 255, 255)');

    //Draw a circle on the y-axis, with it's centre
    //at x, y that touches the origin
    $draw->circle(250, 250, 220, 250);

    $imagick = new \Imagick();
    $imagick->newImage(512, 512, "black");
    $imagick->drawImage($draw);
    $imagick->gaussianBlurImage(20, 20);
    $imagick->autoLevelImage();

    return $imagick;
}


function forwardFourierTransformImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->resizeimage(512, 512, \Imagick::FILTER_LANCZOS, 1);

    $mask = createMask();
    $imagick->forwardFourierTransformImage(true);

    @$imagick->setimageindex(0);
    $magnitude = $imagick->getimage();

    @$imagick->setimageindex(1);
    $imagickPhase = $imagick->getimage();

    if (true) {
        $imagickPhase->compositeImage($mask, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
    }

    if (false) {
        $output = clone $imagickPhase;
        $output->setimageformat('png');
        header("Content-Type: image/png");
        echo $output->getImageBlob();
    }

    $magnitude->inverseFourierTransformImage($imagickPhase, true);

    $magnitude->setimageformat('png');
    header("Content-Type: image/png");
    echo $magnitude->getImageBlob();
}

?>

Imagick::frameImage

Adds a simulated three-dimensional border

说明

public bool Imagick::frameImage ( <span class="methodparam">mixed $matte_color , <span class="type">int $width , <span class="methodparam">int $height , int $inner_bevel , <span class="type">int $outer_bevel )

Adds a simulated three-dimensional border around the image. The width and height specify the border width of the vertical and horizontal sides of the frame. The inner and outer bevels indicate the width of the inner and outer shadows of the frame.

参数

matte_color
ImagickPixel object or a string representing the matte color

width
The width of the border

height
The height of the border

inner_bevel
The inner bevel width

outer_bevel
The outer bevel width

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::frameImage

<?php
function frameImage($imagePath, $color, $width, $height, $innerBevel, $outerBevel) {
    $imagick = new \Imagick(realpath($imagePath));

    $width = $width + $innerBevel + $outerBevel;
    $height = $height + $innerBevel + $outerBevel;

    $imagick->frameimage(
        $color,
        $width,
        $height,
        $innerBevel,
        $outerBevel
    );
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::functionImage

Applies a function on the image

说明

public bool Imagick::functionImage ( <span class="methodparam">int $function , array $arguments [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Applies an arithmetic, relational, or logical expression to a pseudo image.

See also » ImageMagick v6 Examples - Image Transformations — Function, Multi-Argument Evaluate

此方法在Imagick基于ImageMagick 6.4.9以上版本编译时可用。

参数

function
Refer to this list of function constants

arguments
Array of arguments to pass to this function.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Create a sinusoidal gradient

<?php
$imagick = new Imagick();
$imagick->newPseudoImage(200, 200, 'gradient:black-white');
$arguments = array(3, -90);
$imagick->functionImage(Imagick::FUNCTION_SINUSOID, $arguments);

header("Content-Type: image/png");
$imagick->setImageFormat("png");
echo $imagick->getImageBlob();
?>

以上例程的输出类似于:

Output of create a sinusoidal gradient

示例 #2 Create a gradient from the polynomial (4x^2 - 4x + 1)

<?php
$imagick = new Imagick();
$imagick->newPseudoImage(200, 200, 'gradient:black-white');
$arguments = array(4, -4, 1);
$imagick->functionImage(Imagick::FUNCTION_POLYNOMIAL, $arguments);

header("Content-Type: image/png");
$imagick->setimageformat("png");
echo $imagick->getImageBlob();
?>

以上例程的输出类似于:

Output of create a polynomial gradient

**示例 #3 Create a complex gradient from the polynomial (4x^2 - 4x^2 +

  1. modulated by a sinusoidal gradient**
<?php
$imagick1 = new Imagick();
$imagick1->newPseudoImage(200, 200, 'gradient:black-white');
$arguments = array(9, -90);
$imagick1->functionImage(Imagick::FUNCTION_SINUSOID, $arguments);

$imagick2 = new Imagick();
$imagick2->newPseudoImage(200, 200, 'gradient:black-white');
$arguments = array(0.5, 0);
$imagick2->functionImage(Imagick::FUNCTION_SINUSOID, $arguments);
$imagick1->compositeimage($imagick2, Imagick::COMPOSITE_MULTIPLY, 0, 0);

header("Content-Type: image/png");
$imagick1->setImageFormat("png");
echo $imagick1->getImageBlob();
?>

以上例程的输出类似于:

Output of create complex gradient

Imagick::fxImage

Evaluate expression for each pixel in the image

说明

public Imagick Imagick::fxImage ( <span class="methodparam">string $expression [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Evaluate expression for each pixel in the image. Consult » The Fx Special Effects Image Operator for more information.

参数

expression
The expression.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::fxImage

<?php
function fxImage() {
    $imagick = new \Imagick();
    $imagick->newPseudoImage(200, 200, "xc:white");

    $fx = 'xx=i-w/2; yy=j-h/2; rr=hypot(xx,yy); (.5-rr/140)*1.2+.5';
    $fxImage = $imagick->fxImage($fx);

    header("Content-Type: image/png");
    $fxImage->setimageformat('png');
    echo $fxImage->getImageBlob();
}

?>

Imagick::gammaImage

Gamma-corrects an image

说明

public bool Imagick::gammaImage ( <span class="methodparam">float $gamma [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Gamma-corrects an image. The same image viewed on different devices will have perceptual differences in the way the image's intensities are represented on the screen. Specify individual gamma levels for the red, green, and blue channels, or adjust all three with the gamma parameter. Values typically range from 0.8 to 2.3.

参数

gamma
The amount of gamma-correction.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::gammaImage

<?php
function gammaImage($imagePath, $gamma, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->gammaImage($gamma, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::gaussianBlurImage

Blurs an image

说明

public bool Imagick::gaussianBlurImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Blurs an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and selects a suitable radius for you.

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel.

sigma
The standard deviation of the Gaussian, in pixels.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::gaussianBlurImage

<?php
function gaussianBlurImage($imagePath, $radius, $sigma, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->gaussianBlurImage($radius, $sigma, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::getColorspace

Gets the colorspace

说明

public int <span class="methodname">Imagick::getColorspace ( <span class="methodparam">void )

Gets the global colorspace value. 此方法在Imagick基于ImageMagick 6.5.7以上版本编译时可用。

返回值

Returns an integer which can be compared against COLORSPACE constants.

Imagick::getCompression

Gets the object compression type

说明

public int <span class="methodname">Imagick::getCompression ( <span class="methodparam">void )

Gets the object compression type.

返回值

Returns the compression constant

Imagick::getCompressionQuality

Gets the object compression quality

说明

public int <span class="methodname">Imagick::getCompressionQuality ( <span class="methodparam">void )

Gets the object compression quality.

返回值

Returns integer describing the compression quality

Imagick::getCopyright

Returns the ImageMagick API copyright as a string

说明

public <span class="modifier">static string <span class="methodname">Imagick::getCopyright ( <span class="methodparam">void )

Returns the ImageMagick API copyright as a string.

返回值

Returns a string containing the copyright notice of Imagemagick and Magickwand C API.

Imagick::getFilename

The filename associated with an image sequence

说明

public string Imagick::getFilename ( <span class="methodparam">void )

Returns the filename associated with an image sequence.

返回值

Returns a string on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getFont

Gets font

说明

public string Imagick::getFont ( <span class="methodparam">void )

Returns the objects font property. 此方法在Imagick基于ImageMagick 6.3.7以上版本编译时可用。

返回值

Returns the string containing the font name or false if not font is set.

参见

  • Imagick::setFont
  • ImagickDraw::setFont
  • ImagickDraw::getFont

Imagick::getFormat

Returns the format of the Imagick object

说明

public string Imagick::getFormat ( <span class="methodparam">void )

Returns the format of the Imagick object.

返回值

Returns the format of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getGravity

Gets the gravity

说明

public int <span class="methodname">Imagick::getGravity ( <span class="methodparam">void )

Gets the global gravity property for the Imagick object. 此方法在Imagick基于ImageMagick 6.4.0以上版本编译时可用。

返回值

Returns the gravity property. Refer to the list of gravity constants.

Imagick::getHomeURL

Returns the ImageMagick home URL

说明

public <span class="modifier">static string <span class="methodname">Imagick::getHomeURL ( <span class="methodparam">void )

Returns the ImageMagick home URL.

返回值

Returns a link to the imagemagick homepage.

Imagick::getImage

Returns a new Imagick object

说明

public Imagick Imagick::getImage ( <span class="methodparam">void )

Returns a new Imagick object with the current image sequence.

返回值

Returns a new Imagick object with the current image sequence.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageAlphaChannel

获取图像的 alpha 通道

说明

int <span class="methodname">Imagick::getImageAlphaChannel ( <span class="methodparam">void )

获取图像的alpha通道值,为以下常量之一 alpha channel constants. 此方法在Imagick基于ImageMagick 6.4.0以上版本编译时可用。

返回值

返回当前图像的alpha通道值,该值是一个常量。该参考常量列表 alpha channel constants.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageArtifact

Get image artifact

说明

public string Imagick::getImageArtifact ( <span class="methodparam">string $artifact )

Gets an artifact associated with the image. The difference between image properties and image artifacts is that properties are public and artifacts are private. 此方法在Imagick基于ImageMagick 6.5.7以上版本编译时可用。

参数

artifact
The name of the artifact

返回值

Returns the artifact value on success.

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::setImageArtifact
  • Imagick::deleteImageArtifact

Imagick::getImageAttribute

Description

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public string Imagick::getImageAttribute ( <span class="methodparam">string $key )

Returns a named attribute.

参数

key
The key of the attribute to get.

返回值

Imagick::getImageBackgroundColor

Returns the image background color

说明

public <span class="type">ImagickPixel <span class="methodname">Imagick::getImageBackgroundColor ( <span class="methodparam">void )

Returns the image background color.

返回值

Returns an ImagickPixel set to the background color of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageBlob

Returns the image sequence as a blob

说明

public string Imagick::getImageBlob ( <span class="methodparam">void )

Implements direct to memory image formats. It returns the image sequence as a string. The format of the image determines the format of the returned blob (GIF, JPEG, PNG, etc.). To return a different image format, use Imagick::setImageFormat().

返回值

Returns a string containing the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageBluePrimary

Returns the chromaticy blue primary point

说明

public array Imagick::getImageBluePrimary ( <span class="methodparam">void )

Returns the chromaticity blue primary point for the image.

参数

x
The chromaticity blue primary x-point.

y
The chromaticity blue primary y-point.

返回值

Array consisting of "x" and "y" coordinates of point.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageBorderColor

Returns the image border color

说明

public <span class="type">ImagickPixel <span class="methodname">Imagick::getImageBorderColor ( <span class="methodparam">void )

Returns the image border color.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelDepth

Gets the depth for a particular image channel

说明

public int <span class="methodname">Imagick::getImageChannelDepth ( <span class="methodparam">int $channel )

Gets the depth for a particular image channel.

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

Imagick::getImageChannelDistortion

Compares image channels of an image to a reconstructed image

说明

public float Imagick::getImageChannelDistortion ( Imagick $reference , <span class="type">int $channel , <span class="methodparam">int $metric )

Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metric.

参数

reference
Imagick object to compare to.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

metric
One of the metric type constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelDistortions

Gets channel distortions

说明

public float Imagick::getImageChannelDistortions ( Imagick $reference , <span class="type">int $metric [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metrics 此方法在Imagick基于ImageMagick 6.4.4以上版本编译时可用。

参数

reference
Imagick object containing the reference image

metric
Refer to this list of metric type constants.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

Returns a double describing the channel distortion.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelExtrema

Gets the extrema for one or more image channels

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public array Imagick::getImageChannelExtrema ( <span class="methodparam">int $channel )

Gets the extrema for one or more image channels. Return value is an associative array with the keys "minima" and "maxima".

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelKurtosis

The getImageChannelKurtosis purpose

说明

public array Imagick::getImageChannelKurtosis ([ int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Get the kurtosis and skewness of a specific channel. 此方法在Imagick基于ImageMagick 6.4.9以上版本编译时可用。

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

Returns an array with kurtosis and skewness members.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelMean

Gets the mean and standard deviation

说明

public array Imagick::getImageChannelMean ( <span class="methodparam">int $channel )

Gets the mean and standard deviation of one or more image channels.

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

Returns an array with "mean" and "standardDeviation" members.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelRange

Gets channel range

说明

public array Imagick::getImageChannelRange ( <span class="methodparam">int $channel )

Gets the range for one or more image channels. 此方法在Imagick基于ImageMagick 6.4.0以上版本编译时可用。

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

Returns an array containing minima and maxima values of the channel(s).

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelStatistics

Returns statistics for each channel in the image

说明

public array Imagick::getImageChannelStatistics ( void )

Returns statistics for each channel in the image. The statistics include the channel depth, its minima and maxima, the mean, and the standard deviation.

返回值

成功时返回 true

Imagick::getImageClipMask

Gets image clip mask

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public Imagick Imagick::getImageClipMask ( <span class="methodparam">void )

Returns the image clip mask. The clip mask is an Imagick object containing the clip mask. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

返回值

Returns an Imagick object containing the clip mask.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageColormapColor

Returns the color of the specified colormap index

说明

public <span class="type">ImagickPixel <span class="methodname">Imagick::getImageColormapColor ( <span class="methodparam">int $index )

Returns the color of the specified colormap index.

参数

index
The offset into the image colormap.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::getImageColors

Gets the number of unique colors in the image

说明

public int <span class="methodname">Imagick::getImageColors ( <span class="methodparam">void )

Gets the number of unique colors in the image.

返回值

Returns an int, the number of unique colors in the image.

Imagick::getImageColorspace

Gets the image colorspace

说明

public int <span class="methodname">Imagick::getImageColorspace ( <span class="methodparam">void )

Gets the image colorspace.

返回值

Returns an integer which can be compared against COLORSPACE constants.

Imagick::getImageCompose

Returns the composite operator associated with the image

说明

public int <span class="methodname">Imagick::getImageCompose ( <span class="methodparam">void )

Returns the composite operator associated with the image.

返回值

成功时返回 true

Imagick::getImageCompression

Gets the current image's compression type

说明

public int <span class="methodname">Imagick::getImageCompression ( <span class="methodparam">void )

Gets the current image's compression type.

返回值

Returns the compression constant

Imagick::getImageCompressionQuality

Gets the current image's compression quality

说明

public int <span class="methodname">Imagick::getImageCompressionQuality ( <span class="methodparam">void )

Gets the current image's compression quality

返回值

Returns integer describing the images compression quality

Imagick::getImageDelay

Gets the image delay

说明

public int <span class="methodname">Imagick::getImageDelay ( <span class="methodparam">void )

Gets the image delay.

返回值

Returns the image delay.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageDepth

Gets the image depth

说明

public int <span class="methodname">Imagick::getImageDepth ( <span class="methodparam">void )

Gets the image depth.

返回值

The image depth.

Imagick::getImageDispose

Gets the image disposal method

说明

public int <span class="methodname">Imagick::getImageDispose ( <span class="methodparam">void )

Gets the image disposal method.

返回值

Returns the dispose method on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageDistortion

Compares an image to a reconstructed image

说明

public float Imagick::getImageDistortion ( <span class="methodparam">MagickWand $reference , <span class="type">int $metric )

Compares an image to a reconstructed image and returns the specified distortion metric.

参数

reference
Imagick object to compare to.

metric
One of the metric type constants.

返回值

Returns the distortion metric used on the image (or the best guess thereof).

错误/异常

错误时抛出 ImagickException。

Imagick::getImageExtrema

Gets the extrema for the image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public array Imagick::getImageExtrema ( <span class="methodparam">void )

Gets the extrema for the image. Returns an associative array with the keys "min" and "max".

返回值

Returns an associative array with the keys "min" and "max".

错误/异常

错误时抛出 ImagickException。

Imagick::getImageFilename

Returns the filename of a particular image in a sequence

说明

public string Imagick::getImageFilename ( <span class="methodparam">void )

Returns the filename of a particular image in a sequence.

返回值

Returns a string with the filename of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageFormat

Returns the format of a particular image in a sequence

说明

public string Imagick::getImageFormat ( <span class="methodparam">void )

Returns the format of a particular image in a sequence.

返回值

Returns a string containing the image format on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageGamma

Gets the image gamma

说明

public float Imagick::getImageGamma ( <span class="methodparam">void )

Gets the image gamma.

返回值

Returns the image gamma on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageGeometry

Gets the width and height as an associative array

说明

public array Imagick::getImageGeometry ( <span class="methodparam">void )

Returns the width and height as an associative array.

返回值

Returns an array with the width/height of the image.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::getImageGeometry

<?php
function getImageGeometry($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::getImageGravity

Gets the image gravity

说明

public int <span class="methodname">Imagick::getImageGravity ( <span class="methodparam">void )

Gets the current gravity value of the image. Unlike <span class="function">Imagick::getGravity, this method returns the gravity defined for the current image sequence. 此方法在Imagick基于ImageMagick 6.4.4以上版本编译时可用。

返回值

Returns the images gravity property. Refer to the list of gravity constants.

Imagick::getImageGreenPrimary

Returns the chromaticy green primary point

说明

public array Imagick::getImageGreenPrimary ( <span class="methodparam">void )

Returns the chromaticity green primary point. Returns an array with the keys "x" and "y".

返回值

Returns an array with the keys "x" and "y" on success, throws an ImagickException on failure.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageHeight

Returns the image height

说明

public int <span class="methodname">Imagick::getImageHeight ( <span class="methodparam">void )

Returns the image height.

返回值

Returns the image height in pixels.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageHistogram

Gets the image histogram

说明

public array Imagick::getImageHistogram ( <span class="methodparam">void )

Returns the image histogram as an array of ImagickPixel objects.

返回值

Returns the image histogram as an array of ImagickPixel objects.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Generates <span class="function">Imagick::getImageHistogram

<?php
function getColorStatistics($histogramElements, $colorChannel) {
    $colorStatistics = [];

    foreach ($histogramElements as $histogramElement) {
        $color = $histogramElement->getColorValue($colorChannel);
        $color = intval($color * 255);
        $count = $histogramElement->getColorCount();

        if (array_key_exists($color, $colorStatistics)) {
            $colorStatistics[$color] += $count;
        }
        else {
            $colorStatistics[$color] = $count;
        }
    }

    ksort($colorStatistics);

    return $colorStatistics;
}



function getImageHistogram($imagePath) {

    $backgroundColor = 'black';

    $draw = new \ImagickDraw();
    $draw->setStrokeWidth(0); //make the lines be as thin as possible

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    $histogramWidth = 256;
    $histogramHeight = 100; // the height for each RGB segment

    $imagick = new \Imagick(realpath($imagePath));
    //Resize the image to be small, otherwise PHP tends to run out of memory
    //This might lead to bad results for images that are pathologically 'pixelly'
    $imagick->adaptiveResizeImage(200, 200, true);
    $histogramElements = $imagick->getImageHistogram();

    $histogram = new \Imagick();
    $histogram->newpseudoimage($histogramWidth, $histogramHeight * 3, 'xc:black');
    $histogram->setImageFormat('png');

    $getMax = function ($carry, $item)  {
        if ($item > $carry) {
            return $item;
        }
        return $carry;
    };

    $colorValues = [
        'red' => getColorStatistics($histogramElements, \Imagick::COLOR_RED),
        'lime' => getColorStatistics($histogramElements, \Imagick::COLOR_GREEN),
        'blue' => getColorStatistics($histogramElements, \Imagick::COLOR_BLUE),
    ];

    $max = array_reduce($colorValues['red'] , $getMax, 0);
    $max = array_reduce($colorValues['lime'] , $getMax, $max);
    $max = array_reduce($colorValues['blue'] , $getMax, $max);

    $scale =  $histogramHeight / $max;

    $count = 0;
    foreach ($colorValues as $color => $values) {
        $draw->setstrokecolor($color);

        $offset = ($count + 1) * $histogramHeight;

        foreach ($values as $index => $value) {
            $draw->line($index, $offset, $index, $offset - ($value * $scale));
        }
        $count++;
    }

    $histogram->drawImage($draw);

    header( "Content-Type: image/png" );
    echo $histogram;
}

?>

Imagick::getImageIndex

Gets the index of the current active image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public int <span class="methodname">Imagick::getImageIndex ( <span class="methodparam">void )

Returns the index of the current active image within the Imagick object. This method has been deprecated. See <span class="function">Imagick::getIteratorIndex.

返回值

Returns an integer containing the index of the image in the stack.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageInterlaceScheme

Gets the image interlace scheme

说明

public int <span class="methodname">Imagick::getImageInterlaceScheme ( <span class="methodparam">void )

Gets the image interlace scheme.

返回值

Returns the interlace scheme as an integer on success. 错误时抛出 <span class="classname">ImagickException。

Imagick::getImageInterpolateMethod

Returns the interpolation method

说明

public int <span class="methodname">Imagick::getImageInterpolateMethod ( <span class="methodparam">void )

Returns the interpolation method for the specified image. The method is one of the *`Imagick::INTERPOLATE_`** constants.

返回值

Returns the interpolate method on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageIterations

Gets the image iterations

说明

public int <span class="methodname">Imagick::getImageIterations ( <span class="methodparam">void )

Gets the image iterations.

返回值

Returns the image iterations as an integer.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageLength

Returns the image length in bytes

说明

public int <span class="methodname">Imagick::getImageLength ( <span class="methodparam">void )

Returns the image length in bytes

返回值

Returns an int containing the current image size.

范例

示例 #1 Using <span class="function">Imagick::getImageLength:

Getting image length in bytes

<?php
$image = new Imagick('test.jpg');
echo $image->getImageLength() . ' bytes';
?>

Imagick::getImageMatte

Return if the image has a matte channel

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::getImageMatte ( <span class="methodparam">void )

Returns true if the image has a matte channel otherwise false. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

成功时返回 true

Imagick::getImageMatteColor

Returns the image matte color

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public <span class="type">ImagickPixel <span class="methodname">Imagick::getImageMatteColor ( <span class="methodparam">void )

Returns the image matte color.

返回值

Returns ImagickPixel object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageMimeType

Description

说明

public string Imagick::getImageMimeType ( <span class="methodparam">void )

Returns the image mime-type.

参数

此函数没有参数。

返回值

Imagick::getImageOrientation

Gets the image orientation

说明

public int <span class="methodname">Imagick::getImageOrientation ( <span class="methodparam">void )

Gets the image orientation. The return value is one of the orientation constants.

返回值

Returns an int on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImagePage

Returns the page geometry

说明

public array Imagick::getImagePage ( <span class="methodparam">void )

Returns the page geometry associated with the image in an array with the keys "width", "height", "x", and "y".

返回值

Returns the page geometry associated with the image in an array with the keys "width", "height", "x", and "y".

错误/异常

错误时抛出 ImagickException。

Imagick::getImagePixelColor

Returns the color of the specified pixel

说明

public <span class="type">ImagickPixel <span class="methodname">Imagick::getImagePixelColor ( <span class="methodparam">int $x , <span class="methodparam">int $y )

Returns the color of the specified pixel.

参数

x
The x-coordinate of the pixel

y
The y-coordinate of the pixel

返回值

Returns an ImagickPixel instance for the color at the coordinates given.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageProfile

Returns the named image profile

说明

public string Imagick::getImageProfile ( <span class="methodparam">string $name )

Returns the named image profile.

参数

name
The name of the profile to return.

返回值

Returns a string containing the image profile.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageProfiles

Returns the image profiles

说明

public array Imagick::getImageProfiles ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" [, <span class="methodparam">bool $include_values = true ]] )

Returns all associated profiles that match the pattern. If false is passed as second parameter only the profile names are returned. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

pattern
The pattern for profile names.

include_values
Whether to return only profile names. If false then only profile names will be returned.

返回值

Returns an array containing the image profiles or profile names.

Imagick::getImageProperties

Returns the image properties

说明

public array Imagick::getImageProperties ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" [, <span class="methodparam">bool $include_values = true ]] )

Returns all associated properties that match the pattern. If false is passed as second parameter only the property names are returned. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

pattern
The pattern for property names.

include_values
Whether to return only property names. If false then only property names will be returned.

返回值

Returns an array containing the image properties or property names.

范例

示例 #1 Using <span class="function">Imagick::getImageProperties:

An example of extracting EXIF information.

<?php

/* Create the object */
$im = new imagick("/path/to/example.jpg");

/* Get the EXIF information */
$exifArray = $im->getImageProperties("exif:*");

/* Loop trough the EXIF properties */
foreach ($exifArray as $name => $property)
{
    echo "{$name} => {$property}<br />\n"; 
}

?>

Imagick::getImageProperty

Returns the named image property

说明

public string Imagick::getImageProperty ( <span class="methodparam">string $name )

Returns the named image property. 此方法在Imagick基于ImageMagick 6.3.2以上版本编译时可用。

参数

name
name of the property (for example Exif:DateTime)

范例

示例 #1 Using <span class="function">Imagick::getImageProperty:

Setting and getting image property

<?php
$image = new Imagick();
$image->newImage(300, 200, "black");

$image->setImageProperty('Exif:Make', 'Imagick');
echo $image->getImageProperty('Exif:Make');
?>

参见

  • Imagick::setImageProperty

返回值

Returns a string containing the image property, false if a property with the given name does not exist.

Imagick::getImageRedPrimary

Returns the chromaticity red primary point

说明

public array Imagick::getImageRedPrimary ( <span class="methodparam">void )

Returns the chromaticity red primary point as an array with the keys "x" and "y".

返回值

Returns the chromaticity red primary point as an array with the keys "x" and "y". 错误时抛出 ImagickException

错误/异常

错误时抛出 ImagickException。

Imagick::getImageRegion

Extracts a region of the image

说明

public Imagick Imagick::getImageRegion ( <span class="methodparam">int $width , int $height , int $x , int $y )

Extracts a region of the image and returns it as a new Imagick object.

参数

width
The width of the extracted region.

height
The height of the extracted region.

x
X-coordinate of the top-left corner of the extracted region.

y
Y-coordinate of the top-left corner of the extracted region.

返回值

Extracts a region of the image and returns it as a new wand.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageRenderingIntent

Gets the image rendering intent

说明

public int <span class="methodname">Imagick::getImageRenderingIntent ( <span class="methodparam">void )

Gets the image rendering intent.

返回值

Returns the image rendering intent.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageResolution

获取图像的x,y轴分辨率

说明

array <span class="methodname">Imagick::getImageResolution ( <span class="methodparam">void )

获取图像的x,y轴分辨率

返回值

返回分辨率值的数组

错误/异常

错误时抛出 ImagickException。

Imagick::getImagesBlob

Returns all image sequences as a blob

说明

public string Imagick::getImagesBlob ( <span class="methodparam">void )

Implements direct to memory image formats. It returns all image sequences as a string. The format of the image determines the format of the returned blob (GIF, JPEG, PNG, etc.). To return a different image format, use Imagick::setImageFormat().

返回值

Returns a string containing the images. On failure, throws ImagickException.

Imagick::getImageScene

Gets the image scene

说明

public int <span class="methodname">Imagick::getImageScene ( <span class="methodparam">void )

Gets the image scene.

返回值

Returns the image scene.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageSignature

Generates an SHA-256 message digest

说明

public string Imagick::getImageSignature ( <span class="methodparam">void )

Generates an SHA-256 message digest for the image pixel stream.

返回值

Returns a string containing the SHA-256 hash of the file.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageSize

Returns the image length in bytes

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public int <span class="methodname">Imagick::getImageSize ( <span class="methodparam">void )

Returns the image length in bytes. Deprecated in favour of Imagick::getImageLength()

返回值

Returns an int containing the current image size.

Imagick::getImageTicksPerSecond

Gets the image ticks-per-second

说明

public int <span class="methodname">Imagick::getImageTicksPerSecond ( <span class="methodparam">void )

Gets the image ticks-per-second.

返回值

Returns the image ticks-per-second.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageTotalInkDensity

Gets the image total ink density

说明

public float Imagick::getImageTotalInkDensity ( <span class="methodparam">void )

Gets the image total ink density.

返回值

Returns the image total ink density of the image. 错误时抛出 <span class="classname">ImagickException。

Imagick::getImageType

Gets the potential image type

说明

public int <span class="methodname">Imagick::getImageType ( <span class="methodparam">void )

Gets the potential image type.

返回值

Returns the potential image type.

  • imagick::IMGTYPE_UNDEFINED
  • imagick::IMGTYPE_BILEVEL
  • imagick::IMGTYPE_GRAYSCALE
  • imagick::IMGTYPE_GRAYSCALEMATTE
  • imagick::IMGTYPE_PALETTE
  • imagick::IMGTYPE_PALETTEMATTE
  • imagick::IMGTYPE_TRUECOLOR
  • imagick::IMGTYPE_TRUECOLORMATTE
  • imagick::IMGTYPE_COLORSEPARATION
  • imagick::IMGTYPE_COLORSEPARATIONMATTE
  • imagick::IMGTYPE_OPTIMIZE

错误/异常

错误时抛出 ImagickException。

Imagick::getImageUnits

获取图像的分辨率单位

说明

int <span class="methodname">Imagick::getImageUnits ( <span class="methodparam">void )

获取图像的分辨率单位。

返回值

返回分辨率的单位

错误/异常

错误时抛出 ImagickException。

Imagick::getImageVirtualPixelMethod

Returns the virtual pixel method

说明

public int <span class="methodname">Imagick::getImageVirtualPixelMethod ( <span class="methodparam">void )

Returns the virtual pixel method for the specified image.

返回值

Returns the virtual pixel method on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageWhitePoint

Returns the chromaticity white point

说明

public array Imagick::getImageWhitePoint ( <span class="methodparam">void )

Returns the chromaticity white point as an associative array with the keys "x" and "y".

返回值

Returns the chromaticity white point as an associative array with the keys "x" and "y".

错误/异常

错误时抛出 ImagickException。

Imagick::getImageWidth

Returns the image width

说明

public int <span class="methodname">Imagick::getImageWidth ( <span class="methodparam">void )

Returns the image width.

返回值

Returns the image width.

错误/异常

错误时抛出 ImagickException。

Imagick::getInterlaceScheme

Gets the object interlace scheme

说明

public int <span class="methodname">Imagick::getInterlaceScheme ( <span class="methodparam">void )

Gets the object interlace scheme.

返回值

Gets the wand interlace scheme.

错误/异常

错误时抛出 ImagickException。

Imagick::getIteratorIndex

Gets the index of the current active image

说明

public int <span class="methodname">Imagick::getIteratorIndex ( <span class="methodparam">void )

Returns the index of the current active image within the Imagick object. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

Returns an integer containing the index of the image in the stack.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using <span class="function">Imagick::getIteratorIndex:

Create images, set and get the iterator index

<?php
$im = new Imagick();
$im->newImage(100, 100, new ImagickPixel("red"));
$im->newImage(100, 100, new ImagickPixel("green"));
$im->newImage(100, 100, new ImagickPixel("blue"));

$im->setIteratorIndex(1);
echo $im->getIteratorIndex();
?>

参见

  • Imagick::setIteratorIndex
  • Imagick::getImageIndex
  • Imagick::setImageIndex

Imagick::getNumberImages

Returns the number of images in the object

说明

public int <span class="methodname">Imagick::getNumberImages ( <span class="methodparam">void )

Returns the number of images associated with Imagick object.

返回值

Returns the number of images associated with Imagick object.

错误/异常

错误时抛出 ImagickException。

Imagick::getOption

Returns a value associated with the specified key

说明

public string Imagick::getOption ( <span class="methodparam">string $key )

Returns a value associated within the object for the specified key.

参数

key
The name of the option

返回值

Returns a value associated with a wand and the specified key.

错误/异常

错误时抛出 ImagickException。

Imagick::getPackageName

Returns the ImageMagick package name

说明

public <span class="modifier">static string <span class="methodname">Imagick::getPackageName ( <span class="methodparam">void )

Returns the ImageMagick package name.

返回值

Returns the ImageMagick package name as a string.

错误/异常

错误时抛出 ImagickException。

Imagick::getPage

Returns the page geometry

说明

public array Imagick::getPage ( <span class="methodparam">void )

Returns the page geometry associated with the Imagick object in an associative array with the keys "width", "height", "x", and "y".

返回值

Returns the page geometry associated with the Imagick object in an associative array with the keys "width", "height", "x", and "y", throwing ImagickException on error.

Imagick::getPixelIterator

Returns a MagickPixelIterator

说明

public <span class="type">ImagickPixelIterator <span class="methodname">Imagick::getPixelIterator ( <span class="methodparam">void )

Returns a MagickPixelIterator.

返回值

Returns an ImagickPixelIterator on success.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::getPixelIterator

<?php
function getPixelIterator($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imageIterator = $imagick->getPixelIterator();

    foreach ($imageIterator as $row => $pixels) { /* Loop through pixel rows */
        foreach ($pixels as $column => $pixel) { /* Loop through the pixels in the row (columns) */
            /** @var $pixel \ImagickPixel */
            if ($column % 2) {
                $pixel->setColor("rgba(0, 0, 0, 0)"); /* Paint every second pixel black*/
            }
        }
        $imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
    }

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

Imagick::getPixelRegionIterator

Get an ImagickPixelIterator for an image section

说明

public <span class="type">ImagickPixelIterator <span class="methodname">Imagick::getPixelRegionIterator ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $columns , int $rows )

Get an ImagickPixelIterator for an image section.

参数

x
The x-coordinate of the region.

y
The y-coordinate of the region.

columns
The width of the region.

rows
The height of the region.

返回值

Returns an ImagickPixelIterator for an image section.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 <span class="methodname">Imagick::getPixelRegionIterator example

Iterate over the pixels in the top left of the image, changing them to be black.

<?php
$im = new Imagick(realpath("./testImage.png"));
$areaIterator = $im->getPixelRegionIterator(0, 0, 10, 10);

foreach ($areaIterator as $rowIterator) {
    foreach ($rowIterator as $pixel) {
        // Paint every pixel black
        $pixel->setColor("rgba(0, 0, 0, 0)");
    }
    $areaIterator->syncIterator();
}
$im->writeImage("./output.png");
?>

Imagick::getPointSize

Gets point size

说明

public float Imagick::getPointSize ( <span class="methodparam">void )

Returns the objects point size property. 此方法在Imagick基于ImageMagick 6.3.7以上版本编译时可用。

返回值

Returns a float containing the point size.

参见

  • Imagick::setPointSize

Imagick::getQuantum

Description

说明

public <span class="modifier">static int <span class="methodname">Imagick::getQuantum ( <span class="methodparam">void )

Returns the ImageMagick quantum range as an integer.

参数

此函数没有参数。

返回值

Imagick::getQuantumDepth

Gets the quantum depth

说明

public <span class="modifier">static array <span class="methodname">Imagick::getQuantumDepth ( <span class="methodparam">void )

Returns the Imagick quantum depth.

返回值

Returns an array with "quantumDepthLong" and "quantumDepthString" members.

错误/异常

错误时抛出 ImagickException。

Imagick::getQuantumRange

Returns the Imagick quantum range

说明

public <span class="modifier">static array <span class="methodname">Imagick::getQuantumRange ( <span class="methodparam">void )

Returns the quantum range for the Imagick instance.

返回值

Returns an associative array containing the quantum range as an <span class="type">int ("quantumRangeLong") and as a <span class="type">string ("quantumRangeString").

错误/异常

错误时抛出 ImagickException。

Imagick::getRegistry

Description

说明

public <span class="modifier">static string <span class="methodname">Imagick::getRegistry ( <span class="methodparam">string $key )

Get the StringRegistry entry for the named key or false if not set.

参数

key
The entry to get.

返回值

Imagick::getReleaseDate

Returns the ImageMagick release date

说明

public <span class="modifier">static string <span class="methodname">Imagick::getReleaseDate ( <span class="methodparam">void )

Returns the ImageMagick release date as a string.

返回值

Returns the ImageMagick release date as a string.

错误/异常

错误时抛出 ImagickException。

Imagick::getResource

Returns the specified resource's memory usage

说明

public <span class="modifier">static int <span class="methodname">Imagick::getResource ( <span class="methodparam">int $type )

Returns the specified resource's memory usage in megabytes.

参数

type
Refer to the list of resourcetype constants.

返回值

Returns the specified resource's memory usage in megabytes.

错误/异常

错误时抛出 ImagickException。

Imagick::getResourceLimit

Returns the specified resource limit

说明

public <span class="modifier">static int <span class="methodname">Imagick::getResourceLimit ( <span class="methodparam">int $type )

Returns the specified resource limit.

参数

type
One of the resourcetype constants. The unit depends on the type of the resource being limited.

返回值

Returns the specified resource limit in megabytes.

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::setResourceLimit

Imagick::getSamplingFactors

Gets the horizontal and vertical sampling factor

说明

public array Imagick::getSamplingFactors ( <span class="methodparam">void )

Gets the horizontal and vertical sampling factor.

返回值

Returns an associative array with the horizontal and vertical sampling factors of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getSize

Returns the size associated with the Imagick object

说明

public array Imagick::getSize ( <span class="methodparam">void )

Get the size in pixels associated with the Imagick object, previously set by Imagick::setSize.

Note:

This method just returns the size that was set using <span class="function">Imagick::setSize. If you want to get the actual width / height of the image, use <span class="function">Imagick::getImageWidth and <span class="function">Imagick::getImageHeight.

返回值

Returns the size associated with the Imagick object as an array with the keys "columns" and "rows".

范例

示例 #1 Getting the size of a raw RGB image set at 200x400, after scaling to 400x800 (compared to width / height)

<?php
//Set size first and then load the raw image
$img = new Imagick();
$img->setSize(200, 400);
$img->readImage("image.rgb");

$img->scaleImage(400, 800);

$size = $img->getSize();
print_r($size);

echo "$img->getImageWidth()."x".$img->getImageHeight();
?>

以上例程会输出:

Array
(
    [columns] => 200
    [rows] => 400
)
400x800

Imagick::getSizeOffset

Returns the size offset

说明

public int <span class="methodname">Imagick::getSizeOffset ( <span class="methodparam">void )

Returns the size offset associated with the Imagick object. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

Returns the size offset associated with the Imagick object.

错误/异常

错误时抛出 ImagickException。

Imagick::getVersion

Returns the ImageMagick API version

说明

public <span class="modifier">static array <span class="methodname">Imagick::getVersion ( <span class="methodparam">void )

Returns the ImageMagick API version as a string and as a number.

返回值

Returns the ImageMagick API version as a string and as a number.

错误/异常

错误时抛出 ImagickException。

Imagick::haldClutImage

Replaces colors in the image

说明

public bool Imagick::haldClutImage ( <span class="methodparam">Imagick $clut [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Replaces colors in the image using a Hald lookup table. Hald images can be created using HALD color coder.

参数

clut
Imagick object containing the Hald lookup image.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::haldClutImage

<?php
function haldClutImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagickPalette = new \Imagick(realpath("images/hald/hald_8.png"));
    $imagickPalette->sepiatoneImage(55);
    $imagick->haldClutImage($imagickPalette);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::hasNextImage

Checks if the object has more images

说明

public bool Imagick::hasNextImage ( <span class="methodparam">void )

Returns true if the object has more images when traversing the list in the forward direction.

返回值

Returns true if the object has more images when traversing the list in the forward direction, returns false if there are none.

Imagick::hasPreviousImage

Checks if the object has a previous image

说明

public bool Imagick::hasPreviousImage ( <span class="methodparam">void )

Returns true if the object has more images when traversing the list in the reverse direction

返回值

Returns true if the object has more images when traversing the list in the reverse direction, returns false if there are none.

Imagick::identifyFormat

Description

说明

public <span class="type">stringfalse <span class="methodname">Imagick::identifyFormat ( <span class="methodparam">string $embedText )

Replaces any embedded formatting characters with the appropriate image property and returns the interpreted text. See http://www.imagemagick.org/script/escape.php for escape sequences.

参数

embedText
A string containing formatting sequences e.g. "Trim box: %@ number of unique colors: %k".

返回值

Returns format 或者在失败时返回 false.

范例

示例 #1 Imagick::identifyFormat

<?php
        $output = "Output of 'Trim box: %@ number of unique colors: %k' is: <br/>";
        $imagick = new \Imagick(realpath("./images/artifact/mask.png"));
        $output .= $imagick->identifyFormat("Trim box: %@ number of unique colors: %k");

?>

Imagick::identifyImage

Identifies an image and fetches attributes

说明

public array Imagick::identifyImage ([ <span class="methodparam">bool $appendRawOutput = false ] )

Identifies an image and returns the attributes. Attributes include the image width, height, size, and others.

参数

appendRawOutput
If true then the raw output is appended to the array.

返回值

Identifies an image and returns the attributes. Attributes include the image width, height, size, and others.

示例 #1 Example Result Format

Array
(
    [imageName] => /some/path/image.jpg
    [format] => JPEG (Joint Photographic Experts Group JFIF format)
    [geometry] => Array
        (
            [width] => 90
            [height] => 90
        )

    [type] => TrueColor
    [colorSpace] => RGB
    [resolution] => Array
        (
            [x] => 300
            [y] => 300
        )

    [units] => PixelsPerInch
    [fileSize] => 1.88672kb
    [compression] => JPEG
    [signature] => 9a6dc8f604f97d0d691c0286176ddf992e188f0bebba98494b2146ee2d7118da
)

错误/异常

错误时抛出 ImagickException。

Imagick::implodeImage

Creates a new image as a copy

说明

public bool Imagick::implodeImage ( <span class="methodparam">float $radius )

Creates a new image that is a copy of an existing one with the image pixels "imploded" by the specified percentage.

参数

radius
The radius of the implode

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::implodeImage

<?php
function implodeImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->implodeImage(0.0001);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();

}

?>

Imagick::importImagePixels

Imports image pixels

说明

public bool Imagick::importImagePixels ( <span class="methodparam">int $x , <span class="methodparam">int $y , <span class="methodparam">int $width , int $height , string $map , int $storage , <span class="type">array $pixels )

Imports pixels from an array into an image. The map is usually 'RGB'. This method imposes the following constraints for the parameters: amount of pixels in the array must match width x height x length of the map. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

x
The image x position

y
The image y position

width
The image width

height
The image height

map
Map of pixel ordering as a string. This can be for example RGB. The value can be any combination or order of R = red, G = green, B = blue, A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, Y = yellow, M = magenta, K = black, I = intensity (for grayscale), P = pad.

storage
The pixel storage method. Refer to this list of pixel constants.

pixels
The array of pixels

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::importImagePixels example

<?php

/* Generate array of pixels. 2000 pixels per color stripe */
$count = 2000 * 3;

$pixels = 
   array_merge(array_pad(array(), $count, 0),
               array_pad(array(), $count, 255), 
               array_pad(array(), $count, 0),
               array_pad(array(), $count, 255),
               array_pad(array(), $count, 0));

/* Width and height. The area is amount of pixels divided
   by three. Three comes from 'RGB', three values per pixel */
$width = $height = pow((count($pixels) / 3), 0.5);

/* Create empty image */
$im = new Imagick();
$im->newImage($width, $height, 'gray');

/* Import the pixels into image.
   width * height * strlen("RGB") must match count($pixels) */
$im->importImagePixels(0, 0, $width, $height, "RGB", Imagick::PIXEL_CHAR, $pixels);

/* output as jpeg image */
$im->setImageFormat('jpg');
header("Content-Type: image/jpg");
echo $im;

?>

以上例程的输出类似于:

Output of example : Imagick::importImagePixels()

Imagick::inverseFourierTransformImage

Description

说明

public bool Imagick::inverseFourierTransformImage ( Imagick $complement , <span class="type">bool $magnitude )

Implements the inverse discrete Fourier transform (DFT) of the image either as a magnitude / phase or real / imaginary image pair.

Warning

本函数还未编写文档,仅有参数列表。

参数

complement
The second image to combine with this one to form either the magnitude / phase or real / imaginary image pair.

magnitude
If true, combine as magnitude / phase pair otherwise a real / imaginary image pair.

返回值

成功时返回 true

Imagick::labelImage

Adds a label to an image

说明

public bool Imagick::labelImage ( <span class="methodparam">string $label )

Adds a label to an image.

参数

label
The label to add

返回值

成功时返回 true

Imagick::levelImage

Adjusts the levels of an image

说明

public bool Imagick::levelImage ( <span class="methodparam">float $blackPoint , float $gamma , <span class="type">float $whitePoint [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range. The parameters provided represent the black, mid, and white points. The black point specifies the darkest color in the image. Colors darker than the black point are set to zero. Mid point specifies a gamma correction to apply to the image. White point specifies the lightest color in the image. Colors brighter than the white point are set to the maximum quantum value.

参数

blackPoint
The image black point

gamma
The gamma value

whitePoint
The image white point

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::levelImage

<?php
function levelImage($blackPoint, $gamma, $whitePoint) {
    $imagick = new \Imagick();
    $imagick->newPseudoimage(500, 500, 'gradient:black-white');

    $imagick->setFormat('png');
    $quantum = $imagick->getQuantum();
    $imagick->levelImage($blackPoint / 100 , $gamma, $quantum * $whitePoint / 100);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::linearStretchImage

Stretches with saturation the image intensity

说明

public bool Imagick::linearStretchImage ( <span class="methodparam">float $blackPoint , float $whitePoint )

Stretches with saturation the image intensity.

参数

blackPoint
The image black point

whitePoint
The image white point

返回值

成功时返回 true

范例

示例 #1 Imagick::linearStretchImage

<?php
function linearStretchImage($imagePath, $blackThreshold, $whiteThreshold) {
    $imagick = new \Imagick(realpath($imagePath));
    $pixels = $imagick->getImageWidth() * $imagick->getImageHeight();
    $imagick->linearStretchImage($blackThreshold * $pixels, $whiteThreshold * $pixels);

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::liquidRescaleImage

Animates an image or images

说明

public bool Imagick::liquidRescaleImage ( <span class="methodparam">int $width , int $height , float $delta_x , <span class="type">float $rigidity )

This method scales the images using liquid rescaling method. This method is an implementation of a technique called seam carving. In order for this method to work as expected ImageMagick must be compiled with liblqr support. 此方法在Imagick基于ImageMagick 6.3.9以上版本编译时可用。

参数

width
The width of the target size

height
The height of the target size

delta_x
How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight.

rigidity
Introduces a bias for non-straight seams. This parameter is typically 0.

返回值

成功时返回 true

参见

  • Imagick::resizeImage

Imagick::listRegistry

Description

说明

public <span class="modifier">static array <span class="methodname">Imagick::listRegistry ( <span class="methodparam">void )

List all the registry settings. Returns an array of all the key/value pairs in the registry

参数

此函数没有参数。

返回值

An array containing the key/values from the registry.

Imagick::magnifyImage

Scales an image proportionally 2x

说明

public bool Imagick::magnifyImage ( <span class="methodparam">void )

Is a convenience method that scales an image proportionally to twice its original size.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::magnifyImage

<?php
function magnifyImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->magnifyImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::mapImage

Replaces the colors of an image with the closest color from a reference image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::mapImage ( <span class="methodparam">Imagick $map , bool $dither )

参数

map

dither

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::matteFloodfillImage

Changes the transparency value of a color

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::matteFloodfillImage ( <span class="methodparam">float $alpha , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y )

Changes the transparency value of any pixel that matches target and is an immediate neighbor. If the method FillToBorderMethod is specified, the transparency value is changed for any neighbor pixel that does not match the bordercolor member of image.

参数

alpha
The level of transparency: 1.0 is fully opaque and 0.0 is fully transparent.

fuzz
The fuzz member of image defines how much tolerance is acceptable to consider two colors as the same.

bordercolor
An ImagickPixel object or string representing the border color.

x
The starting x coordinate of the operation.

y
The starting y coordinate of the operation.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the third parameter. Previous versions allow only an ImagickPixel object.

Imagick::medianFilterImage

Applies a digital filter

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::medianFilterImage ( <span class="methodparam">float $radius )

Applies a digital filter that improves the quality of a noisy image. Each pixel is replaced by the median in a set of neighboring pixels as defined by radius.

参数

radius
The radius of the pixel neighborhood.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::medianFilterImage

<?php
function medianFilterImage($radius, $imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    @$imagick->medianFilterImage($radius);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::mergeImageLayers

Merges image layers

说明

public Imagick Imagick::mergeImageLayers ( <span class="methodparam">int $layer_method )

Merges image layers into one. This method is useful when working with image formats that use multiple layers such as PSD. The merging is controlled using the layer_method which defines how the layers are merged. 此方法在Imagick基于ImageMagick 6.3.7以上版本编译时可用。

参数

layer_method
One of the *`Imagick::LAYERMETHOD_`** constants

返回值

Returns an Imagick object containing the merged image.

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::flattenImages

范例

示例 #1 Imagick::mergeImageLayers

<?php
function mergeImageLayers($layerMethodType, $imagePath1, $imagePath2) {

    $imagick = new \Imagick(realpath($imagePath));

    $imagick2 = new \Imagick(realpath($imagePath2));
    $imagick->addImage($imagick2);
    $imagick->setImageFormat('png');

    $result = $imagick->mergeImageLayers($layerMethodType);
    header("Content-Type: image/png");
    echo $result->getImageBlob();
}

?>

Imagick::minifyImage

Scales an image proportionally to half its size

说明

public bool Imagick::minifyImage ( <span class="methodparam">void )

Is a convenience method that scales an image proportionally to one-half its original size

返回值

成功时返回 true

Imagick::modulateImage

Control the brightness, saturation, and hue

说明

public bool Imagick::modulateImage ( <span class="methodparam">float $brightness , float $saturation , <span class="type">float $hue )

Lets you control the brightness, saturation, and hue of an image. Hue is the percentage of absolute rotation from the current position. For example 50 results in a counter-clockwise rotation of 90 degrees, 150 results in a clockwise rotation of 90 degrees, with 0 and 200 both resulting in a rotation of 180 degrees.

参数

brightness

saturation

hue

返回值

成功时返回 true

范例

示例 #1 Imagick::modulateImage

<?php
function modulateImage($imagePath, $hue, $brightness, $saturation) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->modulateImage($brightness, $saturation, $hue);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::montageImage

Creates a composite image

说明

public Imagick Imagick::montageImage ( <span class="methodparam">ImagickDraw $draw , string $tile_geometry , <span class="type">string $thumbnail_geometry , <span class="methodparam">int $mode , <span class="methodparam">string $frame )

Creates a composite image by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile.

参数

draw
The font name, size, and color are obtained from this object.

tile_geometry
The number of tiles per row and page (e.g. 6x4+0+0).

thumbnail_geometry
Preferred image size and border size of each thumbnail (e.g. 120x120+4+3>).

mode
Thumbnail framing mode, see Montage Mode constants.

frame
Surround the image with an ornamental border (e.g. 15x15+3+3). The frame color is that of the thumbnail's matte color.

返回值

成功时返回 true

Imagick::morphImages

Method morphs a set of images

说明

public Imagick Imagick::morphImages ( <span class="methodparam">int $number_frames )

Method morphs a set of images. Both the image pixels and size are linearly interpolated to give the appearance of a meta-morphosis from one image to the next.

参数

number_frames
The number of in-between images to generate.

返回值

This method returns a new Imagick object on success. 错误时抛出 <span class="classname">ImagickException。

Imagick::morphology

Description

说明

public bool Imagick::morphology ( <span class="methodparam">int $morphologyMethod , <span class="type">int $iterations , <span class="methodparam">ImagickKernel $ImagickKernel [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Applies a user supplied kernel to the image according to the given morphology method.

参数

morphologyMethod
Which morphology method to use one of the \Imagick::MORPHOLOGY_* constants.

iterations
The number of iteration to apply the morphology function. A value of -1 means loop until no change found. How this is applied may depend on the morphology method. Typically this is a value of 1.

ImagickKernel

channel

返回值

成功时返回 true

范例

示例 #1 Convolve Imagick::morphology

<?php
        $imagick = $this->getCharacter();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_GAUSSIAN, "5,1");
        $imagick->morphology(\Imagick::MORPHOLOGY_CONVOLVE, 2, $kernel);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();

?>

示例 #2 Correlate Imagick::morphology

<?php

        // Top-left pixel must be black
        // Bottom right pixel must be white
        // We don't care about the rest.


        $imagick = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromMatrix(self::$correlateMatrix, [2, 2]);
        $imagick->morphology(\Imagick::MORPHOLOGY_CORRELATE, 1, $kernel);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();

?>

示例 #3 Erode Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_ERODE, 2, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #4 Erode Intensity <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacter();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "1");
        $canvas->morphology(\Imagick::MORPHOLOGY_ERODE_INTENSITY, 2, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #5 Dilate Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_DILATE, 4, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #6 Dilate intensity <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacter();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "1");
        $canvas->morphology(\Imagick::MORPHOLOGY_DILATE_INTENSITY, 4, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #7 Distance with Chebyshev kernel <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_CHEBYSHEV, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);
        $canvas->autoLevelImage();
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #8 Distance with Manhattan kernel <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_MANHATTAN, "5");
        $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);
        $canvas->autoLevelImage();
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #9 Distance with ocatagonal kernel <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGONAL, "5");
        $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);
        $canvas->autoLevelImage();
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #10 Distance with Euclidean kernel <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_EUCLIDEAN, "4");
        $canvas->morphology(\Imagick::MORPHOLOGY_DISTANCE, 3, $kernel);
        $canvas->autoLevelImage();
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #11 Edge Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_EDGE, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #12 Open Imagick::morphology

<?php
        // As a result you will see that 'Open' smoothed the outline, by rounding off any sharp points, and remove any parts that is smaller than the shape used. It will also disconnect or 'open' any thin bridges.
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");
        $canvas->morphology(\Imagick::MORPHOLOGY_OPEN, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #13 Open intensity <span class="function">Imagick::morphology

<?php
        // As a result you will see that 'Open' smoothed the outline, by rounding off any sharp points, and remove any parts that is smaller than the shape used. It will also disconnect or 'open' any thin bridges.

        $canvas = $this->getCharacter();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");
        $canvas->morphology(\Imagick::MORPHOLOGY_OPEN_INTENSITY, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #14 Close Imagick::morphology

<?php
        //The basic use of the 'Close' method is to reduce or remove any 'holes' or 'gaps' about the size of the kernel 'Structure Element'. That is 'close' parts of the background that are about that size.
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");
        $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #15 Close Intensity <span class="function">Imagick::morphology

<?php
        //The basic use of the 'Close' method is to reduce or remove any 'holes' or 'gaps' about the size of the kernel 'Structure Element'. That is 'close' parts of the background that are about that size.
        $canvas = $this->getCharacter();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "6");
        $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE_INTENSITY, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #16 Smooth Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_SMOOTH, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #17 Edge in Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #18 Edge out Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "3");
        $canvas->morphology(\Imagick::MORPHOLOGY_EDGE_OUT, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #19 The 'TopHat' method, or more specifically 'White Top Hat', returns the pixels that were removed by a Opening of the shape, that is the pixels that were removed to round off the points, and the connecting bridged between shapes. <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "5");
        $canvas->morphology(\Imagick::MORPHOLOGY_TOP_HAT, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #20 The 'BottomHat' method, also known as 'Black TopHat' is the pixels that a Closing of the shape adds to the image. That is the pixels that were used to fill in the 'holes', 'gaps', and 'bridges'. <span class="function">Imagick::morphology

<?php

        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "5");
        $canvas->morphology(\Imagick::MORPHOLOGY_BOTTOM_HAT, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #21 Hit and Miss <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        //This finds all the pixels with 3 pixels of the right edge
        $matrix = [[1, false, false, 0]];
        $kernel = \ImagickKernel::fromMatrix(
            $matrix,
            [0, 0]
        );
        $canvas->morphology(\Imagick::MORPHOLOGY_HIT_AND_MISS, 1, $kernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #22 Thinning Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $leftEdgeKernel = \ImagickKernel::fromMatrix([[0, 1]], [1, 0]);
        $rightEdgeKernel = \ImagickKernel::fromMatrix([[1, 0]], [0, 0]);
        $leftEdgeKernel->addKernel($rightEdgeKernel);

        $canvas->morphology(\Imagick::MORPHOLOGY_THINNING, 3, $leftEdgeKernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #23 Thicken Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $leftEdgeKernel = \ImagickKernel::fromMatrix([[0, 1]], [1, 0]);
        $rightEdgeKernel = \ImagickKernel::fromMatrix([[1, 0]], [0, 0]);
        $leftEdgeKernel->addKernel($rightEdgeKernel);

        $canvas->morphology(\Imagick::MORPHOLOGY_THICKEN, 3, $leftEdgeKernel);
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #24 Thick to generate a convex hull <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $diamondKernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DIAMOND, "1");
        $convexKernel =  \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_CONVEX_HULL, "");

        // The thicken morphology doesn't handle small gaps. We close them
        // with the close morphology.
        $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $diamondKernel);
        $canvas->morphology(\Imagick::MORPHOLOGY_THICKEN, -1, $convexKernel);
        $canvas->morphology(\Imagick::MORPHOLOGY_CLOSE, 1, $diamondKernel);

        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #25 Iterative morphology <span class="function">Imagick::morphology

<?php
        $canvas = $this->getCharacterOutline();
        $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DISK, "2");        
        $canvas->morphology(\Imagick::MORPHOLOGY_ITERATIVE, 3, $kernel);
        $canvas->autoLevelImage();
        header("Content-Type: image/png");
        echo $canvas->getImageBlob();

?>

示例 #26 Helper functon to get an image silhouette <span class="function">Imagick::morphology

<?php
    private function getCharacterOutline() {

        $imagick = new \Imagick(realpath("./images/character.png"));
        $character = new \Imagick();
        $character->newPseudoImage(
            $imagick->getImageWidth(),
            $imagick->getImageHeight(),
            "canvas:white"
        );
        $canvas = new \Imagick();
        $canvas->newPseudoImage(
            $imagick->getImageWidth(),
            $imagick->getImageHeight(),
            "canvas:black"
        );

        $character->compositeimage(
            $imagick,
            \Imagick::COMPOSITE_COPYOPACITY,
            0, 0
        );
        $canvas->compositeimage(
            $character,
            \Imagick::COMPOSITE_ATOP,
            0, 0
        );
        $canvas->setFormat('png');

        return $canvas;
    }

?>

Imagick::mosaicImages

Forms a mosaic from images

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public Imagick Imagick::mosaicImages ( <span class="methodparam">void )

Inlays an image sequence to form a single coherent picture. It returns a wand with each image in the sequence composited at the location defined by the page offset of the image.

返回值

成功时返回 true

Imagick::motionBlurImage

Simulates motion blur

说明

public bool Imagick::motionBlurImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $angle [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Simulates motion blur. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and MotionBlurImage() selects a suitable radius for you. Angle gives the angle of the blurring motion.

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel.

sigma
The standard deviation of the Gaussian, in pixels.

angle
Apply the effect along this angle.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants. The channel argument affects only if Imagick is compiled against ImageMagick version 6.4.4 or greater.

返回值

成功时返回 true

范例

示例 #1 Imagick::motionBlurImage

<?php
function motionBlurImage($imagePath, $radius, $sigma, $angle, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->motionBlurImage($radius, $sigma, $angle, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::negateImage

Negates the colors in the reference image

说明

public bool Imagick::negateImage ( <span class="methodparam">bool $gray [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Negates the colors in the reference image. The Grayscale option means that only grayscale values within the image are negated.

参数

gray
Whether to only negate grayscale pixels within the image.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::negateImage

<?php
function negateImage($imagePath, $grayOnly, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->negateImage($grayOnly, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::newImage

创建一张图片

说明

bool <span class="methodname">Imagick::newImage ( <span class="methodparam">int $cols , <span class="methodparam">int $rows , <span class="methodparam">mixed $background [, string $format ] )

创建一个 Imagick 图片对象,同时可以附带设置一个 ImagickPixel 值作为其背景色。

参数

cols
新建图片对象列的值(宽多少像素)

rows
新建图片对象行的值(高多少像素)

background
新建图片独享的背景色

format
图片格式。这个参数是在 Imagick 2.0.1 版本添加的。

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
2.1.0 现在可以似乎用了一个字符串作为颜色传入第三个参数。在此之前的版本只允许以一个 ImagickPixel 对象的形式传入。

范例

示例 #1 Using Imagick::newImage:

Create a new image and display it.

<?php

$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red'));
$image->setImageFormat('png');

header('Content-type: image/png');
echo $image;

?>

Imagick::newPseudoImage

Creates a new image

说明

public bool Imagick::newPseudoImage ( <span class="methodparam">int $columns , int $rows , string $pseudoString )

Creates a new image using ImageMagick pseudo-formats.

参数

columns
columns in the new image

rows
rows in the new image

pseudoString
string containing pseudo image definition.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::newPseudoImage

<?php
function newPseudoImage($canvasType) {
    $imagick = new \Imagick();
    $imagick->newPseudoImage(300, 300, $canvasType);
    $imagick->setImageFormat("png");
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

//newPseudoImage('gradient:red-rgba(64, 255, 255, 0.5)');
//newPseudoImage("radial-gradient:red-blue");
newPseudoImage("plasma:fractal");

?>

Imagick::nextImage

Moves to the next image

说明

public bool Imagick::nextImage ( <span class="methodparam">void )

Associates the next image in the image list with an Imagick object.

返回值

成功时返回 true

Imagick::normalizeImage

Enhances the contrast of a color image

说明

public bool Imagick::normalizeImage ([ <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available.

参数

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

范例

示例 #1 Imagick::normalizeImage

<?php
function normalizeImage($imagePath, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $original = clone $imagick;
    $original->cropimage($original->getImageWidth() / 2, $original->getImageHeight(), 0, 0);
    $imagick->normalizeImage($channel);
    $imagick->compositeimage($original, \Imagick::COMPOSITE_ATOP, 0, 0);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::oilPaintImage

Simulates an oil painting

说明

public bool Imagick::oilPaintImage ( <span class="methodparam">float $radius )

Applies a special effect filter that simulates an oil painting. Each pixel is replaced by the most frequent color occurring in a circular region defined by radius.

参数

radius
The radius of the circular neighborhood.

返回值

成功时返回 true

范例

示例 #1 Imagick::oilPaintImage

<?php
function oilPaintImage($imagePath, $radius) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->oilPaintImage($radius);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::opaquePaintImage

Changes the color value of any pixel that matches target

说明

public bool Imagick::opaquePaintImage ( <span class="methodparam">mixed $target , mixed $fill , float $fuzz , <span class="type">bool $invert [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Changes any pixel that matches color with the color defined by fill. 此方法在Imagick基于ImageMagick 6.3.8以上版本编译时可用。

参数

target
ImagickPixel object or a string containing the color to change

fill
The replacement color

fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color.

invert
If true paints any pixel that does not match the target color.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

Imagick::optimizeImageLayers

Removes repeated portions of images to optimize

说明

public bool Imagick::optimizeImageLayers ( <span class="methodparam">void )

Compares each image the GIF disposed forms of the previous image in the sequence. From this it attempts to select the smallest cropped image to replace each frame, while preserving the results of the animation. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using <span class="function">Imagick::optimizeImageLayers

Reading, optimizing and writing a GIF image

<?php
/* create new imagick object */
$im = new Imagick("test.gif");

/* optimize the image layers */
$im->optimizeImageLayers();

/* write the image back */
$im->writeImages("test_optimized.gif", true);
?>

参见

  • Imagick::compareImageLayers
  • Imagick::writeImages
  • Imagick::writeImage

Imagick::orderedPosterizeImage

Performs an ordered dither

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::orderedPosterizeImage ( <span class="methodparam">string $threshold_map [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Performs an ordered dither based on a number of pre-defined dithering threshold maps, but over multiple intensity levels, which can be different for different channels, according to the input arguments. 此方法在Imagick基于ImageMagick 6.3.1以上版本编译时可用。

参数

threshold_map
A string containing the name of the threshold dither map to use

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 <span class="function">Imagick::orderedPosterizeImage

<?php
function orderedPosterizeImage($imagePath, $orderedPosterizeType) {
    $imagick = new \Imagick(realpath($imagePath));


    $imagick->orderedPosterizeImage($orderedPosterizeType);
    $imagick->setImageFormat('png');

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

//orderedPosterizeImage($imagePath, 'o4x4,3,3');
//orderedPosterizeImage($imagePath, 'o8x8,6,6');
orderedPosterizeImage($imagePath, 'h8x8a');





?>

Imagick::paintFloodfillImage

Changes the color value of any pixel that matches target

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::paintFloodfillImage ( <span class="methodparam">mixed $fill , float $fuzz , mixed $bordercolor , <span class="type">int $x , <span class="type">int $y [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Changes the color value of any pixel that matches target and is an immediate neighbor. As of ImageMagick 6.3.8 this method has been deprecated and <span class="function">Imagick::floodfillPaintImage should be used instead.

参数

fill
ImagickPixel object or a string containing the fill color

fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color for the purposes of the floodfill.

bordercolor
ImagickPixel object or a string containing the border color

x
X start position of the floodfill

y
Y start position of the floodfill

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

Imagick::paintOpaqueImage

Change any pixel that matches color

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::paintOpaqueImage ( <span class="methodparam">mixed $target , mixed $fill , float $fuzz [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Changes any pixel that matches color with the color defined by fill.

参数

target
Change this target color to the fill color within the image. An ImagickPixel object or a string representing the target color.

fill
An ImagickPixel object or a string representing the fill color.

fuzz
The fuzz member of image defines how much tolerance is acceptable to consider two colors as the same.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as first and second parameter. Previous versions allow only an ImagickPixel object.

Imagick::paintTransparentImage

Changes any pixel that matches color with the color defined by fill

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::paintTransparentImage ( <span class="methodparam">mixed $target , float $alpha , <span class="type">float $fuzz )

Changes any pixel that matches color with the color defined by fill.

参数

target
Change this target color to specified opacity value within the image.

alpha
The level of transparency: 1.0 is fully opaque and 0.0 is fully transparent.

fuzz
The fuzz member of image defines how much tolerance is acceptable to consider two colors as the same.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter. Previous versions allow only an ImagickPixel object.

Imagick::pingImage

Fetch basic attributes about the image

说明

public bool Imagick::pingImage ( <span class="methodparam">string $filename )

This method can be used to query image width, height, size, and format without reading the whole image in to memory.

参数

filename
The filename to read the information from.

返回值

成功时返回 true

Imagick::pingImageBlob

Quickly fetch attributes

说明

public bool Imagick::pingImageBlob ( <span class="methodparam">string $image )

This method can be used to query image width, height, size, and format without reading the whole image to memory. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

image
A string containing the image.

返回值

成功时返回 true

范例

示例 #1 Using Imagick::pingImageBlob

Pinging an image from a string

<?php
/* read image contents */
$image = file_get_contents("test.jpg");

/* create new imagick object */
$im = new Imagick();

/* pass the string to the imagick object */
$im->pingImageBlob($image);

/* output image width and height */
echo $im->getImageWidth() . 'x' . $im->getImageHeight();
?>

参见

  • Imagick::pingImage
  • Imagick::pingImageFile
  • Imagick::readImage
  • Imagick::readImageBlob
  • Imagick::readImageFile

Imagick::pingImageFile

Get basic image attributes in a lightweight manner

说明

public bool Imagick::pingImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $fileName ] )

This method can be used to query image width, height, size, and format without reading the whole image to memory. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

filehandle
An open filehandle to the image.

fileName
Optional filename for this image.

返回值

成功时返回 true

范例

示例 #1 Using Imagick::pingImageFile

Opening a remote location

<?php
/* fopen a remote location */
$fp = fopen("http://example.com/test.jpg");

/* create new imagick object */
$im = new Imagick();

/* pass the handle to imagick */
$im->pingImageFile($fp);
?>

参见

  • Imagick::pingImage
  • Imagick::pingImageBlob
  • Imagick::readImage
  • Imagick::readImageBlob
  • Imagick::readImageFile

Imagick::polaroidImage

Simulates a Polaroid picture

说明

public bool Imagick::polaroidImage ( <span class="methodparam">ImagickDraw $properties , <span class="type">float $angle )

Simulates a Polaroid picture. 此方法在Imagick基于ImageMagick 6.3.2以上版本编译时可用。

参数

properties
The polaroid properties

angle
The polaroid angle

返回值

成功时返回 true

范例

示例 #1 A Imagick::polaroidImage example

An example of using Imagick::polaroidImage()

<?php
/* Create the object */
$image = new Imagick('source.png');

/* Set the opacity */
$image->polaroidImage(new ImagickDraw(), 25);

/* output the image */
header('Content-type: image/png');
echo $image;

?>

Imagick::posterizeImage

Reduces the image to a limited number of color level

说明

public bool Imagick::posterizeImage ( <span class="methodparam">int $levels , bool $dither )

Reduces the image to a limited number of color level.

参数

levels

dither

返回值

成功时返回 true

范例

示例 #1 Imagick::posterizeImage

<?php
function posterizeImage($imagePath, $posterizeType, $numberLevels) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->posterizeImage($numberLevels, $posterizeType);
    $imagick->setImageFormat('png');
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

posterizeImage($imagePath, \Imagick::DITHERMETHOD_RIEMERSMA, 8);

?>

Imagick::previewImages

Quickly pin-point appropriate parameters for image processing

说明

public bool Imagick::previewImages ( <span class="methodparam">int $preview )

Tiles 9 thumbnails of the specified image with an image processing operation applied at varying strengths. This is helpful to quickly pin-point an appropriate parameter for an image processing operation.

参数

preview
Preview type. See Preview type constants

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::previousImage

Move to the previous image in the object

说明

public bool Imagick::previousImage ( <span class="methodparam">void )

Assocates the previous image in an image list with the Imagick object.

返回值

成功时返回 true

Imagick::profileImage

Adds or removes a profile from an image

说明

public bool Imagick::profileImage ( <span class="methodparam">string $name , string $profile )

Adds or removes a ICC, IPTC, or generic profile from an image. If the profile is NULL, it is removed from the image otherwise added. Use a name of '*' and a profile of NULL to remove all profiles from the image.

参数

name

profile

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::quantizeImage

Analyzes the colors within a reference image

说明

public bool Imagick::quantizeImage ( <span class="methodparam">int $numberColors , int $colorspace , <span class="type">int $treedepth , <span class="methodparam">bool $dither , bool $measureError )

参数

numberColors

colorspace

treedepth

dither

measureError

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::quantizeImage

<?php
function quantizeImage($imagePath, $numberColors, $colorSpace, $treeDepth, $dither) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->quantizeImage($numberColors, $colorSpace, $treeDepth, $dither, false);
    $imagick->setImageFormat('png');
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::quantizeImages

Analyzes the colors within a sequence of images

说明

public bool Imagick::quantizeImages ( <span class="methodparam">int $numberColors , int $colorspace , <span class="type">int $treedepth , <span class="methodparam">bool $dither , bool $measureError )

参数

numberColors

colorspace

treedepth

dither

measureError

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::queryFontMetrics

Returns an array representing the font metrics

说明

public array Imagick::queryFontMetrics ( <span class="methodparam">ImagickDraw $properties , <span class="type">string $text [, <span class="methodparam">bool $multiline ] )

Returns a multi-dimensional array representing the font metrics.

参数

properties
ImagickDraw object containing font properties

text
The text

multiline
Multiline parameter. If left empty it is autodetected

返回值

Returns a multi-dimensional array representing the font metrics.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using <span class="function">Imagick::queryFontMetrics:

Query the metrics for the text and dump the results on the screen.

<?php
/* Create a new Imagick object */
$im = new Imagick();

/* Create an ImagickDraw object */
$draw = new ImagickDraw();

/* Set the font */
$draw->setFont('/path/to/font.ttf');

/* Dump the font metrics, autodetect multiline */
var_dump($im->queryFontMetrics($draw, "Hello World!"));
?>

Imagick::queryFonts

Returns the configured fonts

说明

public <span class="modifier">static array <span class="methodname">Imagick::queryFonts ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" ] )

Returns the configured fonts.

参数

pattern
The query pattern

返回值

Returns an array containing the configured fonts.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::queryFonts

<?php
        $output = '';
        $output .= "Fonts that match 'Helvetica*' are:<br/>";

        $fontList = \Imagick::queryFonts("Helvetica*");

        foreach ($fontList as $fontName) {
            $output .= '<li>'. $fontName."</li>";
        }

        return $output;

?>

Imagick::queryFormats

Returns formats supported by Imagick

说明

public <span class="modifier">static array <span class="methodname">Imagick::queryFormats ([ <span class="methodparam">string $pattern<span class="initializer"> = "*" ] )

Returns formats supported by Imagick.

参数

pattern

返回值

Returns an array containing the formats supported by Imagick.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::queryFormats

<?php
    function render() {
        $output = "";
        $input = \Imagick::queryformats();
        $columns = 6;

        $output .= "<table border='2'>";

        for ($i=0; $i < count($input); $i += $columns) {
            $output .= "<tr>";
            for ($c=0; $c<$columns; $c++) {
                $output .= "<td>";
                if (($i + $c) <  count($input)) {
                    $output .= $input[$i + $c];
                }
                $output .= "</td>";
            }
            $output .= "</tr>";
        }

        $output .= "</table>";

        return $output;
    }

?>

Imagick::radialBlurImage

Radial blurs an image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::radialBlurImage ( <span class="methodparam">float $angle [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Radial blurs an image.

参数

angle

channel

返回值

成功时返回 true

范例

示例 #1 Imagick::radialBlurImage

<?php
function radialBlurImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    //Blur 3 times with different radii
    $imagick->radialBlurImage(3);
    $imagick->radialBlurImage(5);
    $imagick->radialBlurImage(7);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::raiseImage

Creates a simulated 3d button-like effect

说明

public bool Imagick::raiseImage ( <span class="methodparam">int $width , int $height , int $x , int $y , bool $raise )

Creates a simulated three-dimensional button-like effect by lightening and darkening the edges of the image. Members width and height of raise_info define the width of the vertical and horizontal edge of the effect.

参数

width

height

x

y

raise

返回值

成功时返回 true

范例

示例 #1 Imagick::raiseImage

<?php
function raiseImage($imagePath, $width, $height, $x, $y, $raise) {
    $imagick = new \Imagick(realpath($imagePath));

    //x and y do nothing?
    $imagick->raiseImage($width, $height, $x, $y, $raise);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::randomThresholdImage

Creates a high-contrast, two-color image

说明

public bool Imagick::randomThresholdImage ( <span class="methodparam">float $low , float $high [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Changes the value of individual pixels based on the intensity of each pixel compared to threshold. The result is a high-contrast, two color image. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

low
The low point

high
The high point

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.

返回值

成功时返回 true

范例

示例 #1 Imagick::randomThresholdImage

<?php
function randomThresholdimage($imagePath, $lowThreshold, $highThreshold, $channel) {
    $imagick = new \Imagick(realpath($imagePath));

    $imagick->randomThresholdimage(
        $lowThreshold * \Imagick::getQuantum(),
        $highThreshold * \Imagick::getQuantum(),
        $channel
    );
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::readImage

Reads image from filename

说明

public bool Imagick::readImage ( <span class="methodparam">string $filename )

Reads image from filename

参数

filename

返回值

成功时返回 true

Imagick::readImageBlob

从二进制字符串里读取图片

说明

bool <span class="methodname">Imagick::readImageBlob ( <span class="methodparam">string $image [, string $filename ] )

从二进制字符串里读取图片

参数

image

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::readImageBlob

<?php
function readImageBlob() {
    $base64 = "iVBORw0KGgoAAAANSUhEUgAAAM0AAAD
 NCAMAAAAsYgRbAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5c
 cllPAAAABJQTFRF3NSmzMewPxIG//ncJEJsldTou1jHgAAAARBJREFUeNrs2EEK
 gCAQBVDLuv+V20dENbMY831wKz4Y/VHb/5RGQ0NDQ0NDQ0NDQ0NDQ0NDQ
 0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0PzMWtyaGhoaGhoaGhoaGhoaGhoxtb0QGho
 aGhoaGhoaGhoaGhoaMbRLEvv50VTQ9OTQ5OpyZ01GpM2g0bfmDQaL7S+ofFC6x
 v3ZpxJiywakzbvd9r3RWPS9I2+MWk0+kbf0Hih9Y17U0nTHibrDDQ0NDQ0NDQ0
 NDQ0NDQ0NTXbRSL/AK72o6GhoaGhoRlL8951vwsNDQ0NDQ1NDc0WyHtDTEhD
 Q0NDQ0NTS5MdGhoaGhoaGhoaGhoaGhoaGhoaGhoaGposzSHAAErMwwQ2HwRQ
 AAAAAElFTkSuQmCC";

    $imageBlob = base64_decode($base64);

    $imagick = new Imagick();
    $imagick->readImageBlob($imageBlob);

    header("Content-Type: image/png");
    echo $imageBlob;
}

?>

Imagick::readImageFile

Reads image from open filehandle

说明

public bool Imagick::readImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $fileName = null ] )

Reads image from open filehandle

参数

filehandle

fileName

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::readimages

Description

说明

public bool Imagick::readImages ( <span class="methodparam">array $filenames )

Reads image from an array of filenames. All the images are held in a single Imagick object.

参数

filenames

返回值

成功时返回 true

Imagick::recolorImage

Recolors image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::recolorImage ( <span class="methodparam">array $matrix )

Translate, scale, shear, or rotate image colors. This method supports variable sized matrices but normally 5x5 matrix is used for RGBA and 6x6 is used for CMYK. The last row should contain the normalized values. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

matrix
The matrix containing the color values

返回值

成功时返回 true

参见

  • Imagick::displayImage

范例

示例 #1 Imagick::recolorImage

<?php
function recolorImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $remapColor = [ 1, 0, 0,
        0, 0, 1,
        0, 1, 0,];

//$remapColor = [
//    1.438, -0.122, -0.016,  0, 0, -0.03,
//    -0.062,  1.378, -0.016,  0, 0,  0.05,
//    -0.062, -0.122, 1.483,   0, 0, -0.02,
//];

    @$imagick->recolorImage($remapColor);

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::reduceNoiseImage

Smooths the contours of an image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::reduceNoiseImage ( <span class="methodparam">float $radius )

Smooths the contours of an image while still preserving edge information. The algorithm works by replacing each pixel with its neighbor closest in value. A neighbor is defined by radius. Use a radius of 0 and Imagick::reduceNoiseImage() selects a suitable radius for you.

参数

radius

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::reduceNoiseImage

<?php
function reduceNoiseImage($imagePath, $reduceNoise) {
    $imagick = new \Imagick(realpath($imagePath));
    @$imagick->reduceNoiseImage($reduceNoise);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::remapImage

Remaps image colors

说明

public bool Imagick::remapImage ( <span class="methodparam">Imagick $replacement , <span class="type">int $DITHER )

Replaces colors an image with those defined by replacement. The colors are replaced with the closest possible color. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

replacement
An Imagick object containing the replacement colors

DITHER
Refer to this list of dither method constants

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::removeImage

Removes an image from the image list

说明

public bool Imagick::removeImage ( <span class="methodparam">void )

Removes an image from the image list.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::removeImageProfile

Removes the named image profile and returns it

说明

public string Imagick::removeImageProfile ( <span class="methodparam">string $name )

Removes the named image profile and returns it.

参数

name

返回值

Returns a string containing the profile of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::render

Renders all preceding drawing commands

说明

public bool Imagick::render ( <span class="methodparam">void )

Renders all preceding drawing commands.

返回值

成功时返回 true

Imagick::resampleImage

Resample image to desired resolution

说明

public bool Imagick::resampleImage ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution , <span class="methodparam">int $filter , float $blur )

Resample image to desired resolution.

参数

x_resolution

y_resolution

filter

blur

返回值

成功时返回 true

范例

示例 #1 Imagick::resampleImage

<?php
function resampleImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));

    $imagick->resampleImage(200, 200, \Imagick::FILTER_LANCZOS, 1);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::resetImagePage

Reset image page

说明

public bool Imagick::resetImagePage ( <span class="methodparam">string $page )

The page definition as a string. The string is in format WxH+x+y. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

page
The page definition. For example 7168x5147+0+0

返回值

成功时返回 true

Imagick::resizeImage

Scales an image

说明

public bool Imagick::resizeImage ( <span class="methodparam">int $columns , int $rows , int $filter , float $blur [, <span class="type">bool $bestfit = false [, <span class="type">bool $legacy = false ]] )

Scales an image to the desired dimensions with a filter.

Note: 参数 bestfit 的特性在 Imagick 3.0.0 中已改变。在此版本以前,当目标尺寸设为 400x400 时,原尺寸为 200x150 的图像将不会被改变。自 Imagick 3.0.0 起,源图像将会被放大到 400x300 因为这将更好的适合目标尺寸。当使用参数 bestfit 时,必须同时给出宽度和高度。

参数

columns
Width of the image

rows
Height of the image

filter
Refer to the list of filter constants.

blur
The blur factor where > 1 is blurry, \< 1 is sharp.

bestfit
Optional fit parameter.

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Added optional fit parameter. This method now supports proportional scaling. Pass zero as either parameter for proportional scaling.

范例

示例 #1 Imagick::resizeImage

<?php
function resizeImage($imagePath, $width, $height, $filterType, $blur, $bestFit, $cropZoom) {
    //The blur factor where > 1 is blurry, < 1 is sharp.
    $imagick = new \Imagick(realpath($imagePath));

    $imagick->resizeImage($width, $height, $filterType, $blur, $bestFit);

    $cropWidth = $imagick->getImageWidth();
    $cropHeight = $imagick->getImageHeight();

    if ($cropZoom) {
        $newWidth = $cropWidth / 2;
        $newHeight = $cropHeight / 2;

        $imagick->cropimage(
            $newWidth,
            $newHeight,
            ($cropWidth - $newWidth) / 2,
            ($cropHeight - $newHeight) / 2
        );

        $imagick->scaleimage(
            $imagick->getImageWidth() * 4,
            $imagick->getImageHeight() * 4
        );
    }


    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::rollImage

Offsets an image

说明

public bool Imagick::rollImage ( <span class="methodparam">int $x , <span class="methodparam">int $y )

Offsets an image as defined by x and y.

参数

x
The X offset.

y
The Y offset.

返回值

成功时返回 true

范例

示例 #1 Imagick::rollImage

<?php
function rollImage($imagePath, $rollX, $rollY) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->rollimage($rollX, $rollY);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::rotateImage

Rotates an image

说明

public bool Imagick::rotateImage ( <span class="methodparam">mixed $background , float $degrees )

Rotates an image the specified number of degrees. Empty triangles left over from rotating the image are filled with the background color.

参数

background
The background color

degrees
Rotation angle, in degrees. The rotation angle is interpreted as the number of degrees to rotate the image clockwise.

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::rotateImage

<?php
function rotateImage($imagePath, $angle, $color) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->rotateimage($color, $angle);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::rotationalBlurImage

Description

说明

public bool Imagick::rotationalBlurImage ( <span class="methodparam">float $angle [, int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Rotational blurs an image.

参数

angle
The angle to apply the blur over.

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 Imagick::rotationalBlurImage

<?php
function rotationalBlurImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->rotationalBlurImage(3);
    $imagick->rotationalBlurImage(5);
    $imagick->rotationalBlurImage(7);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::roundCorners

Rounds image corners

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::roundCorners ( <span class="methodparam">float $x_rounding , float $y_rounding [, <span class="type">float $stroke_width = 10 [, <span class="type">float $displace = 5 [, <span class="type">float $size_correction = -6 ]]] )

Rounds image corners. The first two parameters control the amount of rounding and the three last parameters can be used to fine-tune the rounding process. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

x_rounding
x rounding

y_rounding
y rounding

stroke_width
stroke width

displace
image displace

size_correction
size correction

范例

示例 #1 Using Imagick::roundCorners:

Rounds the image corners

<?php

$image = new Imagick();
$image->newPseudoImage(100, 100, "magick:rose");
$image->setImageFormat("png");

$image->roundCorners(5,3);
$image->writeImage("rounded.png");
?>

返回值

成功时返回 true

Imagick::sampleImage

Scales an image with pixel sampling

说明

public bool Imagick::sampleImage ( <span class="methodparam">int $columns , int $rows )

Scales an image to the desired dimensions with pixel sampling. Unlike other scaling methods, this method does not introduce any additional color into the scaled image.

参数

columns

rows

返回值

成功时返回 true

Imagick::scaleImage

Scales the size of an image

说明

public bool Imagick::scaleImage ( <span class="methodparam">int $cols , <span class="methodparam">int $rows [, bool $bestfit<span class="initializer"> = false [, <span class="methodparam">bool $legacy<span class="initializer"> = false ]] )

Scales the size of an image to the given dimensions. The other parameter will be calculated if 0 is passed as either param.

Note: 参数 bestfit 的特性在 Imagick 3.0.0 中已改变。在此版本以前,当目标尺寸设为 400x400 时,原尺寸为 200x150 的图像将不会被改变。自 Imagick 3.0.0 起,源图像将会被放大到 400x300 因为这将更好的适合目标尺寸。当使用参数 bestfit 时,必须同时给出宽度和高度。

参数

cols

rows

bestfit

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Added optional fit parameter. This method now supports proportional scaling. Pass zero as either parameter for proportional scaling.

范例

示例 #1 Imagick::scaleImage

<?php
function scaleImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->scaleImage(150, 150, true);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::segmentImage

Segments an image

说明

public bool Imagick::segmentImage ( <span class="methodparam">int $COLORSPACE , float $cluster_threshold , <span class="type">float $smooth_threshold [, <span class="methodparam">bool $verbose<span class="initializer"> = false ] )

Analyses the image and identifies units that are similar. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

COLORSPACE
One of the COLORSPACE constants.

cluster_threshold
A percentage describing minimum number of pixels contained in hexedra before it is considered valid.

smooth_threshold
Eliminates noise from the histogram.

verbose
Whether to output detailed information about recognised classes.

返回值

范例

示例 #1 Imagick::segmentImage

<?php
function segmentImage($imagePath, $colorSpace, $clusterThreshold, $smoothThreshold) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->segmentImage($colorSpace, $clusterThreshold, $smoothThreshold);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

segmentImage($imagePath, \Imagick::COLORSPACE_RGB, 5, 5);

?>

Imagick::selectiveBlurImage

Description

说明

public bool Imagick::selectiveBlurImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $threshold [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Selectively blur an image within a contrast threshold. It is similar to the unsharpen mask that sharpens everything with contrast above a certain threshold.

参数

radius

sigma

threshold

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

范例

示例 #1 Imagick::selectiveBlurImage

<?php
function selectiveBlurImage($imagePath, $radius, $sigma, $threshold, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->selectiveBlurImage($radius, $sigma, $threshold, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::separateImageChannel

Separates a channel from the image

说明

public bool Imagick::separateImageChannel ( <span class="methodparam">int $channel )

Separates a channel from the image and returns a grayscale image. A channel is a particular color component of each pixel in the image.

参数

channel
Which 'channel' to return. For colorspaces other than RGB, you can still use the CHANNEL_RED, CHANNEL_GREEN, CHANNEL_BLUE constants to indicate the 1st, 2nd and 3rd channels.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::separateImageChannel

<?php
function separateImageChannel($imagePath, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->separateimagechannel($channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

separateImageChannel($imagePath, \Imagick::CHANNEL_GREEN);

?>

Imagick::sepiaToneImage

Sepia tones an image

说明

public bool Imagick::sepiaToneImage ( <span class="methodparam">float $threshold )

Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning. Threshold ranges from 0 to QuantumRange and is a measure of the extent of the sepia toning. A threshold of 80 is a good starting point for a reasonable tone.

参数

threshold

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::sepiaToneImage

<?php
function sepiaToneImage($imagePath, $sepia) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->sepiaToneImage($sepia);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::setBackgroundColor

Sets the object's default background color

说明

public bool Imagick::setBackgroundColor ( <span class="methodparam">mixed $background )

Sets the object's default background color.

参数

background

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as a parameter. Previous versions allow only an ImagickPixel object.

Imagick::setColorspace

Set colorspace

说明

public bool Imagick::setColorspace ( <span class="methodparam">int $COLORSPACE )

Sets the global colorspace value for the object. 此方法在Imagick基于ImageMagick 6.5.7以上版本编译时可用。

参数

COLORSPACE
One of the COLORSPACE constants

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setCompression

Sets the object's default compression type

说明

public bool Imagick::setCompression ( <span class="methodparam">int $compression )

Sets the object's default compression type

参数

compression
The compression type. See the Imagick::COMPRESSION_* constants.

返回值

成功时返回 true

Imagick::setCompressionQuality

Sets the object's default compression quality

说明

public bool Imagick::setCompressionQuality ( <span class="methodparam">int $quality )

Sets the object's default compression quality.

Caution

This method only works for new images e.g. those created through Imagick::newPseudoImage. For existing images you should use <span class="methodname">Imagick::setImageCompressionQuality.

参数

quality
An int between 1 and 100, 1 = high compression, 100 low compression.

返回值

成功时返回 true

范例

示例 #1 <span class="function">Imagick::setCompressionQuality

<?php
function setCompressionQuality($imagePath, $quality) {

    $backgroundImagick = new \Imagick(realpath($imagePath));
    $imagick = new \Imagick();
    $imagick->setCompressionQuality($quality);
    $imagick->newPseudoImage(
        $backgroundImagick->getImageWidth(),
        $backgroundImagick->getImageHeight(),
        'canvas:white'
    );

    $imagick->compositeImage(
        $backgroundImagick,
        \Imagick::COMPOSITE_ATOP,
        0,
        0
    );

    $imagick->setFormat("jpg");    
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::setFilename

Sets the filename before you read or write the image

说明

public bool Imagick::setFilename ( <span class="methodparam">string $filename )

Sets the filename before you read or write an image file.

参数

filename

返回值

成功时返回 true

Imagick::setFirstIterator

Sets the Imagick iterator to the first image

说明

public bool Imagick::setFirstIterator ( <span class="methodparam">void )

Sets the Imagick iterator to the first image.

返回值

成功时返回 true

Imagick::setFont

Sets font

说明

public bool Imagick::setFont ( <span class="methodparam">string $font )

Sets object's font property. This method can be used for example to set font for caption: pseudo-format. The font needs to be configured in ImageMagick configuration or a file by the name of font must exist. This method should not be confused with <span class="function">ImagickDraw::setFont which sets the font for a specific ImagickDraw object. 此方法在Imagick基于ImageMagick 6.3.7以上版本编译时可用。

参数

font
Font name or a filename

返回值

成功时返回 true

参见

  • Imagick::getFont
  • ImagickDraw::setFont
  • ImagickDraw::getFont

范例

示例 #1 A Imagick::setFont example

Example of using Imagick::setFont

<?php
/* Create new imagick object */
$im = new Imagick();

/* Set the font for the object */
$im->setFont("example.ttf");

/* Create new caption */
$im->newPseudoImage(100, 100, "caption:Hello");

/* Do something with the image */
?>

Imagick::setFormat

Sets the format of the Imagick object

说明

public bool Imagick::setFormat ( <span class="methodparam">string $format )

Sets the format of the Imagick object.

参数

format

返回值

成功时返回 true

Imagick::setGravity

Sets the gravity

说明

public bool Imagick::setGravity ( <span class="methodparam">int $gravity )

Sets the global gravity property for the Imagick object. 此方法在Imagick基于ImageMagick 6.4.0以上版本编译时可用。

参数

gravity
The gravity property. Refer to the list of gravity constants.

返回值

没有返回值。

Imagick::setImage

Replaces image in the object

说明

public bool Imagick::setImage ( <span class="methodparam">Imagick $replace )

Replaces the current image sequence with the image from replace object.

参数

replace
The replace Imagick object

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 A Imagick::setImage example

An example of using Imagick::setImage()

<?php
/* Create the objects */
$image = new Imagick('source.jpg');
$replace = new Imagick('replace.jpg');

/* source.jpg is replaced with replace.jpg */
$image->setImage($replace);

/* output the image */
header('Content-type: image/jpeg');
echo $image;

?>

Imagick::setImageAlphaChannel

Sets image alpha channel

说明

public bool Imagick::setImageAlphaChannel ( <span class="methodparam">int $mode )

Activate or deactivate image alpha channel. The mode is one of the *`Imagick::ALPHACHANNEL_`** constants. 此方法在Imagick基于ImageMagick 6.3.8以上版本编译时可用。

参数

mode
One of the *`Imagick::ALPHACHANNEL_`** constants

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

参见

Imagick::setImageArtifact

Set image artifact

说明

public bool Imagick::setImageArtifact ( <span class="methodparam">string $artifact , string $value )

Associates an artifact with the image. The difference between image properties and image artifacts is that properties are public and artifacts are private. 此方法在Imagick基于ImageMagick 6.5.7以上版本编译时可用。

参数

artifact
The name of the artifact

value
The value of the artifact

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::getImageArtifact
  • Imagick::deleteImageArtifact

范例

示例 #1 Imagick::setImageArtifact

<?php
function setImageArtifact() {

    $src1 = new \Imagick(realpath("./images/artifact/source1.png"));
    $src2 = new \Imagick(realpath("./images/artifact/source2.png"));

    $src2->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
    $src2->setImageArtifact('compose:args', "1,0,-0.5,0.5");
    $src1->compositeImage($src2, Imagick::COMPOSITE_MATHEMATICS, 0, 0);

    $src1->setImageFormat('png');
    header("Content-Type: image/png");
    echo $src1->getImagesBlob();
}

?>

Imagick::setImageAttribute

Description

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageAttribute ( <span class="methodparam">string $key , string $value )

Warning

本函数还未编写文档,仅有参数列表。

参数

key

value

返回值

成功时返回 true

Imagick::setImageBackgroundColor

Sets the image background color

说明

public bool Imagick::setImageBackgroundColor ( <span class="methodparam">mixed $background )

Sets the image background color.

参数

background

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the parameter. Previous versions allow only an ImagickPixel object.

Imagick::setImageBias

Sets the image bias for any method that convolves an image

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageBias ( <span class="methodparam">float $bias )

Sets the image bias for any method that convolves an image (e.g. Imagick::ConvolveImage()).

参数

bias

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::setImageBias

<?php
//requires ImageMagick version 6.9.0-1 to have an effect on convolveImage
function setImageBias($bias) {
    $imagick = new \Imagick(realpath("images/stack.jpg"));

    $xKernel = array(
        -0.70, 0, 0.70,
        -0.70, 0, 0.70,
        -0.70, 0, 0.70
    );

    $imagick->setImageBias($bias * \Imagick::getQuantum());
    $imagick->convolveImage($xKernel, \Imagick::CHANNEL_ALL);

    $imagick->setImageFormat('png');

    header('Content-type: image/png');
    echo $imagick->getImageBlob();
}

?>

Imagick::setImageBiasQuantum

Description

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public void Imagick::setImageBiasQuantum ( <span class="methodparam">string $bias )

Warning

本函数还未编写文档,仅有参数列表。

参数

bias

返回值

Imagick::setImageBluePrimary

Sets the image chromaticity blue primary point

说明

public bool Imagick::setImageBluePrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Sets the image chromaticity blue primary point.

参数

x

y

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageBorderColor

Sets the image border color

说明

public bool Imagick::setImageBorderColor ( <span class="methodparam">mixed $border )

Sets the image border color.

参数

border
The border color

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as a parameter. Previous versions allow only an ImagickPixel object.

Imagick::setImageChannelDepth

Sets the depth of a particular image channel

说明

public bool Imagick::setImageChannelDepth ( <span class="methodparam">int $channel , int $depth )

Sets the depth of a particular image channel.

参数

channel

depth

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageClipMask

Sets image clip mask

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageClipMask ( <span class="methodparam">Imagick $clip_mask )

Sets image clip mask from another Imagick object. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

clip_mask
The Imagick object containing the clip mask

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::setImageClipMask

<?php
function setImageClipMask($imagePath) {
    $imagick = new \Imagick();
    $imagick->readImage(realpath($imagePath));

    $width = $imagick->getImageWidth();
    $height = $imagick->getImageHeight();

    $clipMask = new \Imagick();
    $clipMask->newPseudoImage(
        $width,
        $height,
        "canvas:transparent"
    );

    $draw = new \ImagickDraw();
    $draw->setFillColor('white');
    $draw->circle(
        $width / 2,
        $height / 2,
        ($width / 2) + ($width / 4),
        $height / 2
    );
    $clipMask->drawImage($draw);
    $imagick->setImageClipMask($clipMask);

    $imagick->negateImage(false);
    $imagick->setFormat("png");

    header("Content-Type: image/png");
    echo $imagick->getImagesBlob();

}

?>

Imagick::setImageColormapColor

Sets the color of the specified colormap index

说明

public bool Imagick::setImageColormapColor ( <span class="methodparam">int $index , ImagickPixel $color )

Sets the color of the specified colormap index.

参数

index

color

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageColorspace

Sets the image colorspace

说明

public bool Imagick::setImageColorspace ( <span class="methodparam">int $colorspace )

Sets the image colorspace. This method should be used when creating new images. To change the colorspace of an existing image, you should use Imagick::transformImageColorspace.

参数

colorspace
One of the COLORSPACE constants

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageCompose

Sets the image composite operator

说明

public bool Imagick::setImageCompose ( <span class="methodparam">int $compose )

Sets the image composite operator, useful for specifying how to composite the image thumbnail when using the Imagick::montageImage() method.

参数

compose

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageCompression

设置图片压缩的类型

说明

bool <span class="methodname">Imagick::setImageCompression ( <span class="methodparam">int $compression )

参数

compression
COMPRESSION 常量里的一种

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageCompressionQuality

设置图片压缩的质量

说明

bool <span class="methodname">Imagick::setImageCompressionQuality ( <span class="methodparam">int $quality )

设置图片压缩的质量

参数

quality
配置压缩质量的整数

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageDelay

Sets the image delay

说明

public bool Imagick::setImageDelay ( <span class="methodparam">int $delay )

Sets the image delay. For an animated image this is the amount of time that this frame of the image should be displayed for, before displaying the next frame.

The delay can be set individually for each frame in an image.

参数

delay
The amount of time expressed in 'ticks' that the image should be displayed for. For animated GIFs there are 100 ticks per second, so a value of 20 would be 20/100 of a second aka 1/5th of a second.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Modify animated Gif with <span class="function">Imagick::setImageDelay

<?php

// Modify an animated Gif so that it's frames are played at a variable speed,
// varying between being shown for 50ms down to 0ms, which will cause the frame
// to be skipped in most browsers.
$imagick = new Imagick(realpath("Test.gif"));
$imagick = $imagick->coalesceImages();

$frameCount = 0;

foreach ($imagick as $frame) {
    $imagick->setImageDelay((($frameCount % 11) * 5));
    $frameCount++;
}

$imagick = $imagick->deconstructImages();

$imagick->writeImages("/path/to/save/output.gif", true);

?>

Imagick::setImageDepth

Sets the image depth

说明

public bool Imagick::setImageDepth ( <span class="methodparam">int $depth )

Sets the image depth.

参数

depth

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageDispose

Sets the image disposal method

说明

public bool Imagick::setImageDispose ( <span class="methodparam">int $dispose )

Sets the image disposal method.

参数

dispose

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageExtent

Sets the image size

说明

public bool Imagick::setImageExtent ( <span class="methodparam">int $columns , int $rows )

Sets the image size (i.e. columns & rows).

参数

columns

rows

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageFilename

Sets the filename of a particular image

说明

public bool Imagick::setImageFilename ( <span class="methodparam">string $filename )

Sets the filename of a particular image in a sequence.

参数

filename

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageFormat

为图片设置指定的格式

说明

bool <span class="methodname">Imagick::setImageFormat ( <span class="methodparam">string $format )

为图片设置指定的格式

参数

format
表示图片格式的一个字符串。支持的格式依赖于 ImageMagick 的安装。

返回值

成功时返回 true

Imagick::setImageGamma

Sets the image gamma

说明

public bool Imagick::setImageGamma ( <span class="methodparam">float $gamma )

Sets the image gamma.

参数

gamma

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageGravity

Sets the image gravity

说明

public bool Imagick::setImageGravity ( <span class="methodparam">int $gravity )

Sets the gravity property for the current image. This method can be used to set the gravity property for a single image sequence. 此方法在Imagick基于ImageMagick 6.4.4以上版本编译时可用。

参数

gravity
The gravity property. Refer to the list of gravity constants.

返回值

没有返回值。

Imagick::setImageGreenPrimary

Sets the image chromaticity green primary point

说明

public bool Imagick::setImageGreenPrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Sets the image chromaticity green primary point.

参数

x

y

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageIndex

Set the iterator position

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageIndex ( <span class="methodparam">int $index )

Set the iterator to the position in the image list specified with the index parameter.

This method has been deprecated. See <span class="function">Imagick::setIteratorIndex.

参数

index
The position to set the iterator to

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageInterlaceScheme

Sets the image compression

说明

public bool Imagick::setImageInterlaceScheme ( <span class="methodparam">int $interlace_scheme )

Sets the image compression.

参数

interlace_scheme

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageInterpolateMethod

Sets the image interpolate pixel method

说明

public bool Imagick::setImageInterpolateMethod ( int $method )

Sets the image interpolate pixel method.

参数

method
The method is one of the *`Imagick::INTERPOLATE_`** constants

返回值

成功时返回 true

Imagick::setImageIterations

Sets the image iterations

说明

public bool Imagick::setImageIterations ( <span class="methodparam">int $iterations )

Sets the number of iterations an animated image is repeated.

参数

iterations
The number of iterations the image should loop over. Set to '0' to loop continuously.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Basic <span class="function">Imagick::setImageIterations usage

<?php

$imagick = new Imagick(realpath("Test.gif"));

$imagick = $imagick->coalesceImages();
$imagick->setImageIterations(1);
$imagick = $imagick->deconstructImages();

$imagick->writeImages('/path/to/save/OnceOnly.gif', true);

?>

Imagick::setImageMatte

Sets the image matte channel

说明

public bool Imagick::setImageMatte ( <span class="methodparam">bool $matte )

Sets the image matte channel. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

matte
True activates the matte channel and false disables it.

返回值

成功时返回 true

Imagick::setImageMatteColor

Sets the image matte color

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageMatteColor ( <span class="methodparam">mixed $matte )

Sets the image matte color.

参数

matte

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the parameter. Previous versions allow only an ImagickPixel object.

Imagick::setImageOpacity

Sets the image opacity level

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public bool Imagick::setImageOpacity ( <span class="methodparam">float $opacity )

Sets the image to the specified opacity level. 此方法在Imagick基于ImageMagick 6.3.1以上版本编译时可用。 This method operates on all channels, which means that for example opacity value of 0.5 will set all transparent areas to partially opaque. To add transparency to areas that are not already transparent use Imagick::evaluateImage()

参数

opacity
The level of transparency: 1.0 is fully opaque and 0.0 is fully transparent.

返回值

成功时返回 true

范例

示例 #1 A Imagick::setImageOpacity example

An example of using Imagick::setImageOpacity()

<?php
/* Create the object */
$image = new Imagick('source.png');

/* Set the opacity */
$image->setImageOpacity(0.7);

/* output the image */
header('Content-type: image/png');
echo $image;

?>

Imagick::setImageOrientation

Sets the image orientation

说明

public bool Imagick::setImageOrientation ( <span class="methodparam">int $orientation )

Sets the image orientation.

参数

orientation
One of the orientation constants

返回值

成功时返回 true

范例

示例 #1 Imagick::setImageOrientation

<?php
//Doesn't appear to do anything
function setImageOrientation($imagePath, $orientationType) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setImageOrientation($orientationType);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::setImagePage

Sets the page geometry of the image

说明

public bool Imagick::setImagePage ( <span class="methodparam">int $width , int $height , int $x , int $y )

Sets the page geometry of the image.

参数

width

height

x

y

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageProfile

Adds a named profile to the Imagick object

说明

public bool Imagick::setImageProfile ( <span class="methodparam">string $name , string $profile )

Adds a named profile to the Imagick object. If a profile with the same name already exists, it is replaced. This method differs from the Imagick::ProfileImage() method in that it does not apply any CMS color profiles.

参数

name

profile

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageProperty

Sets an image property

说明

public bool Imagick::setImageProperty ( <span class="methodparam">string $name , string $value )

Sets a named property to the image. 此方法在Imagick基于ImageMagick 6.3.2以上版本编译时可用。

参数

name

value

范例

示例 #1 Using <span class="function">Imagick::setImageProperty:

Setting and getting image properties

<?php
$image = new Imagick();
$image->newImage(300, 200, "black");

$image->setImageProperty('Exif:Make', 'Imagick');
echo $image->getImageProperty('Exif:Make');
?>

参见

  • Imagick::getImageProperty

返回值

成功时返回 true

Imagick::setImageRedPrimary

Sets the image chromaticity red primary point

说明

public bool Imagick::setImageRedPrimary ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Sets the image chromaticity red primary point.

参数

x

y

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageRenderingIntent

Sets the image rendering intent

说明

public bool Imagick::setImageRenderingIntent ( <span class="methodparam">int $rendering_intent )

Sets the image rendering intent.

参数

rendering_intent

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageResolution

Sets the image resolution

说明

public bool Imagick::setImageResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

Sets the image resolution.

参数

x_resolution

y_resolution

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::setImageResolution

<?php
function setImageResolution($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setImageResolution(50, 50);

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::setImageScene

Sets the image scene

说明

public bool Imagick::setImageScene ( <span class="methodparam">int $scene )

Sets the image scene.

参数

scene

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setImageTicksPerSecond

Sets the image ticks-per-second

说明

public bool Imagick::setImageTicksPerSecond ( <span class="methodparam">int $ticks_per_second )

Adjust the amount of time that a frame of an animated image is displayed for.

Note:

For animated GIFs, this function does not change the number of 'image ticks' per second, which is always defined as 100. Instead it adjusts the amount of time that the frame is displayed for to simulate the change in 'ticks per second'.

For example, for an animated GIF where each frame is displayed for 20 ticks (1/5 of a second) when this method is called on each frame of that image with an argument of 50 the frames are adjusted to be displayed for 40 ticks (2/5 of a second) and the animation will play at half the original speed.

参数

ticks_per_second
The duration for which an image should be displayed expressed in ticks per second.

返回值

成功时返回 true

范例

示例 #1 Modify animated Gif with <span class="function">Imagick::setImageTicksPerSecond

<?php

// Modify an animated gif so the first half of the gif is played at half the
// speed it currently is, and the second half to be played at double the speed
// it currently is

$imagick = new Imagick(realpath("Test.gif"));
$imagick = $imagick->coalesceImages();

$totalFrames = $imagick->getNumberImages();

$frameCount = 0;

foreach ($imagick as $frame) {
    $imagick->setImageTicksPerSecond(50);

    if ($frameCount < ($totalFrames / 2)) {
        // Modify the frame to be displayed for twice as long as it currently is
        $imagick->setImageTicksPerSecond(50);
    } else {
        // Modify the frame to be displayed for half as long as it currently is
        $imagick->setImageTicksPerSecond(200);
    }

    $frameCount++;
}

$imagick = $imagick->deconstructImages();

$imagick->writeImages("/path/to/save/output.gif", true);

?>

Imagick::setImageType

Sets the image type

说明

public bool Imagick::setImageType ( <span class="methodparam">int $image_type )

Sets the image type.

参数

image_type

返回值

成功时返回 true

Imagick::setImageUnits

Sets the image units of resolution

说明

public bool Imagick::setImageUnits ( <span class="methodparam">int $units )

Sets the image units of resolution.

参数

units

返回值

成功时返回 true

Imagick::setImageVirtualPixelMethod

Sets the image virtual pixel method

说明

public bool Imagick::setImageVirtualPixelMethod ( int $method )

Sets the image virtual pixel method.

参数

method

返回值

成功时返回 true

Imagick::setImageWhitePoint

Sets the image chromaticity white point

说明

public bool Imagick::setImageWhitePoint ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Sets the image chromaticity white point.

参数

x

y

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::setInterlaceScheme

Sets the image compression

说明

public bool Imagick::setInterlaceScheme ( <span class="methodparam">int $interlace_scheme )

Sets the image compression.

参数

interlace_scheme

返回值

成功时返回 true

Imagick::setIteratorIndex

Set the iterator position

说明

public bool Imagick::setIteratorIndex ( <span class="methodparam">int $index )

Set the iterator to the position in the image list specified with the index parameter. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

index
The position to set the iterator to

返回值

成功时返回 true

范例

示例 #1 Using <span class="function">Imagick::setIteratorIndex:

Create images, set and get the iterator index

<?php
$im = new Imagick();
$im->newImage(100, 100, new ImagickPixel("red"));
$im->newImage(100, 100, new ImagickPixel("green"));
$im->newImage(100, 100, new ImagickPixel("blue"));

$im->setIteratorIndex(1);
echo $im->getIteratorIndex();
?>

参见

  • Imagick::getIteratorIndex
  • Imagick::getImageIndex
  • Imagick::setImageIndex

Imagick::setLastIterator

Sets the Imagick iterator to the last image

说明

public bool Imagick::setLastIterator ( <span class="methodparam">void )

Sets the Imagick iterator to the last image.

返回值

成功时返回 true

Imagick::setOption

Set an option

说明

public bool Imagick::setOption ( <span class="methodparam">string $key , string $value )

Associates one or more options with the wand.

参数

key

value

返回值

成功时返回 true

范例

示例 #1 Attempt to reach '$extent' size<span class="function">Imagick::setOption

<?php
    function renderJPG($extent) {
        $imagePath = $this->control->getImagePath();
        $imagick = new \Imagick(realpath($imagePath));
        $imagick->setImageFormat('jpg');
        $imagick->setOption('jpeg:extent', $extent);
        header("Content-Type: image/jpg");
        echo $imagick->getImageBlob();
    }

?>

示例 #2 Imagick::setOption

<?php
    function renderPNG($imagePath, $format) {

        $imagick = new \Imagick(realpath($imagePath));
        $imagick->setImageFormat('png');
        $imagick->setOption('png:format', $format);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

    //Save as 64bit PNG.
    renderPNG($imagePath, 'png64');

?>

示例 #3 Imagick::setOption

<?php
    function renderCustomBitDepthPNG() {
        $imagePath = $this->control->getImagePath();
        $imagick = new \Imagick(realpath($imagePath));
        $imagick->setImageFormat('png');

        $imagick->setOption('png:bit-depth', '16');
        $imagick->setOption('png:color-type', 6);
        header("Content-Type: image/png");
        $crash = true;
        if ($crash) {
            echo $imagick->getImageBlob();
        }
        else {
            $tempFilename = tempnam('./', 'imagick');
            $imagick->writeimage(realpath($tempFilename));
            echo file_get_contents($tempFilename);
        }
    }

?>

Imagick::setPage

Sets the page geometry of the Imagick object

说明

public bool Imagick::setPage ( <span class="methodparam">int $width , int $height , int $x , int $y )

Sets the page geometry of the Imagick object.

参数

width

height

x

y

返回值

成功时返回 true

Imagick::setPointSize

Sets point size

说明

public bool Imagick::setPointSize ( <span class="methodparam">float $point_size )

Sets object's point size property. This method can be used for example to set font size for caption: pseudo-format. 此方法在Imagick基于ImageMagick 6.3.7以上版本编译时可用。

参数

point_size
Point size

返回值

成功时返回 true

参见

  • Imagick::getPointSize

范例

示例 #1 A Imagick::setPointSize example

Example of using Imagick::setPointSize

<?php
/* Create new imagick object */
$im = new Imagick();

/* Set the font for the object */
$im->setFont("example.ttf");

/* Set the point size */
$im->setPointSize(12);

/* Create new caption */
$im->newPseudoImage(100, 100, "caption:Hello");

/* Do something with the image */
?>

Imagick::setProgressMonitor

Description

说明

public bool Imagick::setProgressMonitor ( <span class="methodparam">callable $callback )

Set a callback that will be called during the processing of the Imagick image.

参数

callback
The progress function to call. It should return true if image processing should continue, or false if it should be cancelled. The offset parameter indicates the progress and the span parameter indicates the total amount of work needed to be done.

bool <span class="replaceable">callback ( mixed $offset , <span class="methodparam"> mixed $span )

Caution The values passed to the callback function are not consistent. In particular the span parameter can increase during image processing. Because of this calculating the percentage complete of an image operation is not trivial.

返回值

成功时返回 true

范例

示例 #1 Imagick::setProgressMonitor

<?php
        $abortReason = null;

        try {
            $imagick = new \Imagick(realpath($this->control->getImagePath()));
            $startTime = time();

            $callback = function ($offset, $span)  use ($startTime, &$abortReason) {
                if (((100 * $offset) / $span)  > 20) {
                    $abortReason = "Processing reached 20%";
                    return false;
                }

                $nowTime = time();

                if ($nowTime - $startTime > 5) {
                    $abortReason = "Image processing took more than 5 seconds";
                    return false;
                }
                if (($offset % 5) == 0) {
                    echo "Progress: $offset / $span <br/>";
                }
                return true;
            };

            $imagick->setProgressMonitor($callback);

            $imagick->waveImage(2, 15);

            echo "Data len is: ".strlen($imagick->getImageBlob());
        }
        catch(\ImagickException $e) {
            if ($abortReason != null) {
                echo "Image processing was aborted: ".$abortReason."<br/>";
            }
            else {
                echo "ImagickException caught: ".$e->getMessage()." Exception type is ".get_class($e);
            }
        }

?>

Imagick::setRegistry

Description

说明

public <span class="modifier">static bool <span class="methodname">Imagick::setRegistry ( <span class="methodparam">string $key , string $value )

Sets the ImageMagick registry entry named key to value. This is most useful for setting "temporary-path" which controls where ImageMagick creates temporary images e.g. while processing PDFs.

参数

key

value

返回值

成功时返回 true

Imagick::setResolution

Sets the image resolution

说明

public bool Imagick::setResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

Sets the image resolution.

参数

x_resolution
The horizontal resolution.

y_resolution
The vertical resolution.

返回值

成功时返回 true

注释

Imagick::setResolution must be called before loading or creating an image.

参见

  • Imagick::setImageResolution
  • Imagick::getImageResolution

Imagick::setResourceLimit

Sets the limit for a particular resource

说明

public <span class="modifier">static bool <span class="methodname">Imagick::setResourceLimit ( <span class="methodparam">int $type , <span class="methodparam">int $limit )

This method is used to modify the resource limits of the underlying ImageMagick library.

参数

type
Refer to the list of resourcetype constants.

limit
One of the resourcetype constants. The unit depends on the type of the resource being limited.

返回值

成功时返回 true

参见

  • Imagick::getResourceLimit

Imagick::setSamplingFactors

Sets the image sampling factors

说明

public bool Imagick::setSamplingFactors ( <span class="methodparam">array $factors )

Sets the image sampling factors.

参数

factors

返回值

成功时返回 true

范例

示例 #1 Imagick::setSamplingFactors

<?php
function setSamplingFactors($imagePath) {

    $imagePath = "../imagick/images/FineDetail.png";
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setImageFormat('jpg');
    $imagick->setSamplingFactors(array('2x2', '1x1', '1x1'));

    $compressed = $imagick->getImageBlob();


    $reopen = new \Imagick();
    $reopen->readImageBlob($compressed);

    $reopen->resizeImage(
        $reopen->getImageWidth() * 4,
        $reopen->getImageHeight() * 4,
        \Imagick::FILTER_POINT,
        1
    );

    header("Content-Type: image/jpg");
    echo $reopen->getImageBlob();
}

?>

Imagick::setSize

Sets the size of the Imagick object

说明

public bool Imagick::setSize ( <span class="methodparam">int $columns , int $rows )

Sets the size of the Imagick object. Set it before you read a raw image format such as RGB, GRAY, or CMYK.

参数

columns

rows

返回值

成功时返回 true

Imagick::setSizeOffset

Sets the size and offset of the Imagick object

说明

public bool Imagick::setSizeOffset ( <span class="methodparam">int $columns , int $rows , int $offset )

Sets the size and offset of the Imagick object. Set it before you read a raw image format such as RGB, GRAY, or CMYK. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

columns
The width in pixels.

rows
The height in pixels.

offset
The image offset.

返回值

成功时返回 true

Imagick::setType

Sets the image type attribute

说明

public bool Imagick::setType ( <span class="methodparam">int $image_type )

Sets the image type attribute.

参数

image_type

返回值

成功时返回 true

Imagick::shadeImage

Creates a 3D effect

说明

public bool Imagick::shadeImage ( <span class="methodparam">bool $gray , float $azimuth , <span class="type">float $elevation )

Shines a distant light on an image to create a three-dimensional effect. You control the positioning of the light with azimuth and elevation; azimuth is measured in degrees off the x axis and elevation is measured in pixels above the Z axis. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

gray
A value other than zero shades the intensity of each pixel.

azimuth
Defines the light source direction.

elevation
Defines the light source direction.

返回值

成功时返回 true

错误/异常

Throws ImagickException on failure.

范例

示例 #1 Imagick::shadeImage

<?php
function shadeImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->shadeImage(true, 45, 20);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::shadowImage

Simulates an image shadow

说明

public bool Imagick::shadowImage ( <span class="methodparam">float $opacity , float $sigma , <span class="type">int $x , <span class="type">int $y )

Simulates an image shadow.

参数

opacity

sigma

x

y

返回值

成功时返回 true

范例

示例 #1 Imagick::shadowImage

<?php
function shadowImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->shadowImage(0.4, 10, 50, 5);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::sharpenImage

Sharpens an image

说明

public bool Imagick::sharpenImage ( <span class="methodparam">float $radius , float $sigma [, <span class="type">int $channel = Imagick::CHANNEL_DEFAULT ] )

Sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and <span class="function">Imagick::sharpenImage selects a suitable radius for you.

参数

radius

sigma

channel

返回值

成功时返回 true

范例

示例 #1 Imagick::sharpenImage

<?php
function sharpenImage($imagePath, $radius, $sigma, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->sharpenimage($radius, $sigma, $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::shaveImage

Shaves pixels from the image edges

说明

public bool Imagick::shaveImage ( <span class="methodparam">int $columns , int $rows )

Shaves pixels from the image edges. It allocates the memory necessary for the new Image structure and returns a pointer to the new image.

参数

columns

rows

返回值

成功时返回 true

范例

示例 #1 Imagick::shaveImage

<?php
function shaveImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->shaveImage(100, 50);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::shearImage

Creating a parallelogram

说明

public bool Imagick::shearImage ( <span class="methodparam">mixed $background , float $x_shear , <span class="type">float $y_shear )

Slides one edge of an image along the X or Y axis, creating a parallelogram. An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis. The amount of the shear is controlled by a shear angle. For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis. Empty triangles left over from shearing the image are filled with the background color.

参数

background
The background color

x_shear
The number of degrees to shear on the x axis

y_shear
The number of degrees to shear on the y axis

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::shearImage

<?php
function shearImage($imagePath, $color, $shearX, $shearY) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->shearimage($color, $shearX, $shearY);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::sigmoidalContrastImage

Adjusts the contrast of an image

说明

public bool Imagick::sigmoidalContrastImage ( <span class="methodparam">bool $sharpen , float $alpha , <span class="type">float $beta [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Adjusts the contrast of an image with a non-linear sigmoidal contrast algorithm. Increase the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows. Contrast indicates how much to increase the contrast (0 is none; 3 is typical; 20 is pushing it); mid-point indicates where midtones fall in the resultant image (0 is white; 50 is middle-gray; 100 is black). Set sharpen to true to increase the image contrast otherwise the contrast is reduced.

See also » ImageMagick v6 Examples - Image Transformations — Sigmoidal Non-linearity Contrast

参数

sharpen
If true increase the contrast, if false decrease the contrast.

alpha
The amount of contrast to apply. 1 is very little, 5 is a significant amount, 20 is extreme.

beta
Where the midpoint of the gradient will be. This value should be in the range 0 to 1 - mutliplied by the quantum value for ImageMagick.

channel
Which color channels the contrast will be applied to.

返回值

成功时返回 true

范例

示例 #1 Create a gradient image using <span class="function">Imagick::sigmoidalContrastImage suitable for blending two images together smoothly, with the blending defined by $contrast and $the midpoint

<?php

function generateBlendImage($width, $height, $contrast = 10, $midpoint = 0.5) {
    $imagick = new Imagick();
    $imagick->newPseudoImage($width, $height, 'gradient:black-white');
    $quanta = $imagick->getQuantumRange();
    $imagick->sigmoidalContrastImage(true, $contrast, $midpoint * $quanta["quantumRangeLong"]);

    return $imagick; 
}

?>

错误/异常

错误时抛出 ImagickException。

Imagick::sketchImage

Simulates a pencil sketch

说明

public bool Imagick::sketchImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $angle )

Simulates a pencil sketch. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and Imagick::sketchImage() selects a suitable radius for you. Angle gives the angle of the blurring motion. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

radius
The radius of the Gaussian, in pixels, not counting the center pixel

sigma
The standard deviation of the Gaussian, in pixels.

angle
Apply the effect along this angle.

返回值

成功时返回 true

范例

示例 #1 Imagick::sketchImage

<?php
function sketchImage($imagePath, $radius, $sigma, $angle) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->sketchimage($radius, $sigma, $angle);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::smushImages

Description

说明

public Imagick Imagick::smushImages ( <span class="methodparam">bool $stack , int $offset )

Takes all images from the current image pointer to the end of the image list and smushs them to each other top-to-bottom if the stack parameter is true, otherwise left-to-right.

参数

stack

offset

返回值

The new smushed image.

范例

示例 #1 Imagick::smushImages

<?php
function smushImages($imagePath, $imagePath2) {

    $imagick = new \Imagick(realpath($imagePath));
    $imagick2 = new \Imagick(realpath($imagePath2));

    $imagick->addimage($imagick2);
    $smushed = $imagick->smushImages(false, 50);
    $smushed->setImageFormat('jpg');
    header("Content-Type: image/jpg");
    echo $smushed->getImageBlob();
}

?>

Imagick::solarizeImage

Applies a solarizing effect to the image

说明

public bool Imagick::solarizeImage ( <span class="methodparam">int $threshold )

Applies a special effect to the image, similar to the effect achieved in a photo darkroom by selectively exposing areas of photo sensitive paper to light. Threshold ranges from 0 to QuantumRange and is a measure of the extent of the solarization.

参数

threshold

返回值

成功时返回 true

范例

示例 #1 Imagick::solarizeImage

<?php
function solarizeImage($imagePath, $solarizeThreshold) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->solarizeImage($solarizeThreshold * \Imagick::getQuantum());
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::sparseColorImage

Interpolates colors

说明

public bool Imagick::sparseColorImage ( <span class="methodparam">int $SPARSE_METHOD , <span class="type">array $arguments [, <span class="methodparam">int $channel<span class="initializer"> = Imagick::CHANNEL_DEFAULT ] )

Given the arguments array containing numeric values this method interpolates the colors found at those coordinates across the whole image using sparse_method. 此方法在Imagick基于ImageMagick 6.4.5以上版本编译时可用。

参数

SPARSE_METHOD
Refer to this list of sparse method constants

arguments
An array containing the coordinates. The array is in format array(1,1, 2,45)

channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channel constants using bitwise operators. 缺省为Imagick::CHANNEL_DEFAULT. 参考此 通道常数列表

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 SPARSECOLORMETHOD_BARYCENTRIC <span class="function">Imagick::sparseColorImage

<?php
    function renderImageBarycentric2() {
        $points = [
            [0.30, 0.10, 'red'],
            [0.10, 0.80, 'blue'],
            [0.70, 0.60, 'lime'],
            [0.80, 0.20, 'yellow'],
        ];
        $imagick = createGradientImage(
            400, 400,
            $points,
            \Imagick::SPARSECOLORMETHOD_BARYCENTRIC
        );
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

?>

示例 #2 SPARSECOLORMETHOD_BILINEAR <span class="function">Imagick::sparseColorImage

<?php
    function renderImageBilinear() {
        $points = [[0.30, 0.10, 'red'], [0.10, 0.80, 'blue'], [0.70, 0.60, 'lime'], [0.80, 0.20, 'yellow'],];
        $imagick = createGradientImage(500, 500, $points, \Imagick::SPARSECOLORMETHOD_BILINEAR);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

?>

示例 #3 SPARSECOLORMETHOD_SPEPARDS <span class="function">Imagick::sparseColorImage

<?php
    function renderImageShepards() {
        $points = [
            [0.30, 0.10, 'red'],
            [0.10, 0.80, 'blue'],
            [0.70, 0.60, 'lime'],
            [0.80, 0.20, 'yellow'],
        ];
        $imagick = createGradientImage(600, 600, $points, \Imagick::SPARSECOLORMETHOD_SPEPARDS);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

?>

示例 #4 SPARSECOLORMETHOD_VORONOI <span class="function">Imagick::sparseColorImage

<?php
    function renderImageVoronoi() {
        $points = [
            [0.30, 0.10, 'red'],
            [0.10, 0.80, 'blue'],
            [0.70, 0.60, 'lime'],
            [0.80, 0.20, 'yellow'],
        ];
        $imagick = createGradientImage(500, 500, $points, \Imagick::SPARSECOLORMETHOD_VORONOI);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

?>

示例 #5 SPARSECOLORMETHOD_BARYCENTRIC <span class="function">Imagick::sparseColorImage

<?php
    function renderImageBarycentric() {
        $points = [
            [0, 0, 'skyblue'],
            [-1, 1, 'skyblue'],
            [1, 1, 'black'],
        ];
        $imagick = createGradientImage(600, 200, $points, \Imagick::SPARSECOLORMETHOD_BARYCENTRIC);
        header("Content-Type: image/png");
        echo $imagick->getImageBlob();
    }

?>

示例 #6 createGradientImage is used by other examples. <span class="function">Imagick::sparseColorImage

<?php
function createGradientImage($width, $height, $colorPoints, $sparseMethod, $absolute = false) {

    $imagick = new \Imagick();
    $imagick->newImage($width, $height, "white");
    $imagick->setImageFormat("png");

    $barycentricPoints = array();

    foreach ($colorPoints as $colorPoint) {

        if ($absolute == true) {
            $barycentricPoints[] = $colorPoint[0];
            $barycentricPoints[] = $colorPoint[1];
        }
        else {
            $barycentricPoints[] = $colorPoint[0] * $width;
            $barycentricPoints[] = $colorPoint[1] * $height;
        }

        if (is_string($colorPoint[2])) {
            $imagickPixel = new \ImagickPixel($colorPoint[2]);
        }
        else if ($colorPoint[2] instanceof \ImagickPixel) {
            $imagickPixel = $colorPoint[2];
        }
        else{
            $errorMessage = sprintf(
                "Value %s is neither a string nor an ImagickPixel class. Cannot use as a color.",
                $colorPoint[2]
            );

            throw new \InvalidArgumentException(
                $errorMessage
            );
        }

        $red = $imagickPixel->getColorValue(\Imagick::COLOR_RED);
        $green = $imagickPixel->getColorValue(\Imagick::COLOR_GREEN);
        $blue = $imagickPixel->getColorValue(\Imagick::COLOR_BLUE);
        $alpha = $imagickPixel->getColorValue(\Imagick::COLOR_ALPHA);

        $barycentricPoints[] = $red;
        $barycentricPoints[] = $green;
        $barycentricPoints[] = $blue;
        $barycentricPoints[] = $alpha;
    }

    $imagick->sparseColorImage($sparseMethod, $barycentricPoints);

    return $imagick;
}

?>

Imagick::spliceImage

Splices a solid color into the image

说明

public bool Imagick::spliceImage ( <span class="methodparam">int $width , int $height , int $x , int $y )

Splices a solid color into the image.

参数

width

height

x

y

返回值

成功时返回 true

范例

示例 #1 Imagick::spliceImage

<?php
function spliceImage($imagePath, $startX, $startY, $width, $height) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->spliceImage($width, $height, $startX, $startY);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::spreadImage

Randomly displaces each pixel in a block

说明

public bool Imagick::spreadImage ( <span class="methodparam">float $radius )

Special effects method that randomly displaces each pixel in a block defined by the radius parameter.

参数

radius

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::spreadImage

<?php
function spreadImage($imagePath, $radius) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->spreadImage($radius);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::statisticImage

Description

说明

public bool Imagick::statisticImage ( <span class="methodparam">int $type , <span class="methodparam">int $width , int $height [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Replace each pixel with corresponding statistic from the neighborhood of the specified width and height.

参数

type

width

height

channel

返回值

成功时返回 true

范例

示例 #1 Imagick::statisticImage

<?php
function statisticImage($imagePath, $statisticType, $width, $height, $channel) {
    $imagick = new \Imagick(realpath($imagePath));

    $imagick->statisticImage(
        $statisticType,
        $width,
        $height,
        $channel
    );

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

statisticImage($imagePath, \Imagick::STATISTIC_MEDIAN, 5, 5, \Imagick::CHANNEL_DEFAULT);

?>

Imagick::steganoImage

Hides a digital watermark within the image

说明

public Imagick Imagick::steganoImage ( <span class="methodparam">Imagick $watermark_wand , <span class="type">int $offset )

Hides a digital watermark within the image. Recover the hidden watermark later to prove that the authenticity of an image. Offset defines the start position within the image to hide the watermark.

参数

watermark_wand

offset

返回值

成功时返回 true

Imagick::stereoImage

Composites two images

说明

public bool Imagick::stereoImage ( <span class="methodparam">Imagick $offset_wand )

Composites two images and produces a single image that is the composite of a left and right image of a stereo pair.

参数

offset_wand

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::stripImage

去掉图片的所有配置和设置

说明

bool <span class="methodname">Imagick::stripImage ( <span class="methodparam">void )

去掉图片的所有配置和设置

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

Imagick::subImageMatch

Description

说明

public Imagick Imagick::subImageMatch ( <span class="methodparam">Imagick $Imagick [, array &$offset [, <span class="type">float &$similarity ]] )

Searches for a subimage in the current image and returns a similarity image such that an exact match location is completely white and if none of the pixels match, black, otherwise some gray level in-between. You can also pass in the optional parameters bestMatch and similarity. After calling the function similarity will be set to the 'score' of the similarity between the subimage and the matching position in the larger image, bestMatch will contain an associative array with elements x, y, width, height that describe the matching region.

参数

Imagick

offset

similarity
A new image that displays the amount of similarity at each pixel.

返回值

范例

示例 #1 Imagick::subImageMatch

<?php
function subImageMatch($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick2 = clone $imagick;
    $imagick2->cropimage(40, 40, 250, 110);
    $imagick2->vignetteimage(0, 1, 3, 3);

    $similarity = null;
    $bestMatch = null;
    $comparison = $imagick->subImageMatch($imagick2, $bestMatch, $similarity);

    $comparison->setImageFormat('png');
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::swirlImage

Swirls the pixels about the center of the image

说明

bool <span class="methodname">Imagick::swirlImage ( <span class="methodparam">float $degrees )

Swirls the pixels about the center of the image, where degrees indicates the sweep of the arc through which each pixel is moved. You get a more dramatic effect as the degrees move from 1 to 360.

参数

degrees

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::swirlImage

<?php
function swirlImage($imagePath, $swirl) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->swirlImage($swirl);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::textureImage

Repeatedly tiles the texture image

说明

Imagick <span class="methodname">Imagick::textureImage ( <span class="methodparam">Imagick $texture_wand )

Repeatedly tiles the texture image across and down the image canvas.

参数

texture_wand
Imagick object to use as texture image

返回值

Returns a new Imagick object that has the repeated texture applied.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::textureImage

<?php
function textureImage($imagePath) {
    $image = new \Imagick();
    $image->newImage(640, 480, new \ImagickPixel('pink'));
    $image->setImageFormat("jpg");
    $texture = new \Imagick(realpath($imagePath));
    $texture->scaleimage($image->getimagewidth() / 4, $image->getimageheight() / 4);
    $image = $image->textureImage($texture);
    header("Content-Type: image/jpg");
    echo $image;
}

?>

Imagick::thresholdImage

Changes the value of individual pixels based on a threshold

说明

public bool Imagick::thresholdImage ( <span class="methodparam">float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Changes the value of individual pixels based on the intensity of each pixel compared to threshold. The result is a high-contrast, two color image.

参数

threshold

channel

返回值

成功时返回 true

范例

示例 #1 Imagick::thresholdImage

<?php
function thresholdimage($imagePath, $threshold, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->thresholdimage($threshold * \Imagick::getQuantum(), $channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::thumbnailImage

Changes the size of an image

说明

public bool Imagick::thumbnailImage ( <span class="methodparam">int $columns , int $rows [, bool $bestfit = false [, bool $fill<span class="initializer"> = false [, <span class="methodparam">bool $legacy<span class="initializer"> = false ]]] )

Changes the size of an image to the given dimensions and removes any associated profiles. The goal is to produce small, low cost thumbnail images suited for display on the Web. If true is given as a third parameter then columns and rows parameters are used as maximums for each side. Both sides will be scaled down until they match or are smaller than the parameter given for the side.

Note: 参数 bestfit 的特性在 Imagick 3.0.0 中已改变。在此版本以前,当目标尺寸设为 400x400 时,原尺寸为 200x150 的图像将不会被改变。自 Imagick 3.0.0 起,源图像将会被放大到 400x300 因为这将更好的适合目标尺寸。当使用参数 bestfit 时,必须同时给出宽度和高度。

参数

columns
Image width

rows
Image height

bestfit
Whether to force maximum values

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::thumbnailImage

<?php
function thumbnailImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setbackgroundcolor('rgb(64, 64, 64)');
    $imagick->thumbnailImage(100, 100, true, true);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::tintImage

Applies a color vector to each pixel in the image

说明

public bool Imagick::tintImage ( <span class="methodparam">mixed $tint , mixed $opacity [, <span class="type">bool $legacy = false ] )

Applies a color vector to each pixel in the image. The length of the vector is 0 for black and white and at its maximum for the midtones. The vector weighing function is f(x)=(1-(4.0*((x-0.5)*(x-0.5)))).

参数

tint

opacity

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as the first parameter and a float representing the opacity value as the second parameter. Previous versions allow only an ImagickPixel objects.

范例

示例 #1 Imagick::tintImage

<?php
function tintImage($r, $g, $b, $a) {
    $a = $a / 100;

    $imagick = new \Imagick();
    $imagick->newPseudoImage(400, 400, 'gradient:black-white');

    $tint = new \ImagickPixel("rgb($r, $g, $b)");
    $opacity = new \ImagickPixel("rgb(128, 128, 128, $a)");
    $imagick->tintImage($tint, $opacity);
    $imagick->setImageFormat('png');
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::__toString

Returns the image as a string

说明

public string Imagick::__toString ( <span class="methodparam">void )

Returns the current image as string. This will only return a single image; it should not be used for Imagick objects that contain multiple images e.g. an animated GIF or PDF with multiple pages.

参数

此函数没有参数。

返回值

Returns the string content on success or an empty string on failure.

参见

  • Imagick::getImageBlob
  • Imagick::getImagesBlob

Imagick::transformImage

Convenience method for setting crop size and the image geometry

Warning

此函数在 Imagick 3.4.4 中被 废弃,强烈建议不要应用此函数。

说明

public Imagick Imagick::transformImage ( <span class="methodparam">string $crop , string $geometry )

A convenience method for setting crop size and the image geometry from strings. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

crop
A crop geometry string. This geometry defines a subregion of the image to crop.

geometry
An image geometry string. This geometry defines the final size of the image.

返回值

Returns an Imagick object containing the transformed image.

范例

示例 #1 Using <span class="function">Imagick::transformImage:

The example creates a 100x100 black image.

<?php
$image = new Imagick();
$image->newImage(300, 200, "black");
$new_image = $image->transformImage("100x100", "100x100");
$new_image->writeImage('test_out.jpg');
?>

参见

  • Imagick::cropImage
  • Imagick::resizeImage
  • Imagick::thumbnailImage

Imagick::transformImageColorspace

Transforms an image to a new colorspace

说明

public bool Imagick::transformImageColorspace ( int $colorspace )

Transforms an image to a new colorspace.

参数

colorspace
The colorspace the image should be transformed to, one of the COLORSPACE constants e.g. Imagick::COLORSPACE_CMYK.

返回值

成功时返回 true

范例

示例 #1 <span class="methodname">Imagick::transformImageColorspace example

Transforms an image to a new colorspace, and then extracts a single channel so that the individual channel values can be viewed.

<?php
function transformImageColorspace($imagePath, $colorSpace, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->transformimagecolorspace($colorSpace);
    //channel should be one of the channel constants e.g. \Imagick::CHANNEL_BLUE 
    $imagick->separateImageChannel($channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}
?>

参见

  • Imagick::setColorSpace

范例

示例 #2 <span class="function">Imagick::transformImageColorspace

<?php
function transformImageColorspace($imagePath, $colorSpace, $channel) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->transformimagecolorspace($colorSpace);
    $imagick->separateImageChannel($channel);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::transparentPaintImage

Paints pixels transparent

说明

public bool Imagick::transparentPaintImage ( <span class="methodparam">mixed $target , float $alpha , <span class="type">float $fuzz , <span class="methodparam">bool $invert )

Paints pixels matching the target color transparent. 此方法在Imagick基于ImageMagick 6.3.8以上版本编译时可用。

参数

target
The target color to paint

alpha
透明级别:1.0 是完全不透明,0.0 是完全透明。

fuzz
The amount of fuzz. For example, set fuzz to 10 and the color red at intensities of 100 and 102 respectively are now interpreted as the same color.

invert
If true paints any pixel that does not match the target color.

返回值

成功时返回 true

范例

示例 #1 <span class="function">Imagick::transparentPaintImage

<?php
function transparentPaintImage($color, $alpha, $fuzz) {
    $imagick = new \Imagick(realpath("images/BlueScreen.jpg"));

    //Need to be in a format that supports transparency
    $imagick->setimageformat('png');

    $imagick->transparentPaintImage(
        $color, $alpha, $fuzz * \Imagick::getQuantum(), false
    );

    //Not required, but helps tidy up left over pixels
    $imagick->despeckleimage();

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::transposeImage

Creates a vertical mirror image

说明

public bool Imagick::transposeImage ( <span class="methodparam">void )

Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them 90-degrees. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

成功时返回 true

参见

  • Imagick::transverseImage

范例

示例 #1 Imagick::transposeImage

<?php
function transposeImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->transposeImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::transverseImage

Creates a horizontal mirror image

说明

public bool Imagick::transverseImage ( <span class="methodparam">void )

Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them 270-degrees. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

成功时返回 true

参见

  • Imagick::transposeImage

范例

示例 #1 Imagick::transverseImage

<?php
function transverseImage($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->transverseImage();
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::trimImage

Remove edges from the image

说明

public bool Imagick::trimImage ( <span class="methodparam">float $fuzz )

Remove edges that are the background color from the image. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

fuzz
By default target must match a particular pixel color exactly. However, in many cases two colors may differ by a small amount. The fuzz member of image defines how much tolerance is acceptable to consider two colors as the same. This parameter represents the variation on the quantum range.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Using Imagick::trimImage:

Trim an image, then display to the browser.

<?php
/* Create the object and read the image in */
$im = new Imagick("image.jpg");

/* Trim the image. */
$im->trimImage(0);

/* Ouput the image */
header("Content-Type: image/" . $im->getImageFormat());
echo $im;
?>

参见

  • Imagick::getQuantumDepth
  • Imagick::getQuantumRange
  • imagecropauto

Imagick::uniqueImageColors

Discards all but one of any pixel color

说明

public bool Imagick::uniqueImageColors ( <span class="methodparam">void )

Discards all but one of any pixel color. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

返回值

成功时返回 true

范例

示例 #1 Imagick::uniqueImageColors

<?php
function uniqueImageColors($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    //Reduce the image to 256 colours nicely.
    $imagick->quantizeImage(256, \Imagick::COLORSPACE_YIQ, 0, false, false);
    $imagick->uniqueImageColors();
    $imagick->scaleimage($imagick->getImageWidth(), $imagick->getImageHeight() * 20);
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

Imagick::unsharpMaskImage

Sharpens an image

说明

public bool Imagick::unsharpMaskImage ( <span class="methodparam">float $radius , float $sigma , <span class="type">float $amount , <span class="methodparam">float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and Imagick::UnsharpMaskImage() selects a suitable radius for you.

参数

radius

sigma

amount

threshold

channel

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Imagick::unsharpMaskImage

<?php
function unsharpMaskImage($imagePath, $radius, $sigma, $amount, $unsharpThreshold) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->unsharpMaskImage($radius, $sigma, $amount, $unsharpThreshold);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::valid

Checks if the current item is valid

说明

public bool Imagick::valid ( <span class="methodparam">void )

Checks if the current item is valid.

返回值

成功时返回 true

Imagick::vignetteImage

Adds vignette filter to the image

说明

public bool Imagick::vignetteImage ( <span class="methodparam">float $blackPoint , float $whitePoint , <span class="type">int $x , <span class="type">int $y )

Softens the edges of the image in vignette style. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

blackPoint
The black point.

whitePoint
The white point

x
X offset of the ellipse

y
Y offset of the ellipse

返回值

成功时返回 true

参见

  • Imagick::waveImage
  • Imagick::swirlImage

范例

示例 #1 Imagick::vignetteImage

<?php
function vignetteImage($imagePath, $blackPoint, $whitePoint, $x, $y) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->vignetteImage($blackPoint, $whitePoint, $x, $y);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::waveImage

Applies wave filter to the image

说明

public bool Imagick::waveImage ( <span class="methodparam">float $amplitude , float $length )

Applies a wave filter to the image. 此方法在Imagick基于ImageMagick 6.2.9以上版本编译时可用。

参数

amplitude
The amplitude of the wave.

length
The length of the wave.

返回值

成功时返回 true

错误/异常

错误时抛出 ImagickException。

参见

  • Imagick::solarizeImage
  • Imagick::oilpaintImage
  • Imagick::embossImage
  • Imagick::addNoiseImage
  • Imagick::swirlImage

范例

示例 #1 WaveImage can be quite slow <span class="function">Imagick::waveImage

<?php
function waveImage($imagePath, $amplitude, $length) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->waveImage($amplitude, $length);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::whiteThresholdImage

Force all pixels above the threshold into white

说明

public bool Imagick::whiteThresholdImage ( <span class="methodparam">mixed $threshold )

Is like Imagick::ThresholdImage() but force all pixels above the threshold into white while leaving all pixels below the threshold unchanged.

参数

threshold

返回值

成功时返回 true

更新日志

版本 说明
PECL imagick 2.1.0 Now allows a string representing the color as a parameter. Previous versions allow only an ImagickPixel object.

范例

示例 #1 Imagick::whiteThresholdImage

<?php
function whiteThresholdImage($imagePath, $color) {
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->whiteThresholdImage($color);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

Imagick::writeImage

把图片写入指定的文件

说明

bool <span class="methodname">Imagick::writeImage ([ <span class="methodparam">string $filename<span class="initializer"> = NULL ] )

把图片写入指定的文件。如果指定文件参数的值是 NULL ,图片将会写入通过 Imagick::readImage() 或者 Imagick::setImageFilename() 设定的文件。

参数

filename
图片将被写入的文件名。文件的后缀指定了文件的类型。 可以强制指定图片的格式而不管文件的后缀名。在文件名前面加上一个前缀,例如 “jpg:test.png”。

返回值

成功时返回 true

Imagick::writeImageFile

Writes an image to a filehandle

说明

public bool Imagick::writeImageFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $format ] )

Writes the image sequence to an open filehandle. The handle must be opened with for example fopen. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

filehandle
Filehandle where to write the image

返回值

成功时返回 true

Imagick::writeImages

Writes an image or image sequence

说明

public bool Imagick::writeImages ( <span class="methodparam">string $filename , bool $adjoin )

Writes an image or image sequence.

参数

filename

adjoin

返回值

成功时返回 true

Imagick::writeImagesFile

Writes frames to a filehandle

说明

public bool Imagick::writeImagesFile ( <span class="methodparam">resource $filehandle [, <span class="type">string $format ] )

Writes all image frames into an open filehandle. This method can be used to write animated gifs or other multiframe images into open filehandle. 此方法在Imagick基于ImageMagick 6.3.6以上版本编译时可用。

参数

filehandle
Filehandle where to write the images

返回值

成功时返回 true

类摘要

ImagickDraw

class ImagickDraw {

public bool affine ( <span class="type">array $affine )

public bool annotation ( <span class="methodparam">float $x , <span class="methodparam">float $y , <span class="methodparam">string $text )

public bool arc ( <span class="type">float $sx , <span class="type">float $sy , <span class="type">float $ex , <span class="type">float $ey , <span class="type">float $sd , <span class="type">float $ed )

public bool bezier ( <span class="type">array $coordinates )

public bool circle ( <span class="type">float $ox , <span class="type">float $oy , <span class="type">float $px , <span class="type">float $py )

public bool clear ( <span class="methodparam">void )

public <span class="type">ImagickDraw clone ( void )

public bool color ( <span class="type">float $x , <span class="type">float $y , <span class="type">int $paintMethod )

public bool comment ( <span class="methodparam">string $comment )

public bool composite ( <span class="methodparam">int $compose , float $x , float $y , float $width , <span class="type">float $height , <span class="methodparam">Imagick $compositeWand )

public <span class="methodname">__construct ( <span class="methodparam">void )

public bool destroy ( <span class="methodparam">void )

public bool ellipse ( <span class="methodparam">float $ox , <span class="methodparam">float $oy , <span class="methodparam">float $rx , <span class="methodparam">float $ry , <span class="methodparam">float $start , float $end )

public string getClipPath ( <span class="methodparam">void )

public int <span class="methodname">getClipRule ( <span class="methodparam">void )

public int <span class="methodname">getClipUnits ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getFillColor ( <span class="methodparam">void )

public float getFillOpacity ( <span class="methodparam">void )

public int <span class="methodname">getFillRule ( <span class="methodparam">void )

public string getFont ( <span class="methodparam">void )

public string getFontFamily ( <span class="methodparam">void )

public float getFontSize ( <span class="methodparam">void )

public int <span class="methodname">getFontStretch ( <span class="methodparam">void )

public int <span class="methodname">getFontStyle ( <span class="methodparam">void )

public int <span class="methodname">getFontWeight ( <span class="methodparam">void )

public int <span class="methodname">getGravity ( <span class="methodparam">void )

public bool getStrokeAntialias ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getStrokeColor ( <span class="methodparam">void )

public array getStrokeDashArray ( <span class="methodparam">void )

public float getStrokeDashOffset ( <span class="methodparam">void )

public int <span class="methodname">getStrokeLineCap ( <span class="methodparam">void )

public int <span class="methodname">getStrokeLineJoin ( <span class="methodparam">void )

public int <span class="methodname">getStrokeMiterLimit ( <span class="methodparam">void )

public float getStrokeOpacity ( <span class="methodparam">void )

public float getStrokeWidth ( <span class="methodparam">void )

public int <span class="methodname">getTextAlignment ( <span class="methodparam">void )

public bool getTextAntialias ( <span class="methodparam">void )

public int <span class="methodname">getTextDecoration ( <span class="methodparam">void )

public string getTextEncoding ( <span class="methodparam">void )

public float getTextInterlineSpacing ( <span class="methodparam">void )

public float getTextInterwordSpacing ( <span class="methodparam">void )

public float getTextKerning ( <span class="methodparam">void )

public <span class="type">ImagickPixel <span class="methodname">getTextUnderColor ( <span class="methodparam">void )

public string getVectorGraphics ( <span class="methodparam">void )

public bool line ( <span class="type">float $sx , <span class="type">float $sy , <span class="type">float $ex , <span class="type">float $ey )

public bool matte ( <span class="type">float $x , <span class="type">float $y , <span class="type">int $paintMethod )

public bool pathClose ( <span class="methodparam">void )

public bool pathCurveToAbsolute ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathCurveToQuadraticBezierAbsolute ( float $x1 , float $y1 , float $x , float $y )

public bool pathCurveToQuadraticBezierRelative ( float $x1 , float $y1 , float $x , float $y )

public bool pathCurveToQuadraticBezierSmoothAbsolute ( float $x , float $y )

public bool pathCurveToQuadraticBezierSmoothRelative ( float $x , float $y )

public bool pathCurveToRelative ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathCurveToSmoothAbsolute ( <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathCurveToSmoothRelative ( <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathEllipticArcAbsolute ( <span class="methodparam">float $rx , <span class="methodparam">float $ry , <span class="methodparam">float $x_axis_rotation , <span class="type">bool $large_arc_flag , <span class="methodparam">bool $sweep_flag , float $x , float $y )

public bool pathEllipticArcRelative ( <span class="methodparam">float $rx , <span class="methodparam">float $ry , <span class="methodparam">float $x_axis_rotation , <span class="type">bool $large_arc_flag , <span class="methodparam">bool $sweep_flag , float $x , float $y )

public bool pathFinish ( <span class="methodparam">void )

public bool pathLineToAbsolute ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathLineToHorizontalAbsolute ( <span class="methodparam">float $x )

public bool pathLineToHorizontalRelative ( <span class="methodparam">float $x )

public bool pathLineToRelative ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathLineToVerticalAbsolute ( <span class="methodparam">float $y )

public bool pathLineToVerticalRelative ( <span class="methodparam">float $y )

public bool pathMoveToAbsolute ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathMoveToRelative ( <span class="methodparam">float $x , <span class="methodparam">float $y )

public bool pathStart ( <span class="methodparam">void )

public bool point ( <span class="type">float $x , <span class="type">float $y )

public bool polygon ( <span class="methodparam">array $coordinates )

public bool polyline ( <span class="methodparam">array $coordinates )

public bool pop ( <span class="methodparam">void )

public bool popClipPath ( <span class="methodparam">void )

public bool popDefs ( <span class="methodparam">void )

public bool popPattern ( <span class="methodparam">void )

public bool push ( <span class="methodparam">void )

public bool pushClipPath ( <span class="methodparam">string $clip_mask_id )

public bool pushDefs ( <span class="methodparam">void )

public bool pushPattern ( <span class="methodparam">string $pattern_id , <span class="type">float $x , <span class="type">float $y , <span class="type">float $width , <span class="methodparam">float $height )

public bool rectangle ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 )

public bool render ( <span class="methodparam">void )

public bool resetVectorGraphics ( <span class="methodparam">void )

public bool rotate ( <span class="type">float $degrees )

public bool roundRectangle ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $rx , <span class="methodparam">float $ry )

public bool scale ( <span class="type">float $x , <span class="type">float $y )

public bool setClipPath ( <span class="methodparam">string $clip_mask )

public bool setClipRule ( <span class="methodparam">int $fill_rule )

public bool setClipUnits ( <span class="methodparam">int $clip_units )

public bool setFillAlpha ( <span class="methodparam">float $opacity )

public bool setFillColor ( <span class="methodparam">ImagickPixel $fill_pixel )

public bool setFillOpacity ( <span class="methodparam">float $fillOpacity )

public bool setFillPatternURL ( <span class="methodparam">string $fill_url )

public bool setFillRule ( <span class="methodparam">int $fill_rule )

public bool setFont ( <span class="methodparam">string $font_name )

public bool setFontFamily ( <span class="methodparam">string $font_family )

public bool setFontSize ( <span class="methodparam">float $pointsize )

public bool setFontStretch ( <span class="methodparam">int $fontStretch )

public bool setFontStyle ( <span class="methodparam">int $style )

public bool setFontWeight ( <span class="methodparam">int $font_weight )

public bool setGravity ( <span class="methodparam">int $gravity )

public bool setResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

public bool setStrokeAlpha ( <span class="methodparam">float $opacity )

public bool setStrokeAntialias ( <span class="methodparam">bool $stroke_antialias )

public bool setStrokeColor ( <span class="methodparam">ImagickPixel $stroke_pixel )

public bool setStrokeDashArray ( <span class="methodparam">array $dashArray )

public bool setStrokeDashOffset ( <span class="methodparam">float $dash_offset )

public bool setStrokeLineCap ( <span class="methodparam">int $linecap )

public bool setStrokeLineJoin ( <span class="methodparam">int $linejoin )

public bool setStrokeMiterLimit ( <span class="methodparam">int $miterlimit )

public bool setStrokeOpacity ( <span class="methodparam">float $stroke_opacity )

public bool setStrokePatternURL ( <span class="methodparam">string $stroke_url )

public bool setStrokeWidth ( <span class="methodparam">float $stroke_width )

public bool setTextAlignment ( <span class="methodparam">int $alignment )

public bool setTextAntialias ( <span class="methodparam">bool $antiAlias )

public bool setTextDecoration ( <span class="methodparam">int $decoration )

public bool setTextEncoding ( <span class="methodparam">string $encoding )

public bool setTextInterlineSpacing ( <span class="methodparam">float $spacing )

public bool setTextInterwordSpacing ( <span class="methodparam">float $spacing )

public bool setTextKerning ( <span class="methodparam">float $kerning )

public bool setTextUnderColor ( <span class="methodparam">ImagickPixel $under_color )

public bool setVectorGraphics ( <span class="methodparam">string $xml )

public bool setViewbox ( <span class="methodparam">int $x1 , <span class="methodparam">int $y1 , <span class="methodparam">int $x2 , <span class="methodparam">int $y2 )

public bool skewX ( <span class="type">float $degrees )

public bool skewY ( <span class="type">float $degrees )

public bool translate ( <span class="methodparam">float $x , <span class="methodparam">float $y )

}

ImagickDraw::affine

Adjusts the current affine transformation matrix

说明

public bool ImagickDraw::affine ( <span class="methodparam">array $affine )

Warning

本函数还未编写文档,仅有参数列表。

Adjusts the current affine transformation matrix with the specified affine transformation matrix.

参数

affine
Affine matrix parameters

返回值

没有返回值。

范例

示例 #1 ImagickDraw::affine

<?php
function affine($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeWidth(1);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);

    $PI = 3.141592653589794;
    $angle = 60 * $PI / 360;

    //Scale the drawing co-ordinates.
    $affineScale = array("sx" => 1.75, "sy" => 1.75, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0);

    //Shear the drawing co-ordinates.
    $affineShear = array("sx" => 1, "sy" => 1, "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0);

    //Rotate the drawing co-ordinates. The shear affine matrix
    //produces incorrectly scaled drawings.
    $affineRotate = array("sx" => cos($angle), "sy" => cos($angle), "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0,);

    //Translate (offset) the drawing
    $affineTranslate = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 30, "ty" => 30);

    //The identiy affine matrix
    $affineIdentity = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0);

    $examples = [$affineScale, $affineShear, $affineRotate, $affineTranslate, $affineIdentity,];

    $count = 0;

    foreach ($examples as $example) {
        $draw->push();
        $draw->translate(($count % 2) * 250, intval($count / 2) * 250);
        $draw->translate(100, 100);
        $draw->affine($example);
        $draw->rectangle(-50, -50, 50, 50);
        $draw->pop();
        $count++;
    }

    //Create an image object which the draw commands can be rendered into
    $image = new \Imagick();
    $image->newImage(500, 750, $backgroundColor);
    $image->setImageFormat("png");

    //Render the draw commands in the ImagickDraw object 
    //into the image.
    $image->drawImage($draw);

    //Send the image to the browser
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::annotation

Draws text on the image

说明

public bool ImagickDraw::annotation ( <span class="methodparam">float $x , <span class="methodparam">float $y , <span class="methodparam">string $text )

Warning

本函数还未编写文档,仅有参数列表。

Draws text on the image.

参数

x
The x coordinate where text is drawn

y
The y coordinate where text is drawn

text
The text to draw on the image

返回值

没有返回值。

ImagickDraw::arc

Draws an arc

说明

public bool ImagickDraw::arc ( <span class="methodparam">float $sx , <span class="methodparam">float $sy , <span class="methodparam">float $ex , <span class="methodparam">float $ey , <span class="methodparam">float $sd , <span class="methodparam">float $ed )

Warning

本函数还未编写文档,仅有参数列表。

Draws an arc falling within a specified bounding rectangle on the image.

参数

sx
Starting x ordinate of bounding rectangle

sy
starting y ordinate of bounding rectangle

ex
ending x ordinate of bounding rectangle

ey
ending y ordinate of bounding rectangle

sd
starting degrees of rotation

ed
ending degrees of rotation

返回值

没有返回值。

范例

示例 #1 ImagickDraw::arc

<?php
function arc($strokeColor, $fillColor, $backgroundColor, $startX, $startY, $endX, $endY, $startAngle, $endAngle) {

    //Create a ImagickDraw object to draw into.
    $draw = new \ImagickDraw();
    $draw->setStrokeWidth(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);

    $draw->arc($startX, $startY, $endX, $endY, $startAngle, $endAngle);

    //Create an image object which the draw commands can be rendered into
    $image = new \Imagick();
    $image->newImage(IMAGE_WIDTH, IMAGE_HEIGHT, $backgroundColor);
    $image->setImageFormat("png");

    //Render the draw commands in the ImagickDraw object 
    //into the image.
    $image->drawImage($draw);

    //Send the image to the browser
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::bezier

Draws a bezier curve

说明

public bool ImagickDraw::bezier ( <span class="methodparam">array $coordinates )

Warning

本函数还未编写文档,仅有参数列表。

Draws a bezier curve through a set of points on the image.

参数

coordinates
Multidimensional array like array( array( 'x' => 1, 'y' => 2 ), array( 'x' => 3, 'y' => 4 ) )

返回值

没有返回值。

范例

示例 #1 ImagickDraw::bezier

<?php
function bezier($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);

    $smoothPointsSet = [
        [
            ['x' => 10.0 * 5, 'y' => 10.0 * 5],
            ['x' => 30.0 * 5, 'y' => 90.0 * 5],
            ['x' => 25.0 * 5, 'y' => 10.0 * 5],
            ['x' => 50.0 * 5, 'y' => 50.0 * 5],
        ], 
        [
            ['x' => 50.0 * 5, 'y' => 50.0 * 5],
            ['x' => 75.0 * 5, 'y' => 90.0 * 5],
            ['x' => 70.0 * 5, 'y' => 10.0 * 5],
            ['x' => 90.0 * 5, 'y' => 40.0 * 5],
        ],
    ];

    foreach ($smoothPointsSet as $points) {
        $draw->bezier($points);
    }

    $disjointPoints = [
        [
            ['x' => 10 * 5, 'y' => 10 * 5], 
            ['x' => 30 * 5, 'y' => 90 * 5], 
            ['x' => 25 * 5, 'y' => 10 * 5],
            ['x' => 50 * 5, 'y' => 50 * 5],
        ],
        [
            ['x' => 50 * 5, 'y' => 50 * 5], 
            ['x' => 80 * 5, 'y' => 50 * 5],
            ['x' => 70 * 5, 'y' => 10 * 5],
            ['x' => 90 * 5, 'y' => 40 * 5],
         ]
    ];
    $draw->translate(0, 200);

    foreach ($disjointPoints as $points) {
        $draw->bezier($points);
    }

    //Create an image object which the draw commands can be rendered into
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    //Render the draw commands in the ImagickDraw object 
    //into the image.
    $imagick->drawImage($draw);

    //Send the image to the browser
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::circle

Draws a circle

说明

public bool ImagickDraw::circle ( <span class="methodparam">float $ox , <span class="methodparam">float $oy , <span class="methodparam">float $px , <span class="methodparam">float $py )

Warning

本函数还未编写文档,仅有参数列表。

Draws a circle on the image.

参数

ox
origin x coordinate

oy
origin y coordinate

px
perimeter x coordinate

py
perimeter y coordinate

返回值

没有返回值。

范例

示例 #1 ImagickDraw::circle

<?php
function circle($strokeColor, $fillColor, $backgroundColor, $originX, $originY, $endX, $endY) {

    //Create a ImagickDraw object to draw into.
    $draw = new \ImagickDraw();

    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->circle($originX, $originY, $endX, $endY);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::clear

Clears the ImagickDraw

说明

public bool ImagickDraw::clear ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Clears the ImagickDraw object of any accumulated commands, and resets the settings it contains to their defaults.

返回值

Returns an ImagickDraw object.

ImagickDraw::clone

Makes an exact copy of the specified ImagickDraw object

说明

public <span class="type">ImagickDraw <span class="methodname">ImagickDraw::clone ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Makes an exact copy of the specified ImagickDraw object.

返回值

What the function returns, first on success, then on failure. See also the &return.success; entity

ImagickDraw::color

Draws color on image

说明

public bool ImagickDraw::color ( <span class="methodparam">float $x , <span class="methodparam">float $y , <span class="methodparam">int $paintMethod )

Warning

本函数还未编写文档,仅有参数列表。

Draws color on image using the current fill color, starting at specified position, and using specified paint method.

参数

x
x coordinate of the paint

y
y coordinate of the paint

paintMethod
one of the PAINT_ constants

返回值

没有返回值。

ImagickDraw::comment

Adds a comment

说明

public bool ImagickDraw::comment ( <span class="methodparam">string $comment )

Warning

本函数还未编写文档,仅有参数列表。

Adds a comment to a vector output stream.

参数

comment
The comment string to add to vector output stream

返回值

没有返回值。

ImagickDraw::composite

Composites an image onto the current image

说明

public bool ImagickDraw::composite ( <span class="methodparam">int $compose , float $x , float $y , float $width , <span class="type">float $height , <span class="methodparam">Imagick $compositeWand )

Warning

本函数还未编写文档,仅有参数列表。

Composites an image onto the current image, using the specified composition operator, specified position, and at the specified size.

参数

compose
composition operator. One of COMPOSITE_ constants

x
x coordinate of the top left corner

y
y coordinate of the top left corner

width
width of the composition image

height
height of the composition image

compositeWand
the Imagick object where composition image is taken from

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::composite

<?php
function composite($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setFillOpacity(1);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(2);
    $draw->setFont("../fonts/CANDY.TTF");
    $draw->setFontSize(140);
    $draw->rectangle(0, 0, 1000, 300);
    $draw->setFillColor('white');
    $draw->setfillopacity(1);
    $draw->annotation(50, 180, "Lorem Ipsum!");

    //Create an image object which the draw commands can be rendered into
    $imagick = new \Imagick();
    $imagick->newImage(1000, 302, $backgroundColor);
    $imagick->setImageFormat("png");

    //Render the draw commands in the ImagickDraw object 
    //into the image.
    $imagick->drawImage($draw);

    //Send the image to the browser
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::__construct

The ImagickDraw constructor

说明

public <span class="methodname">ImagickDraw::__construct ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

The ImagickDraw constructor

返回值

没有返回值。

ImagickDraw::destroy

Frees all associated resources

说明

public bool ImagickDraw::destroy ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Frees all resources associated with the ImagickDraw object.

返回值

没有返回值。

ImagickDraw::ellipse

Draws an ellipse on the image

说明

public bool ImagickDraw::ellipse ( <span class="methodparam">float $ox , <span class="methodparam">float $oy , <span class="methodparam">float $rx , <span class="methodparam">float $ry , <span class="methodparam">float $start , float $end )

Warning

本函数还未编写文档,仅有参数列表。

Draws an ellipse on the image.

参数

ox

oy

rx

ry

start

end

返回值

没有返回值。

范例

示例 #1 ImagickDraw::ellipse

<?php
function ellipse($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->ellipse(125, 70, 100, 50, 0, 360);
    $draw->ellipse(350, 70, 100, 50, 0, 315);

    $draw->push();
    $draw->translate(125, 250);
    $draw->rotate(30);
    $draw->ellipse(0, 0, 100, 50, 0, 360);
    $draw->pop();

    $draw->push();
    $draw->translate(350, 250);
    $draw->rotate(30);
    $draw->ellipse(0, 0, 100, 50, 0, 315);
    $draw->pop();

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::getClipPath

Obtains the current clipping path ID

说明

public string ImagickDraw::getClipPath ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Obtains the current clipping path ID.

返回值

Returns a string containing the clip path ID or false if no clip path exists.

ImagickDraw::getClipRule

Returns the current polygon fill rule

说明

public int <span class="methodname">ImagickDraw::getClipRule ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the current polygon fill rule to be used by the clipping path.

返回值

Returns one of the FILLRULE_ constants.

ImagickDraw::getClipUnits

Returns the interpretation of clip path units

说明

public int <span class="methodname">ImagickDraw::getClipUnits ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the interpretation of clip path units.

返回值

Returns an int on success.

ImagickDraw::getFillColor

Returns the fill color

说明

public <span class="type">ImagickPixel <span class="methodname">ImagickDraw::getFillColor ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the fill color used for drawing filled objects.

返回值

Returns an ImagickPixel object.

ImagickDraw::getFillOpacity

Returns the opacity used when drawing

说明

public float ImagickDraw::getFillOpacity ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the opacity used when drawing using the fill color or fill texture. Fully opaque is 1.0.

返回值

The opacity.

ImagickDraw::getFillRule

Returns the fill rule

说明

public int <span class="methodname">ImagickDraw::getFillRule ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the fill rule used while drawing polygons.

返回值

Returns a FILLRULE_ constant

ImagickDraw::getFont

Returns the font

说明

public string ImagickDraw::getFont ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns a string specifying the font used when annotating with text.

返回值

Returns a string on success and false if no font is set.

ImagickDraw::getFontFamily

Returns the font family

说明

public string ImagickDraw::getFontFamily ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the font family to use when annotating with text.

返回值

Returns the font family currently selected or false if font family is not set.

ImagickDraw::getFontSize

Returns the font pointsize

说明

public float ImagickDraw::getFontSize ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the font pointsize used when annotating with text.

返回值

Returns the font size associated with the current ImagickDraw object.

ImagickDraw::getFontStretch

Description

说明

public int <span class="methodname">ImagickDraw::getFontStretch ( <span class="methodparam">void )

Gets the font stretch to use when annotating with text. Returns a StretchType.

参数

此函数没有参数。

返回值

ImagickDraw::getFontStyle

Returns the font style

说明

public int <span class="methodname">ImagickDraw::getFontStyle ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the font style used when annotating with text.

返回值

Returns the font style constant (STYLE_) associated with the ImagickDraw object or 0 if no style is set.

ImagickDraw::getFontWeight

Returns the font weight

说明

public int <span class="methodname">ImagickDraw::getFontWeight ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the font weight used when annotating with text.

返回值

Returns an int on success and 0 if no weight is set.

ImagickDraw::getGravity

Returns the text placement gravity

说明

public int <span class="methodname">ImagickDraw::getGravity ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the text placement gravity used when annotating with text.

返回值

Returns a GRAVITY_ constant on success and 0 if no gravity is set.

ImagickDraw::getStrokeAntialias

Returns the current stroke antialias setting

说明

public bool ImagickDraw::getStrokeAntialias ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the current stroke antialias setting. Stroked outlines are antialiased by default. When antialiasing is disabled stroked pixels are thresholded to determine if the stroke color or underlying canvas color should be used.

返回值

Returns true if antialiasing is on and false if it is off.

ImagickDraw::getStrokeColor

Returns the color used for stroking object outlines

说明

public <span class="type">ImagickPixel <span class="methodname">ImagickDraw::getStrokeColor ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the color used for stroking object outlines.

参数

stroke_color

返回值

Returns an ImagickPixel object which describes the color.

ImagickDraw::getStrokeDashArray

Returns an array representing the pattern of dashes and gaps used to stroke paths

说明

public array ImagickDraw::getStrokeDashArray ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns an array representing the pattern of dashes and gaps used to stroke paths.

返回值

Returns an array on success and empty array if not set.

ImagickDraw::getStrokeDashOffset

Returns the offset into the dash pattern to start the dash

说明

public float ImagickDraw::getStrokeDashOffset ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the offset into the dash pattern to start the dash.

返回值

Returns a float representing the offset and 0 if it's not set.

ImagickDraw::getStrokeLineCap

Returns the shape to be used at the end of open subpaths when they are stroked

说明

public int <span class="methodname">ImagickDraw::getStrokeLineCap ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the shape to be used at the end of open subpaths when they are stroked.

返回值

Returns one of the LINECAP_ constants or 0 if stroke linecap is not set.

ImagickDraw::getStrokeLineJoin

Returns the shape to be used at the corners of paths when they are stroked

说明

public int <span class="methodname">ImagickDraw::getStrokeLineJoin ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the shape to be used at the corners of paths (or other vector shapes) when they are stroked.

返回值

Returns one of the LINEJOIN_ constants or 0 if stroke line join is not set.

ImagickDraw::getStrokeMiterLimit

Returns the stroke miter limit

说明

public int <span class="methodname">ImagickDraw::getStrokeMiterLimit ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the miter limit. When two line segments meet at a sharp angle and miter joins have been specified for 'lineJoin', it is possible for the miter to extend far beyond the thickness of the line stroking the path. The 'miterLimit' imposes a limit on the ratio of the miter length to the 'lineWidth'.

返回值

Returns an int describing the miter limit and 0 if no miter limit is set.

ImagickDraw::getStrokeOpacity

Returns the opacity of stroked object outlines

说明

public float ImagickDraw::getStrokeOpacity ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the opacity of stroked object outlines.

返回值

Returns a double describing the opacity.

ImagickDraw::getStrokeWidth

Returns the width of the stroke used to draw object outlines

说明

public float ImagickDraw::getStrokeWidth ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the width of the stroke used to draw object outlines.

返回值

Returns a double describing the stroke width.

ImagickDraw::getTextAlignment

Returns the text alignment

说明

public int <span class="methodname">ImagickDraw::getTextAlignment ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the alignment applied when annotating with text.

返回值

Returns one of the ALIGN_ constants and 0 if no align is set.

ImagickDraw::getTextAntialias

Returns the current text antialias setting

说明

public bool ImagickDraw::getTextAntialias ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the current text antialias setting, which determines whether text is antialiased. Text is antialiased by default.

返回值

Returns true if text is antialiased and false if not.

ImagickDraw::getTextDecoration

Returns the text decoration

说明

public int <span class="methodname">ImagickDraw::getTextDecoration ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the decoration applied when annotating with text.

返回值

Returns one of the DECORATION_ constants and 0 if no decoration is set.

ImagickDraw::getTextEncoding

Returns the code set used for text annotations

说明

public string ImagickDraw::getTextEncoding ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns a string which specifies the code set used for text annotations.

返回值

Returns a string specifying the code set or false if text encoding is not set.

ImagickDraw::getTextInterlineSpacing

Description

说明

public float ImagickDraw::getTextInterlineSpacing ( void )

Gets the text interword spacing.

参数

此函数没有参数。

返回值

ImagickDraw::getTextInterwordSpacing

Description

说明

public float ImagickDraw::getTextInterwordSpacing ( void )

Gets the text interword spacing.

参数

此函数没有参数。

返回值

ImagickDraw::getTextKerning

Description

说明

public float ImagickDraw::getTextKerning ( <span class="methodparam">void )

Gets the text kerning.

参数

此函数没有参数。

返回值

ImagickDraw::getTextUnderColor

Returns the text under color

说明

public <span class="type">ImagickPixel <span class="methodname">ImagickDraw::getTextUnderColor ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the color of a background rectangle to place under text annotations.

返回值

Returns an ImagickPixel object describing the color.

ImagickDraw::getVectorGraphics

Returns a string containing vector graphics

说明

public string ImagickDraw::getVectorGraphics ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns a string which specifies the vector graphics generated by any graphics calls made since the ImagickDraw object was instantiated.

返回值

Returns a string containing the vector graphics.

ImagickDraw::line

Draws a line

说明

public bool ImagickDraw::line ( <span class="methodparam">float $sx , <span class="methodparam">float $sy , <span class="methodparam">float $ex , <span class="methodparam">float $ey )

Warning

本函数还未编写文档,仅有参数列表。

Draws a line on the image using the current stroke color, stroke opacity, and stroke width.

参数

sx
starting x coordinate

sy
starting y coordinate

ex
ending x coordinate

ey
ending y coordinate

返回值

没有返回值。

范例

示例 #1 ImagickDraw::line

<?php
function line($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->line(125, 70, 100, 50);
    $draw->line(350, 170, 100, 150);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::matte

Paints on the image's opacity channel

说明

public bool ImagickDraw::matte ( <span class="methodparam">float $x , <span class="methodparam">float $y , <span class="methodparam">int $paintMethod )

Warning

本函数还未编写文档,仅有参数列表。

Paints on the image's opacity channel in order to set effected pixels to transparent, to influence the opacity of pixels.

参数

x
x coordinate of the matte

y
y coordinate of the matte

paintMethod
PAINT_ constant

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 ImagickDraw::matte

<?php
function matte($strokeColor, $fillColor, $backgroundColor, $paintType) {
    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->matte(120, 120, $paintType);    
    $draw->rectangle(100, 100, 300, 200);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::pathClose

Adds a path element to the current path

说明

public bool ImagickDraw::pathClose ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Adds a path element to the current path which closes the current subpath by drawing a straight line from the current point to the current subpath's most recent starting point (usually, the most recent moveto point).

返回值

没有返回值。

ImagickDraw::pathCurveToAbsolute

Draws a cubic Bezier curve

说明

public bool ImagickDraw::pathCurveToAbsolute ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a cubic Bezier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve using absolute coordinates. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x1
x coordinate of the first control point

y1
y coordinate of the first control point

x2
x coordinate of the second control point

y2
y coordinate of the first control point

x
x coordinate of the curve end

y
y coordinate of the curve end

返回值

没有返回值。

ImagickDraw::pathCurveToQuadraticBezierAbsolute

Draws a quadratic Bezier curve

说明

public bool <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierAbsolute ( float $x1 , float $y1 , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point using absolute coordinates. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x1
x coordinate of the control point

y1
y coordinate of the control point

x
x coordinate of the end point

y
y coordinate of the end point

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::pathCurveToQuadraticBezierAbsolute

<?php
function pathCurveToQuadraticBezierAbsolute($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->pathStart();
    $draw->pathMoveToAbsolute(50,250);

    // This specifies a quadratic bezier curve with the current position as the start
    // point, the control point is the first two params, and the end point is the last two params.
    $draw->pathCurveToQuadraticBezierAbsolute(
        150,50, 
        250,250
    );

    // This specifies a quadratic bezier curve with the current position as the start
    // point, the control point is mirrored from the previous curves control point
    // and the end point is defined by the x, y values.
    $draw->pathCurveToQuadraticBezierSmoothAbsolute(
        450,250
    );

    // This specifies a quadratic bezier curve with the current position as the start
    // point, the control point is mirrored from the previous curves control point
    // and the end point is defined relative from the current position by the x, y values.
    $draw->pathCurveToQuadraticBezierSmoothRelative(
        200,-100
    );

    $draw->pathFinish();

    $imagick = new \Imagick();
    $imagick->newImage(700, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();

}

?>

ImagickDraw::pathCurveToQuadraticBezierRelative

Draws a quadratic Bezier curve

说明

public bool <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierRelative ( float $x1 , float $y1 , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point using relative coordinates. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x1
starting x coordinate

y1
starting y coordinate

x
ending x coordinate

y
ending y coordinate

返回值

没有返回值。

ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute

Draws a quadratic Bezier curve

说明

public bool <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute ( float $x , float $y )

Draws a quadratic Bezier curve (using absolute coordinates) from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a DrawPathCurveToQuadraticBezierAbsolute, DrawPathCurveToQuadraticBezierRelative, DrawPathCurveToQuadraticBezierSmoothAbsolut or DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point is coincident with the current point.). At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

This function cannot be used to continue a cubic Bezier curve smoothly. It can only continue from a quadratic curve smoothly.

参数

x
ending x coordinate

y
ending y coordinate

返回值

没有返回值。

范例

示例 #1 <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierSmoothAbsolute

<?php
$draw = new \ImagickDraw();

$draw->setStrokeOpacity(1);
$draw->setStrokeColor("black");
$draw->setFillColor("blue");

$draw->setStrokeWidth(2);
$draw->setFontSize(72);

$draw->pathStart();
$draw->pathMoveToAbsolute(50,250);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is the first two params, and the end point is the last two params.
$draw->pathCurveToQuadraticBezierAbsolute(
    150,50, 
    250,250
);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is mirrored from the previous curves control point
// and the end point is defined by the x, y values.
$draw->pathCurveToQuadraticBezierSmoothAbsolute(
    450,250
);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is mirrored from the previous curves control point
// and the end point is defined relative from the current position by the x, y values.
$draw->pathCurveToQuadraticBezierSmoothRelative(
    200,-100
);

$draw->pathFinish();

$imagick = new \Imagick();
$imagick->newImage(700, 500, $backgroundColor);
$imagick->setImageFormat("png");

$imagick->drawImage($draw);

header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

ImagickDraw::pathCurveToQuadraticBezierSmoothRelative

Draws a quadratic Bezier curve

说明

public bool <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierSmoothRelative ( float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a quadratic Bezier curve (using relative coordinates) from the current point to (x, y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a DrawPathCurveToQuadraticBezierAbsolute, DrawPathCurveToQuadraticBezierRelative, DrawPathCurveToQuadraticBezierSmoothAbsolut or DrawPathCurveToQuadraticBezierSmoothRelative, assume the control point is coincident with the current point). At the end of the command, the new current point becomes the final (x, y) coordinate pair used in the polybezier.

This function cannot be used to continue a cubic Bezier curve smoothly. It can only continue from a quadratic curve smoothly.

参数

x
ending x coordinate

y
ending y coordinate

返回值

没有返回值。

范例

示例 #1 <span class="methodname">ImagickDraw::pathCurveToQuadraticBezierSmoothRelative

<?php
$draw = new \ImagickDraw();

$draw->setStrokeOpacity(1);
$draw->setStrokeColor("black");
$draw->setFillColor("blue");

$draw->setStrokeWidth(2);
$draw->setFontSize(72);

$draw->pathStart();
$draw->pathMoveToAbsolute(50,250);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is the first two params, and the end point is the last two params.
$draw->pathCurveToQuadraticBezierAbsolute(
    150,50, 
    250,250
);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is mirrored from the previous curves control point
// and the end point is defined by the x, y values.
$draw->pathCurveToQuadraticBezierSmoothAbsolute(
    450,250
);

// This specifies a quadratic bezier curve with the current position as the start
// point, the control point is mirrored from the previous curves control point
// and the end point is defined relative from the current position by the x, y values.
$draw->pathCurveToQuadraticBezierSmoothRelative(
    200,-100
);

$draw->pathFinish();

$imagick = new \Imagick();
$imagick->newImage(700, 500, $backgroundColor);
$imagick->setImageFormat("png");

$imagick->drawImage($draw);

header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>

ImagickDraw::pathCurveToRelative

Draws a cubic Bezier curve

说明

public bool ImagickDraw::pathCurveToRelative ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a cubic Bezier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve using relative coordinates. At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x1
x coordinate of starting control point

y1
y coordinate of starting control point

x2
x coordinate of ending control point

y2
y coordinate of ending control point

x
ending x coordinate

y
ending y coordinate

返回值

没有返回值。

ImagickDraw::pathCurveToSmoothAbsolute

Draws a cubic Bezier curve

说明

public bool ImagickDraw::pathCurveToSmoothAbsolute ( float $x2 , float $y2 , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a cubic Bezier curve from the current point to (x,y) using absolute coordinates. The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an DrawPathCurveToAbsolute, DrawPathCurveToRelative, DrawPathCurveToSmoothAbsolute or DrawPathCurveToSmoothRelative, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve). At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x2
x coordinate of the second control point

y2
y coordinate of the second control point

x
x coordinate of the ending point

y
y coordinate of the ending point

返回值

没有返回值。

ImagickDraw::pathCurveToSmoothRelative

Draws a cubic Bezier curve

说明

public bool ImagickDraw::pathCurveToSmoothRelative ( float $x2 , float $y2 , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a cubic Bezier curve from the current point to (x,y) using relative coordinates. The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an DrawPathCurveToAbsolute, DrawPathCurveToRelative, DrawPathCurveToSmoothAbsolute or DrawPathCurveToSmoothRelative, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve). At the end of the command, the new current point becomes the final (x,y) coordinate pair used in the polybezier.

参数

x2
x coordinate of the second control point

y2
y coordinate of the second control point

x
x coordinate of the ending point

y
y coordinate of the ending point

返回值

没有返回值。

ImagickDraw::pathEllipticArcAbsolute

Draws an elliptical arc

说明

public bool ImagickDraw::pathEllipticArcAbsolute ( float $rx , float $ry , float $x_axis_rotation , <span class="type">bool $large_arc_flag , <span class="methodparam">bool $sweep_flag , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws an elliptical arc from the current point to (x, y) using absolute coordinates. The size and orientation of the ellipse are defined by two radii (rx, ry) and an xAxisRotation, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. largeArcFlag and sweepFlag contribute to the automatic calculations and help determine how the arc is drawn. If largeArcFlag is true then draw the larger of the available arcs. If sweepFlag is true, then draw the arc matching a clock-wise rotation.

参数

rx
x radius

ry
y radius

x_axis_rotation
x axis rotation

large_arc_flag
large arc flag

sweep_flag
sweep flag

x
x coordinate

y
y coordinate

返回值

没有返回值。

ImagickDraw::pathEllipticArcRelative

Draws an elliptical arc

说明

public bool ImagickDraw::pathEllipticArcRelative ( float $rx , float $ry , float $x_axis_rotation , <span class="type">bool $large_arc_flag , <span class="methodparam">bool $sweep_flag , float $x , float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws an elliptical arc from the current point to (x, y) using relative coordinates. The size and orientation of the ellipse are defined by two radii (rx, ry) and an xAxisRotation, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center (cx, cy) of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. largeArcFlag and sweepFlag contribute to the automatic calculations and help determine how the arc is drawn. If largeArcFlag is true then draw the larger of the available arcs. If sweepFlag is true, then draw the arc matching a clock-wise rotation.

参数

rx
x radius

ry
y radius

x_axis_rotation
x axis rotation

large_arc_flag
large arc flag

sweep_flag
sweep flag

x
x coordinate

y
y coordinate

返回值

没有返回值。

ImagickDraw::pathFinish

Terminates the current path

说明

public bool ImagickDraw::pathFinish ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Terminates the current path.

返回值

没有返回值。

ImagickDraw::pathLineToAbsolute

Draws a line path

说明

public bool ImagickDraw::pathLineToAbsolute ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a line path from the current point to the given coordinate using absolute coordinates. The coordinate then becomes the new current point.

参数

x
starting x coordinate

y
ending x coordinate

返回值

没有返回值。

ImagickDraw::pathLineToHorizontalAbsolute

Draws a horizontal line path

说明

public bool <span class="methodname">ImagickDraw::pathLineToHorizontalAbsolute ( float $x )

Warning

本函数还未编写文档,仅有参数列表。

Draws a horizontal line path from the current point to the target point using absolute coordinates. The target point then becomes the new current point.

参数

x
x coordinate

返回值

没有返回值。

ImagickDraw::pathLineToHorizontalRelative

Draws a horizontal line

说明

public bool <span class="methodname">ImagickDraw::pathLineToHorizontalRelative ( float $x )

Warning

本函数还未编写文档,仅有参数列表。

Draws a horizontal line path from the current point to the target point using relative coordinates. The target point then becomes the new current point.

参数

x
x coordinate

返回值

没有返回值。

ImagickDraw::pathLineToRelative

Draws a line path

说明

public bool ImagickDraw::pathLineToRelative ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a line path from the current point to the given coordinate using relative coordinates. The coordinate then becomes the new current point.

参数

x
starting x coordinate

y
starting y coordinate

返回值

没有返回值。

ImagickDraw::pathLineToVerticalAbsolute

Draws a vertical line

说明

public bool ImagickDraw::pathLineToVerticalAbsolute ( float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a vertical line path from the current point to the target point using absolute coordinates. The target point then becomes the new current point.

参数

y
y coordinate

返回值

没有返回值。

ImagickDraw::pathLineToVerticalRelative

Draws a vertical line path

说明

public bool ImagickDraw::pathLineToVerticalRelative ( float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a vertical line path from the current point to the target point using relative coordinates. The target point then becomes the new current point.

参数

y
y coordinate

返回值

没有返回值。

ImagickDraw::pathMoveToAbsolute

Starts a new sub-path

说明

public bool ImagickDraw::pathMoveToAbsolute ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Starts a new sub-path at the given coordinate using absolute coordinates. The current point then becomes the specified coordinate.

参数

x
x coordinate of the starting point

y
y coordinate of the starting point

返回值

没有返回值。

ImagickDraw::pathMoveToRelative

Starts a new sub-path

说明

public bool ImagickDraw::pathMoveToRelative ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Starts a new sub-path at the given coordinate using relative coordinates. The current point then becomes the specified coordinate.

参数

x
target x coordinate

y
target y coordinate

返回值

没有返回值。

ImagickDraw::pathStart

Declares the start of a path drawing list

说明

public bool ImagickDraw::pathStart ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Declares the start of a path drawing list which is terminated by a matching DrawPathFinish() command. All other DrawPath commands must be enclosed between a and a DrawPathFinish() command. This is because path drawing commands are subordinate commands and they do not function by themselves.

返回值

没有返回值。

范例

示例 #1 ImagickDraw::pathStart

<?php
function pathStart($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    $draw->pathStart();
    $draw->pathMoveToAbsolute(50, 50);
    $draw->pathLineToAbsolute(100, 50);
    $draw->pathLineToRelative(0, 50);
    $draw->pathLineToHorizontalRelative(-50);
    $draw->pathFinish();

    $draw->pathStart();
    $draw->pathMoveToAbsolute(50, 50);
    $draw->pathMoveToRelative(300, 0);
    $draw->pathLineToRelative(50, 0);
    $draw->pathLineToVerticalRelative(50);
    $draw->pathLineToHorizontalAbsolute(350);
    $draw->pathclose();
    $draw->pathFinish();

    $draw->pathStart();
    $draw->pathMoveToAbsolute(50, 300);
    $draw->pathCurveToAbsolute(50, 300, 100, 200, 300, 300);
    $draw->pathLineToVerticalAbsolute(350);
    $draw->pathFinish();

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::point

Draws a point

说明

public bool ImagickDraw::point ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Draws a point using the current stroke color and stroke thickness at the specified coordinates.

参数

x
point's x coordinate

y
point's y coordinate

返回值

没有返回值。

范例

示例 #1 ImagickDraw::point

<?php
function point($fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setFillColor($fillColor);

    for ($x = 0; $x < 10000; $x++) {
        $draw->point(rand(0, 500), rand(0, 500));
    }

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::polygon

Draws a polygon

说明

public bool ImagickDraw::polygon ( <span class="methodparam">array $coordinates )

Warning

本函数还未编写文档,仅有参数列表。

Draws a polygon using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates.

参数

coordinates
multidimensional array like array( array( 'x' => 3, 'y' => 4 ), array( 'x' => 2, 'y' => 6 ) );

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::polygon

<?php
function polygon($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(4);

    $draw->setFillColor($fillColor);

    $points = [
        ['x' => 40 * 5, 'y' => 10 * 5],
        ['x' => 20 * 5, 'y' => 20 * 5], 
        ['x' => 70 * 5, 'y' => 50 * 5], 
        ['x' => 60 * 5, 'y' => 15 * 5],
    ];

    $draw->polygon($points);

    $image = new \Imagick();
    $image->newImage(500, 300, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::polyline

Draws a polyline

说明

public bool ImagickDraw::polyline ( <span class="methodparam">array $coordinates )

Warning

本函数还未编写文档,仅有参数列表。

Draws a polyline using the current stroke, stroke width, and fill color or texture, using the specified array of coordinates.

参数

coordinates
array of x and y coordinates: array( array( 'x' => 4, 'y' => 6 ), array( 'x' => 8, 'y' => 10 ) )

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::polyline

<?php
function polyline($strokeColor, $fillColor, $backgroundColor) {
    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(5);

    $points = [
        ['x' => 40 * 5, 'y' => 10 * 5],
        ['x' => 20 * 5, 'y' => 20 * 5],
        ['x' => 70 * 5, 'y' => 50 * 5],
        ['x' => 60 * 5, 'y' => 15 * 5]
    ];

    $draw->polyline($points);

    $image = new \Imagick();
    $image->newImage(500, 300, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::pop

Destroys the current ImagickDraw in the stack, and returns to the previously pushed ImagickDraw

说明

public bool ImagickDraw::pop ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Destroys the current ImagickDraw in the stack, and returns to the previously pushed ImagickDraw. Multiple ImagickDraws may exist. It is an error to attempt to pop more ImagickDraws than have been pushed, and it is proper form to pop all ImagickDraws which have been pushed.

返回值

Returns true on success and false on failure.

ImagickDraw::popClipPath

Terminates a clip path definition

说明

public bool ImagickDraw::popClipPath ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Terminates a clip path definition.

返回值

没有返回值。

ImagickDraw::popDefs

Terminates a definition list

说明

public bool ImagickDraw::popDefs ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Terminates a definition list.

返回值

没有返回值。

范例

示例 #1 ImagickDraw::popDefs

<?php
function popDefs($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setstrokeOpacity(1);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->pushDefs();
    $draw->setStrokeColor('white');
    $draw->rectangle(50, 50, 200, 200);
    $draw->popDefs();

    $draw->rectangle(300, 50, 450, 200);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::popPattern

Terminates a pattern definition

说明

public bool ImagickDraw::popPattern ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Terminates a pattern definition.

返回值

成功时返回 true, 或者在失败时返回 false

ImagickDraw::push

Clones the current ImagickDraw and pushes it to the stack

说明

public bool ImagickDraw::push ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Clones the current ImagickDraw to create a new ImagickDraw, which is then added to the ImagickDraw stack. The original drawing ImagickDraw(s) may be returned to by invoking pop(). The ImagickDraws are stored on a ImagickDraw stack. For every Pop there must have already been an equivalent Push.

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 ImagickDraw::push

<?php
function push($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillModifiedColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->push();
    $draw->translate(50, 50);
    $draw->rectangle(200, 200, 300, 300);
    $draw->pop();
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::pushClipPath

Starts a clip path definition

说明

public bool ImagickDraw::pushClipPath ( <span class="methodparam">string $clip_mask_id )

Warning

本函数还未编写文档,仅有参数列表。

Starts a clip path definition which is comprised of any number of drawing commands and terminated by a ImagickDraw::popClipPath() command.

参数

clip_mask_id
Clip mask Id

返回值

没有返回值。

ImagickDraw::pushDefs

Indicates that following commands create named elements for early processing

说明

public bool ImagickDraw::pushDefs ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Indicates that commands up to a terminating ImagickDraw::popDefs() command create named elements (e.g. clip-paths, textures, etc.) which may safely be processed earlier for the sake of efficiency.

返回值

没有返回值。

ImagickDraw::pushPattern

Indicates that subsequent commands up to a ImagickDraw::opPattern() command comprise the definition of a named pattern

说明

public bool ImagickDraw::pushPattern ( <span class="methodparam">string $pattern_id , <span class="type">float $x , <span class="type">float $y , <span class="type">float $width , <span class="methodparam">float $height )

Warning

本函数还未编写文档,仅有参数列表。

Indicates that subsequent commands up to a DrawPopPattern() command comprise the definition of a named pattern. The pattern space is assigned top left corner coordinates, a width and height, and becomes its own drawing space. Anything which can be drawn may be used in a pattern definition. Named patterns may be used as stroke or brush definitions.

参数

pattern_id
the pattern Id

x
x coordinate of the top-left corner

y
y coordinate of the top-left corner

width
width of the pattern

height
height of the pattern

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 ImagickDraw::pushPattern

<?php
function pushPattern($strokeColor, $fillColor, $backgroundColor) {
    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(1);

    $draw->pushPattern("MyFirstPattern", 0, 0, 50, 50);
    for ($x = 0; $x < 50; $x += 10) {
        for ($y = 0; $y < 50; $y += 5) {
            $positionX = $x + (($y / 5) % 5);
            $draw->rectangle($positionX, $y, $positionX + 5, $y + 5);
        }
    }
    $draw->popPattern();

    $draw->setFillOpacity(0);
    $draw->rectangle(100, 100, 400, 400);
    $draw->setFillOpacity(1);

    $draw->setFillOpacity(1);

    $draw->push();
    $draw->setFillPatternURL('#MyFirstPattern');
    $draw->setFillColor('yellow');
    $draw->rectangle(100, 100, 400, 400);
    $draw->pop();

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::rectangle

Draws a rectangle

说明

public bool ImagickDraw::rectangle ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 )

Warning

本函数还未编写文档,仅有参数列表。

Draws a rectangle given two coordinates and using the current stroke, stroke width, and fill settings.

参数

x1
x coordinate of the top left corner

y1
y coordinate of the top left corner

x2
x coordinate of the bottom right corner

y2
y coordinate of the bottom right corner

返回值

没有返回值。

范例

示例 #1 ImagickDraw::rectangle

<?php
function rectangle($strokeColor, $fillColor, $backgroundColor) {
    $draw = new \ImagickDraw();
    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);

    $draw->rectangle(200, 200, 300, 300);
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::render

Renders all preceding drawing commands onto the image

说明

public bool ImagickDraw::render ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Renders all preceding drawing commands onto the image.

返回值

成功时返回 true, 或者在失败时返回 false

ImagickDraw::resetVectorGraphics

Description

说明

public bool ImagickDraw::resetVectorGraphics ( <span class="methodparam">void )

Resets the vector graphics.

参数

此函数没有参数。

返回值

成功时返回 true

ImagickDraw::rotate

Applies the specified rotation to the current coordinate space

说明

public bool ImagickDraw::rotate ( <span class="methodparam">float $degrees )

Warning

本函数还未编写文档,仅有参数列表。

Applies the specified rotation to the current coordinate space.

参数

degrees
degrees to rotate

返回值

没有返回值。

范例

示例 #1 ImagickDraw::rotate

<?php
function rotate($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor) {
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeOpacity(1);
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);
    $draw->setFillColor($fillModifiedColor);
    $draw->rotate(15);
    $draw->rectangle(200, 200, 300, 300);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::roundRectangle

Draws a rounded rectangle

说明

public bool ImagickDraw::roundRectangle ( <span class="methodparam">float $x1 , <span class="methodparam">float $y1 , <span class="methodparam">float $x2 , <span class="methodparam">float $y2 , <span class="methodparam">float $rx , <span class="methodparam">float $ry )

Warning

本函数还未编写文档,仅有参数列表。

Draws a rounded rectangle given two coordinates, x & y corner radiuses and using the current stroke, stroke width, and fill settings.

参数

x1
x coordinate of the top left corner

y1
y coordinate of the top left corner

x2
x coordinate of the bottom right

y2
y coordinate of the bottom right

rx
x rounding

ry
y rounding

返回值

没有返回值。

范例

示例 #1 ImagickDraw::roundRectangle

<?php
function roundRectangle($strokeColor, $fillColor, $backgroundColor, $startX, $startY, $endX, $endY, $roundX, $roundY) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);

    $draw->roundRectangle($startX, $startY, $endX, $endY, $roundX, $roundY);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::scale

Adjusts the scaling factor

说明

public bool ImagickDraw::scale ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Adjusts the scaling factor to apply in the horizontal and vertical directions to the current coordinate space.

参数

x
horizontal factor

y
vertical factor

返回值

没有返回值。

范例

示例 #1 ImagickDraw::scale

<?php
function scale($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(4);
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);
    $draw->setFillColor($fillModifiedColor);
    $draw->scale(1.4, 1.4);
    $draw->rectangle(200, 200, 300, 300);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setClipPath

Associates a named clipping path with the image

说明

public bool ImagickDraw::setClipPath ( <span class="methodparam">string $clip_mask )

Warning

本函数还未编写文档,仅有参数列表。

Associates a named clipping path with the image. Only the areas drawn on by the clipping path will be modified as long as it remains in effect.

参数

clip_mask
the clipping path name

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setClipPath

<?php
function setClipPath($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);

    $clipPathName = 'testClipPath';

    $draw->pushClipPath($clipPathName);
    $draw->rectangle(0, 0, 250, 250);
    $draw->popClipPath();
    $draw->setClipPath($clipPathName);
    $draw->rectangle(100, 100, 400, 400);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setClipRule

Set the polygon fill rule to be used by the clipping path

说明

public bool ImagickDraw::setClipRule ( <span class="methodparam">int $fill_rule )

Warning

本函数还未编写文档,仅有参数列表。

Set the polygon fill rule to be used by the clipping path.

参数

fill_rule
FILLRULE_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setClipRule

<?php
function setClipRule($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);
    //\Imagick::FILLRULE_EVENODD
    //\Imagick::FILLRULE_NONZERO

    $clipPathName = 'testClipPath';
    $draw->pushClipPath($clipPathName);
    $draw->setClipRule(\Imagick::FILLRULE_EVENODD);
    $draw->rectangle(0, 0, 300, 500);
    $draw->rectangle(200, 0, 500, 500);
    $draw->popClipPath();
    $draw->setClipPath($clipPathName);
    $draw->rectangle(200, 200, 300, 300);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setClipUnits

Sets the interpretation of clip path units

说明

public bool ImagickDraw::setClipUnits ( <span class="methodparam">int $clip_units )

Warning

本函数还未编写文档,仅有参数列表。

Sets the interpretation of clip path units.

参数

clip_units
the number of clip units

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setClipUnits

<?php
function setClipUnits($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);
    $clipPathName = 'testClipPath';
    $draw->setClipUnits(\Imagick::RESOLUTION_PIXELSPERINCH);
    $draw->pushClipPath($clipPathName);
    $draw->rectangle(0, 0, 250, 250);
    $draw->popClipPath();
    $draw->setClipPath($clipPathName);

    //RESOLUTION_PIXELSPERINCH
    //RESOLUTION_PIXELSPERCENTIMETER

    $draw->rectangle(200, 200, 300, 300);
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFillAlpha

Sets the opacity to use when drawing using the fill color or fill texture

说明

public bool ImagickDraw::setFillAlpha ( <span class="methodparam">float $opacity )

Warning

本函数还未编写文档,仅有参数列表。

Sets the opacity to use when drawing using the fill color or fill texture. Fully opaque is 1.0.

参数

opacity
fill alpha

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFillAlpha

<?php
function setFillAlpha($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);
    $draw->rectangle(100, 200, 200, 300);
    @$draw->setFillAlpha(0.4);
    $draw->rectangle(300, 200, 400, 300);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFillColor

Sets the fill color to be used for drawing filled objects

说明

public bool ImagickDraw::setFillColor ( <span class="methodparam">ImagickPixel $fill_pixel )

Warning

本函数还未编写文档,仅有参数列表。

Sets the fill color to be used for drawing filled objects.

参数

fill_pixel
ImagickPixel to use to set the color

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFillColor

<?php
function setFillColor($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(1.5);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->rectangle(50, 50, 150, 150);

    $draw->setFillColor("rgb(200, 32, 32)");
    $draw->rectangle(200, 50, 300, 150);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setFillOpacity

Sets the opacity to use when drawing using the fill color or fill texture

说明

public bool ImagickDraw::setFillOpacity ( <span class="methodparam">float $fillOpacity )

Warning

本函数还未编写文档,仅有参数列表。

Sets the opacity to use when drawing using the fill color or fill texture. Fully opaque is 1.0.

参数

fillOpacity
the fill opacity

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFillOpacity

<?php
function setFillOpacity($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeWidth(2);

    $draw->rectangle(100, 200, 200, 300);

    $draw->setFillOpacity(0.4);
    $draw->rectangle(300, 200, 400, 300);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFillPatternURL

Sets the URL to use as a fill pattern for filling objects

说明

public bool ImagickDraw::setFillPatternURL ( <span class="methodparam">string $fill_url )

Warning

本函数还未编写文档,仅有参数列表。

Sets the URL to use as a fill pattern for filling objects. Only local URLs ("#identifier") are supported at this time. These local URLs are normally created by defining a named fill pattern with DrawPushPattern/DrawPopPattern.

参数

fill_url
URL to use to obtain fill pattern.

返回值

成功时返回 true, 或者在失败时返回 false

ImagickDraw::setFillRule

Sets the fill rule to use while drawing polygons

说明

public bool ImagickDraw::setFillRule ( <span class="methodparam">int $fill_rule )

Warning

本函数还未编写文档,仅有参数列表。

Sets the fill rule to use while drawing polygons.

参数

fill_rule
FILLRULE_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFillRule

<?php
function setFillRule($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeWidth(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $fillRules = [\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD];

    $points = 11;
    $size = 150;

    $draw->translate(175, 160);

    for ($x = 0; $x < 2; $x++) {
        $draw->setFillRule($fillRules[$x]);
        $draw->pathStart();
        for ($n = 0; $n < $points * 2; $n++) {

            if ($n >= $points) {
                $angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180;
            }
            else {
                $angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180;
            }

            $positionX = $size * sin($angle);
            $positionY = $size * cos($angle);

            if ($n == 0) {
                $draw->pathMoveToAbsolute($positionX, $positionY);
            }
            else {
                $draw->pathLineToAbsolute($positionX, $positionY);
            }
        }

        $draw->pathClose();
        $draw->pathFinish();

        $draw->translate(325, 0);
    }

    $image = new \Imagick();
    $image->newImage(700, 320, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setFont

Sets the fully-specified font to use when annotating with text

说明

public bool ImagickDraw::setFont ( <span class="methodparam">string $font_name )

Warning

本函数还未编写文档,仅有参数列表。

Sets the fully-specified font to use when annotating with text.

参数

font_name

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::setFont

<?php
function setFont($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);
    $draw->setFontSize(36);

    $draw->setFont("../fonts/Arial.ttf");
    $draw->annotation(50, 50, "Lorem Ipsum!");

    $draw->setFont("../fonts/Consolas.ttf");
    $draw->annotation(50, 100, "Lorem Ipsum!");

    $draw->setFont("../fonts/CANDY.TTF");
    $draw->annotation(50, 150, "Lorem Ipsum!");

    $draw->setFont("../fonts/Inconsolata-dz.otf");
    $draw->annotation(50, 200, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(500, 300, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFontFamily

Sets the font family to use when annotating with text

说明

public bool ImagickDraw::setFontFamily ( <span class="methodparam">string $font_family )

Warning

本函数还未编写文档,仅有参数列表。

Sets the font family to use when annotating with text.

参数

font_family
the font family

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::setFontFamily

<?php
function setFontFamily($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $strokeColor = new \ImagickPixel($strokeColor);
    $fillColor = new \ImagickPixel($fillColor);

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);

    $draw->setFontSize(48);

    $draw->setFontFamily("Times");
    $draw->annotation(50, 50, "Lorem Ipsum!");

    $draw->setFontFamily("AvantGarde");
    $draw->annotation(50, 100, "Lorem Ipsum!");

    $draw->setFontFamily("NewCenturySchlbk");    
    $draw->annotation(50, 150, "Lorem Ipsum!");

    $draw->setFontFamily("Palatino");
    $draw->annotation(50, 200, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(450, 250, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFontSize

Sets the font pointsize to use when annotating with text

说明

public bool ImagickDraw::setFontSize ( <span class="methodparam">float $pointsize )

Warning

本函数还未编写文档,仅有参数列表。

Sets the font pointsize to use when annotating with text.

参数

pointsize
the point size

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFontSize

<?php
function setFontSize($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFont("../fonts/Arial.ttf");

    $sizes = [24, 36, 48, 60, 72];

    foreach ($sizes as $size) {
        $draw->setFontSize($size);
        $draw->annotation(50, ($size * $size / 16), "Lorem Ipsum!");
    }

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFontStretch

Sets the font stretch to use when annotating with text

说明

public bool ImagickDraw::setFontStretch ( <span class="methodparam">int $fontStretch )

Warning

本函数还未编写文档,仅有参数列表。

Sets the font stretch to use when annotating with text. The AnyStretch enumeration acts as a wild-card "don't care" option.

参数

fontStretch
STRETCH_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFontStretch

<?php
function setFontStretch($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(36);

    $fontStretchTypes = [
        \Imagick::STRETCH_ULTRACONDENSED, 
        \Imagick::STRETCH_CONDENSED, 
        \Imagick::STRETCH_SEMICONDENSED, 
        \Imagick::STRETCH_SEMIEXPANDED, 
        \Imagick::STRETCH_EXPANDED, 
        \Imagick::STRETCH_EXTRAEXPANDED, 
        \Imagick::STRETCH_ULTRAEXPANDED, 
        \Imagick::STRETCH_ANY
    ];

    $offset = 0;
    foreach ($fontStretchTypes as $fontStretch) {
        $draw->setFontStretch($fontStretch);
        $draw->annotation(50, 75 + $offset, "Lorem Ipsum!");
        $offset += 50;
    }

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFontStyle

Sets the font style to use when annotating with text

说明

public bool ImagickDraw::setFontStyle ( <span class="methodparam">int $style )

Warning

本函数还未编写文档,仅有参数列表。

Sets the font style to use when annotating with text. The AnyStyle enumeration acts as a wild-card "don't care" option.

参数

style
STYLETYPE_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setFontStyle

<?php
function setFontStyle($fillColor, $strokeColor, $backgroundColor) {
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setFontSize(36);
    $draw->setFontStyle(\Imagick::STYLE_NORMAL);
    $draw->annotation(50, 50, "Lorem Ipsum!");

    $draw->setFontStyle(\Imagick::STYLE_ITALIC);
    $draw->annotation(50, 100, "Lorem Ipsum!");

    $draw->setFontStyle(\Imagick::STYLE_OBLIQUE);
    $draw->annotation(50, 150, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(350, 300, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setFontWeight

Sets the font weight

说明

public bool ImagickDraw::setFontWeight ( <span class="methodparam">int $font_weight )

Warning

本函数还未编写文档,仅有参数列表。

Sets the font weight to use when annotating with text.

参数

font_weight

返回值

范例

示例 #1 ImagickDraw::setFontWeight

<?php
function setFontWeight($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(1);

    $draw->setFontSize(36);

    $draw->setFontWeight(100);
    $draw->annotation(50, 50, "Lorem Ipsum!");

    $draw->setFontWeight(200);
    $draw->annotation(50, 100, "Lorem Ipsum!");

    $draw->setFontWeight(400);
    $draw->annotation(50, 150, "Lorem Ipsum!");

    $draw->setFontWeight(800);
    $draw->annotation(50, 200, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setGravity

Sets the text placement gravity

说明

public bool ImagickDraw::setGravity ( <span class="methodparam">int $gravity )

Warning

本函数还未编写文档,仅有参数列表。

Sets the text placement gravity to use when annotating with text.

参数

gravity
GRAVITY_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setGravity

<?php
function setGravity($fillColor, $strokeColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setFontSize(24);

    $gravitySettings = array(
        \Imagick::GRAVITY_NORTHWEST => 'NorthWest',
        \Imagick::GRAVITY_NORTH => 'North',
        \Imagick::GRAVITY_NORTHEAST => 'NorthEast',
        \Imagick::GRAVITY_WEST => 'West',
        \Imagick::GRAVITY_CENTER => 'Centre',
        \Imagick::GRAVITY_SOUTHWEST => 'SouthWest',
        \Imagick::GRAVITY_SOUTH => 'South',
        \Imagick::GRAVITY_SOUTHEAST => 'SouthEast',
        \Imagick::GRAVITY_EAST => 'East'
    );

    $draw->setFont("../fonts/Arial.ttf");

    foreach ($gravitySettings as $type => $description) {
        $draw->setGravity($type);
        $draw->annotation(50, 50, '"' . $description . '"');
    }

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setResolution

Description

说明

public bool ImagickDraw::setResolution ( <span class="methodparam">float $x_resolution , <span class="type">float $y_resolution )

Sets the resolution.

参数

x_resolution

y_resolution

返回值

成功时返回 true

ImagickDraw::setStrokeAlpha

Specifies the opacity of stroked object outlines

说明

public bool ImagickDraw::setStrokeAlpha ( <span class="methodparam">float $opacity )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the opacity of stroked object outlines.

参数

opacity
opacity

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setStrokeAlpha

<?php
function setStrokeAlpha($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(4);
    $draw->line(100, 100, 400, 145);
    $draw->rectangle(100, 200, 225, 350);
    $draw->setStrokeOpacity(0.1);
    $draw->line(100, 120, 400, 165);
    $draw->rectangle(275, 200, 400, 350);

    $image = new \Imagick();
    $image->newImage(500, 400, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeAntialias

Controls whether stroked outlines are antialiased

说明

public bool ImagickDraw::setStrokeAntialias ( <span class="methodparam">bool $stroke_antialias )

Warning

本函数还未编写文档,仅有参数列表。

Controls whether stroked outlines are antialiased. Stroked outlines are antialiased by default. When antialiasing is disabled stroked pixels are thresholded to determine if the stroke color or underlying canvas color should be used.

参数

stroke_antialias
the antialias setting

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setStrokeAntialias

<?php
function setStrokeAntialias($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setStrokeAntialias(false);
    $draw->line(100, 100, 400, 105);

    $draw->line(100, 140, 400, 185);

    $draw->setStrokeAntialias(true);
    $draw->line(100, 110, 400, 115);
    $draw->line(100, 150, 400, 195);

    $image = new \Imagick();
    $image->newImage(500, 250, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeColor

Sets the color used for stroking object outlines

说明

public bool ImagickDraw::setStrokeColor ( <span class="methodparam">ImagickPixel $stroke_pixel )

Warning

本函数还未编写文档,仅有参数列表。

Sets the color used for stroking object outlines.

参数

stroke_pixel
the stroke color

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setStrokeColor

<?php
function setStrokeColor($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(5);

    $draw->line(100, 100, 400, 145);
    $draw->rectangle(100, 200, 225, 350);

    $draw->setStrokeOpacity(0.1);
    $draw->line(100, 120, 400, 165);
    $draw->rectangle(275, 200, 400, 350);

    $image = new \Imagick();
    $image->newImage(500, 400, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeDashArray

Specifies the pattern of dashes and gaps used to stroke paths

说明

public bool ImagickDraw::setStrokeDashArray ( <span class="methodparam">array $dashArray )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the pattern of dashes and gaps used to stroke paths. The strokeDashArray represents an array of numbers that specify the lengths of alternating dashes and gaps in pixels. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. To remove an existing dash array, pass a zero number_elements argument and null dash_array. A typical strokeDashArray_ array might contain the members 5 3 2.

参数

dashArray
array of floats

返回值

成功时返回 true

范例

示例 #1 <span class="function">ImagickDraw::setStrokeDashArray

<?php
function setStrokeDashArray($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(4);

    $draw->setStrokeDashArray([10, 10]);
    $draw->rectangle(100, 50, 225, 175);

    $draw->setStrokeDashArray([20, 5, 20, 5, 5, 5,]);
    $draw->rectangle(275, 50, 400, 175);

    $draw->setStrokeDashArray([20, 5, 20, 5, 5]);
    $draw->rectangle(100, 200, 225, 350);

    $draw->setStrokeDashArray([1, 1, 1, 1, 2, 2, 3, 3, 5, 5, 8, 8, 13, 13, 21, 21, 34, 34, 55, 55, 89, 89, 144, 144, 233, 233, 377, 377, 610, 610, 987, 987, 1597, 1597, 2584, 2584, 4181, 4181,]);

    $draw->rectangle(275, 200, 400, 350);

    $image = new \Imagick();
    $image->newImage(500, 400, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeDashOffset

Specifies the offset into the dash pattern to start the dash

说明

public bool ImagickDraw::setStrokeDashOffset ( <span class="methodparam">float $dash_offset )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the offset into the dash pattern to start the dash.

参数

dash_offset
dash offset

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setStrokeDashOffset

<?php
function setStrokeDashOffset($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(4);
    $draw->setStrokeDashArray([20, 20]);
    $draw->setStrokeDashOffset(0);
    $draw->rectangle(100, 50, 225, 175);

    //Start the dash effect halfway through the solid portion
    $draw->setStrokeDashOffset(10);
    $draw->rectangle(275, 50, 400, 175);

    //Start the dash effect on the space portion
    $draw->setStrokeDashOffset(20);
    $draw->rectangle(100, 200, 225, 350);
    $draw->setStrokeDashOffset(5);
    $draw->rectangle(275, 200, 400, 350);

    $image = new \Imagick();
    $image->newImage(500, 400, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeLineCap

Specifies the shape to be used at the end of open subpaths when they are stroked

说明

public bool ImagickDraw::setStrokeLineCap ( <span class="methodparam">int $linecap )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the shape to be used at the end of open subpaths when they are stroked.

参数

linecap
LINECAP_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setStrokeLineCap

<?php
function setStrokeLineCap($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(25);

    $lineTypes = [\Imagick::LINECAP_BUTT, \Imagick::LINECAP_ROUND, \Imagick::LINECAP_SQUARE,];

    $offset = 0;

    foreach ($lineTypes as $lineType) {
        $draw->setStrokeLineCap($lineType);
        $draw->line(50 + $offset, 50, 50 + $offset, 250);
        $offset += 50;
    }

    $imagick = new \Imagick();
    $imagick->newImage(300, 300, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setStrokeLineJoin

Specifies the shape to be used at the corners of paths when they are stroked

说明

public bool ImagickDraw::setStrokeLineJoin ( <span class="methodparam">int $linejoin )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the shape to be used at the corners of paths (or other vector shapes) when they are stroked.

参数

linejoin
LINEJOIN_ constant

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setStrokeLineJoin

<?php
function setStrokeLineJoin($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeWidth(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(20);

    $offset = 220;

    $lineJoinStyle = [
        \Imagick::LINEJOIN_MITER,
        \Imagick::LINEJOIN_ROUND,
        \Imagick::LINEJOIN_BEVEL,
        ];

    for ($x = 0; $x < count($lineJoinStyle); $x++) {
        $draw->setStrokeLineJoin($lineJoinStyle[$x]);
        $points = [
            ['x' => 40 * 5, 'y' => 10 * 5 + $x * $offset],
            ['x' => 20 * 5, 'y' => 20 * 5 + $x * $offset],
            ['x' => 70 * 5, 'y' => 50 * 5 + $x * $offset],
            ['x' => 40 * 5, 'y' => 10 * 5 + $x * $offset],
        ];

        $draw->polyline($points);
    }

    $image = new \Imagick();
    $image->newImage(500, 700, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeMiterLimit

Specifies the miter limit

说明

public bool ImagickDraw::setStrokeMiterLimit ( <span class="methodparam">int $miterlimit )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the miter limit. When two line segments meet at a sharp angle and miter joins have been specified for 'lineJoin', it is possible for the miter to extend far beyond the thickness of the line stroking the path. The miterLimit' imposes a limit on the ratio of the miter length to the 'lineWidth'.

参数

miterlimit
the miter limit

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setStrokeMiterLimit

<?php
function setStrokeMiterLimit($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeOpacity(0.6);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(10);

    $yOffset = 100;

    $draw->setStrokeLineJoin(\Imagick::LINEJOIN_MITER);

    for ($y = 0; $y < 3; $y++) {

        $draw->setStrokeMiterLimit(40 * $y);

        $points = [
            ['x' => 22 * 3, 'y' => 15 * 4 + $y * $yOffset],
            ['x' => 20 * 3, 'y' => 20 * 4 + $y * $yOffset],
            ['x' => 70 * 5, 'y' => 45 * 4 + $y * $yOffset],
        ];

        $draw->polygon($points);
    }

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    $image->setImageType(\Imagick::IMGTYPE_PALETTE);
    $image->setImageCompressionQuality(100);
    $image->stripImage();

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokeOpacity

Specifies the opacity of stroked object outlines

说明

public bool ImagickDraw::setStrokeOpacity ( <span class="methodparam">float $stroke_opacity )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the opacity of stroked object outlines.

参数

stroke_opacity
stroke opacity. 1.0 is fully opaque

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setStrokeOpacity

<?php
function setStrokeOpacity($strokeColor, $fillColor, $backgroundColor) {
    $draw = new \ImagickDraw();

    $draw->setStrokeWidth(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(10);
    $draw->setStrokeOpacity(1);
    $draw->line(100, 80, 400, 125);
    $draw->rectangle(25, 200, 150, 350);
    $draw->setStrokeOpacity(0.5);
    $draw->line(100, 100, 400, 145);
    $draw->rectangle(200, 200, 325, 350);
    $draw->setStrokeOpacity(0.2);
    $draw->line(100, 120, 400, 165);
    $draw->rectangle(375, 200, 500, 350);

    $image = new \Imagick();
    $image->newImage(550, 400, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setStrokePatternURL

Sets the pattern used for stroking object outlines

说明

public bool ImagickDraw::setStrokePatternURL ( <span class="methodparam">string $stroke_url )

Warning

本函数还未编写文档,仅有参数列表。

Sets the pattern used for stroking object outlines.

参数

stroke_url
stroke URL

返回值

imagick.imagickdraw.return.success;

ImagickDraw::setStrokeWidth

Sets the width of the stroke used to draw object outlines

说明

public bool ImagickDraw::setStrokeWidth ( <span class="methodparam">float $stroke_width )

Warning

本函数还未编写文档,仅有参数列表。

Sets the width of the stroke used to draw object outlines.

参数

stroke_width
stroke width

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setStrokeWidth

<?php
function setStrokeWidth($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeWidth(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->line(100, 100, 400, 145);
    $draw->rectangle(100, 200, 225, 350);
    $draw->setStrokeWidth(5);
    $draw->line(100, 120, 400, 165);
    $draw->rectangle(275, 200, 400, 350);

    $image = new \Imagick();
    $image->newImage(500, 400, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::setTextAlignment

Specifies a text alignment

说明

public bool ImagickDraw::setTextAlignment ( <span class="methodparam">int $alignment )

Warning

本函数还未编写文档,仅有参数列表。

Specifies a text alignment to be applied when annotating with text.

参数

alignment
ALIGN_ constant

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setTextAlignment

<?php
function setTextAlignment($strokeColor, $fillColor, $backgroundColor) {
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setFontSize(36);

    $draw->setTextAlignment(\Imagick::ALIGN_LEFT);
    $draw->annotation(250, 75, "Lorem Ipsum!");
    $draw->setTextAlignment(\Imagick::ALIGN_CENTER);
    $draw->annotation(250, 150, "Lorem Ipsum!");
    $draw->setTextAlignment(\Imagick::ALIGN_RIGHT);
    $draw->annotation(250, 225, "Lorem Ipsum!");
    $draw->line(250, 0, 250, 500);

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setTextAntialias

Controls whether text is antialiased

说明

public bool ImagickDraw::setTextAntialias ( <span class="methodparam">bool $antiAlias )

Warning

本函数还未编写文档,仅有参数列表。

Controls whether text is antialiased. Text is antialiased by default.

参数

antiAlias

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setTextAntialias

<?php
function setTextAntialias($fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();
    $draw->setStrokeColor('none');
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(1);
    $draw->setFontSize(32);
    $draw->setTextAntialias(false);
    $draw->annotation(5, 30, "Lorem Ipsum!");
    $draw->setTextAntialias(true);
    $draw->annotation(5, 65, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(220, 80, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    //Scale the image so that people can see the aliasing.
    $imagick->scaleImage(220 * 6, 80 * 6);
    $imagick->cropImage(640, 480, 0, 0);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setTextDecoration

Specifies a decoration

说明

public bool ImagickDraw::setTextDecoration ( <span class="methodparam">int $decoration )

Warning

本函数还未编写文档,仅有参数列表。

Specifies a decoration to be applied when annotating with text.

参数

decoration
DECORATION_ constant

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setTextDecoration

<?php
function setTextDecoration($strokeColor, $fillColor, $backgroundColor, $textDecoration) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->setTextDecoration($textDecoration);
    $draw->annotation(50, 75, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(500, 200, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setTextEncoding

Specifies the text code set

说明

public bool ImagickDraw::setTextEncoding ( <span class="methodparam">string $encoding )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the code set to use for text annotations. The only character encoding which may be specified at this time is "UTF-8" for representing Unicode as a sequence of bytes. Specify an empty string to set text encoding to the system's default. Successful text annotation using Unicode may require fonts designed to support Unicode.

参数

encoding
the encoding name

返回值

没有返回值。

ImagickDraw::setTextInterlineSpacing

Description

说明

public bool ImagickDraw::setTextInterlineSpacing ( float $spacing )

Sets the text interline spacing.

Warning

本函数还未编写文档,仅有参数列表。

参数

spacing

返回值

成功时返回 true

ImagickDraw::setTextInterwordSpacing

Description

说明

public bool ImagickDraw::setTextInterwordSpacing ( float $spacing )

Sets the text interword spacing.

参数

spacing

返回值

成功时返回 true

ImagickDraw::setTextKerning

Description

说明

public bool ImagickDraw::setTextKerning ( <span class="methodparam">float $kerning )

Sets the text kerning

Warning

本函数还未编写文档,仅有参数列表。

参数

kerning

返回值

成功时返回 true

ImagickDraw::setTextUnderColor

Specifies the color of a background rectangle

说明

public bool ImagickDraw::setTextUnderColor ( <span class="methodparam">ImagickPixel $under_color )

Warning

本函数还未编写文档,仅有参数列表。

Specifies the color of a background rectangle to place under text annotations.

参数

under_color
the under color

返回值

没有返回值。

范例

示例 #1 <span class="function">ImagickDraw::setTextUnderColor

<?php
function setTextUnderColor($strokeColor, $fillColor, $backgroundColor, $textUnderColor) {
    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->annotation(50, 75, "Lorem Ipsum!");
    $draw->setTextUnderColor($textUnderColor);
    $draw->annotation(50, 175, "Lorem Ipsum!");

    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setVectorGraphics

Sets the vector graphics

说明

public bool ImagickDraw::setVectorGraphics ( <span class="methodparam">string $xml )

Warning

本函数还未编写文档,仅有参数列表。

Sets the vector graphics associated with the specified ImagickDraw object. Use this method with ImagickDraw::getVectorGraphics() as a method to persist the vector graphics state.

参数

xml
xml containing the vector graphics

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 <span class="function">ImagickDraw::setVectorGraphics

<?php
function setVectorGraphics() {
    //Setup a draw object with some drawing in it.
    $draw = new \ImagickDraw();
    $draw->setFillColor("red");
    $draw->circle(20, 20, 50, 50);
    $draw->setFillColor("blue");
    $draw->circle(50, 70, 50, 50);
    $draw->rectangle(50, 120, 80, 150);

    //Get the drawing as a string
    $SVG = $draw->getVectorGraphics();

    //$svg is a string, and could be saved anywhere a string can be saved

    //Use the saved drawing to generate a new draw object
    $draw2 = new \ImagickDraw();
    //Apparently the SVG text is missing the root element. 
    $draw2->setVectorGraphics("<root>".$SVG."</root>");

    $imagick = new \Imagick();
    $imagick->newImage(200, 200, 'white');
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw2);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::setViewbox

Sets the overall canvas size

说明

public bool ImagickDraw::setViewbox ( <span class="methodparam">int $x1 , <span class="methodparam">int $y1 , <span class="methodparam">int $x2 , <span class="methodparam">int $y2 )

Warning

本函数还未编写文档,仅有参数列表。

Sets the overall canvas size to be recorded with the drawing vector data. Usually this will be specified using the same size as the canvas image. When the vector data is saved to SVG or MVG formats, the viewbox is use to specify the size of the canvas image that a viewer will render the vector data on.

参数

x1
left x coordinate

y1
left y coordinate

x2
right x coordinate

y2
right y coordinate

返回值

没有返回值。

范例

示例 #1 ImagickDraw::setViewBox

<?php
function setViewBox($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);

    /*

    Sets the overall canvas size to be recorded with the drawing vector data. Usually this will be specified using the same size as the canvas image. When the vector data is saved to SVG or MVG formats, the viewbox is use to specify the size of the canvas image that a viewer will render the vector data on.

     */

    $draw->circle(250, 250, 250, 0);
    $draw->setviewbox(0, 0, 200, 200);
    $draw->circle(125, 250, 250, 250);
    $draw->translate(250, 125);
    $draw->circle(0, 0, 125, 0);


    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");

    $imagick->drawImage($draw);

    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}

?>

ImagickDraw::skewX

Skews the current coordinate system in the horizontal direction

说明

public bool ImagickDraw::skewX ( <span class="methodparam">float $degrees )

Warning

本函数还未编写文档,仅有参数列表。

Skews the current coordinate system in the horizontal direction.

参数

degrees
degrees to skew

返回值

没有返回值。

范例

示例 #1 ImagickDraw::skewX

<?php
function skewX($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor, 
               $startX, $startY, $endX, $endY, $skew) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(2);
    $draw->setFillColor($fillColor);
    $draw->rectangle($startX, $startY, $endX, $endY);
    $draw->setFillColor($fillModifiedColor);
    $draw->skewX($skew);
    $draw->rectangle($startX, $startY, $endX, $endY);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::skewY

Skews the current coordinate system in the vertical direction

说明

public bool ImagickDraw::skewY ( <span class="methodparam">float $degrees )

Warning

本函数还未编写文档,仅有参数列表。

Skews the current coordinate system in the vertical direction.

参数

degrees
degrees to skew

返回值

没有返回值。

范例

示例 #1 ImagickDraw::skewY

<?php
function skewY($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor, 
               $startX, $startY, $endX, $endY, $skew) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeWidth(2);
    $draw->setFillColor($fillColor);
    $draw->rectangle($startX, $startY, $endX, $endY);
    $draw->setFillColor($fillModifiedColor);
    $draw->skewY($skew);
    $draw->rectangle($startX, $startY, $endX, $endY);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickDraw::translate

Applies a translation to the current coordinate system

说明

public bool ImagickDraw::translate ( <span class="methodparam">float $x , <span class="methodparam">float $y )

Warning

本函数还未编写文档,仅有参数列表。

Applies a translation to the current coordinate system which moves the coordinate system origin to the specified coordinate.

参数

x
horizontal translation

y
vertical translation

返回值

没有返回值。

范例

示例 #1 ImagickDraw::translate

<?php
function translate($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor, 
                   $startX, $startY, $endX, $endY, $translateX, $translateY) {

    $draw = new \ImagickDraw();

    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->rectangle($startX, $startY, $endX, $endY);

    $draw->setFillColor($fillModifiedColor);
    $draw->translate($translateX, $translateY);
    $draw->rectangle($startX, $startY, $endX, $endY);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

类摘要

ImagickPixel

class ImagickPixel {

public bool clear ( <span class="methodparam">void )

public <span class="methodname">__construct ([ <span class="methodparam">string $color ] )

public bool destroy ( <span class="methodparam">void )

public array getColor ([ <span class="methodparam">int $normalized<span class="initializer"> = 0 ] )

public string getColorAsString ( <span class="methodparam">void )

public int <span class="methodname">getColorCount ( <span class="methodparam">void )

public array getColorQuantum ( <span class="methodparam">void )

public float getColorValue ( <span class="methodparam">int $color )

public <span class="type">intfloat <span class="methodname">getColorValueQuantum ( <span class="methodparam">int $color )

public array getHSL ( <span class="methodparam">void )

public int <span class="methodname">getIndex ( <span class="methodparam">void )

public bool isPixelSimilar ( <span class="methodparam">ImagickPixel $color , <span class="type">float $fuzz )

public bool isPixelSimilarQuantum ( <span class="methodparam">string $color [, string $fuzz ] )

public bool isSimilar ( <span class="methodparam">ImagickPixel $color , <span class="type">float $fuzz )

public bool setColor ( <span class="methodparam">string $color )

public bool setcolorcount ( <span class="methodparam">int $colorCount )

public bool setColorValue ( <span class="methodparam">int $color , float $value )

public bool setColorValueQuantum ( <span class="methodparam">int $color , <span class="type">intfloat $value )

public bool setHSL ( <span class="type">float $hue , <span class="methodparam">float $saturation , float $luminosity )

public bool setIndex ( <span class="methodparam">int $index )

}

ImagickPixel::clear

Clears resources associated with this object

说明

public bool ImagickPixel::clear ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Clears the ImagickPixel object, leaving it in a fresh state. This also unsets any color associated with the object.

返回值

成功时返回 true

ImagickPixel::__construct

The ImagickPixel constructor

说明

public <span class="methodname">ImagickPixel::__construct ([ <span class="methodparam">string $color ] )

Warning

本函数还未编写文档,仅有参数列表。

Constructs an ImagickPixel object. If a color is specified, the object is constructed and then initialised with that color before being returned.

参数

color
The optional color string to use as the initial value of this object.

返回值

Returns an ImagickPixel object on success, throwing ImagickPixelException on failure.

范例

示例 #1 ImagickPixel::construct

<?php
function construct() {

    $columns = 4;

    $exampleColors = array(
        "rgba(100%, 0%, 0%, 0.5)",
        "hsb(33.3333%, 100%,  75%)", // medium green
        "hsl(120, 255,   191.25)", //medium green
        "graya(50%, 0.5)", //  semi-transparent mid gray
        "LightCoral", "none", //"cmyk(0.9, 0.48, 0.83, 0.50)",
        "#f00", //  #rgb
        "#ff0000", //  #rrggbb
        "#ff0000ff", //  #rrggbbaa
        "#ffff00000000", //  #rrrrggggbbbb
        "#ffff00000000ffff", //  #rrrrggggbbbbaaaa
        "rgb(255, 0, 0)", //  an integer in the range 0—255 for each component
        "rgb(100.0%, 0.0%, 0.0%)", //  a float in the range 0—100% for each component
        "rgb(255, 0, 0)", //  range 0 - 255
        "rgba(255, 0, 0, 1.0)", //  the same, with an explicit alpha value
        "rgb(100%, 0%, 0%)", //  range 0.0% - 100.0%
        "rgba(100%, 0%, 0%, 1.0)", //  the same, with an explicit alpha value
    );

    $draw = new \ImagickDraw();
    $count = 0;
    $black = new \ImagickPixel('rgb(0, 0, 0)');

    foreach ($exampleColors as $exampleColor) {
        $color = new \ImagickPixel($exampleColor);

        $draw->setstrokewidth(1.0);
        $draw->setStrokeColor($black);
        $draw->setFillColor($color);
        $offsetX = ($count % $columns) * 50 + 5;
        $offsetY = intval($count / $columns) * 50 + 5;
        $draw->rectangle(0 + $offsetX, 0 + $offsetY, 40 + $offsetX, 40 + $offsetY);
        $count++;
    }

    $image = new \Imagick();
    $image->newImage(350, 350, "blue");
    $image->setImageFormat("png");
    $image->drawImage($draw);
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickPixel::destroy

Deallocates resources associated with this object

说明

public bool ImagickPixel::destroy ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Deallocates any resources used by the ImagickPixel object, and unsets any associated color. The object should not be used after the destroy function has been called.

返回值

成功时返回 true

ImagickPixel::getColor

Returns the color

说明

public array ImagickPixel::getColor ([ <span class="methodparam">int $normalized<span class="initializer"> = 0 ] )

Returns the color described by the ImagickPixel object, as an array. If the color has an opacity channel set, this is provided as a fourth value in the list.

参数

normalized
Normalize the color values. Possible values are 0, 1 or 2.

normalized Description
0 The RGB values are returned as ints in the range 0 to 255 (inclusive.) The alpha value is returned as int and is either 0 or 1.
1 The RGBA values are returned as floats in the range 0 to 1 (inclusive.)
2 The RGBA values are returned as ints in the range 0 to 255 (inclusive.)

返回值

An array of channel values. Throws ImagickPixelException on error.

范例

示例 #1 Basic Imagick::getColor usage

<?php

//Create an ImagickPixel with the predefined color 'brown'
$color = new ImagickPixel('brown');

//Set the color to have an alpha of 25%
$color->setColorValue(Imagick::COLOR_ALPHA, 64 / 256.0);

$colorInfo = $color->getColor();

echo "Standard values".PHP_EOL;
print_r($colorInfo);

$colorInfo = $color->getColor(1);

echo "Normalized values:".PHP_EOL;
print_r($colorInfo);

?>

以上例程会输出:

Standard values
Array
(
    [r] => 165
    [g] => 42
    [b] => 42
    [a] => 0
)
Normalized values:
Array
(
    [r] => 0.64705882352941
    [g] => 0.16470588235294
    [b] => 0.16470588235294
    [a] => 0.25000381475547
)

ImagickPixel::getColorAsString

Returns the color as a string

说明

public string ImagickPixel::getColorAsString ( <span class="methodparam">void )

Returns the color of the ImagickPixel object as a string.

参数

此函数没有参数。

返回值

Returns the color of the ImagickPixel object as a string.

范例

示例 #1 Basic Imagick::getColorAsString usage

<?php

//Create an ImagickPixel with the predefined color 'brown'
$color = new ImagickPixel('brown');

$color->setColorValue(Imagick::COLOR_ALPHA, 64 / 256.0);

$colorInfo = $color->getColorAsString();

print_r($colorInfo);
?>

以上例程会输出:

rgb(165,42,42)

注释

Note: Alpha not returned

This function does not return the alpha value of the color in the string.

ImagickPixel::getColorCount

Returns the color count associated with this color

说明

public int <span class="methodname">ImagickPixel::getColorCount ( <span class="methodparam">void )

Returns the color count associated with this color.

The color count is the number of pixels in the image that have the same color as this ImagickPixel.

ImagickPixel::getColorCount appears to only work for ImagickPixel objects created through Imagick::getImageHistogram()

返回值

Returns the color count as an integer on success, throws ImagickPixelException on failure.

范例

示例 #1 ImagickPixel getColorCount

<?php
    $imagick = new \Imagick();
    $imagick->newPseudoImage(640, 480, "magick:logo");
    $histogramElements = $imagick->getImageHistogram();
    $lastColor = array_pop($histogramElements);
    echo "Last pixel color count is: ".$lastColor->getColorCount();
?>

The output for this will be similar to:

Last pixel color count is: 256244

ImagickPixel::getColorQuantum

Description

说明

public array ImagickPixel::getColorQuantum ( <span class="methodparam">void )

Returns the color of the pixel in an array as Quantum values. If ImageMagick was compiled as HDRI these will be floats, otherwise they will be integers.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Returns an array with keys "r", "g", "b", "a".

ImagickPixel::getColorValue

Gets the normalized value of the provided color channel

说明

public float ImagickPixel::getColorValue ( <span class="methodparam">int $color )

Retrieves the value of the color channel specified, as a floating-point number between 0 and 1.

参数

color
The color to get the value of, specified as one of the Imagick color constants. This can be one of the RGB colors, CMYK colors, alpha and opacity e.g (Imagick::COLOR_BLUE, Imagick::COLOR_MAGENTA).

返回值

The value of the channel, as a normalized floating-point number, throwing ImagickPixelException on error.

范例

示例 #1 Basic Imagick::getColorValue usage

<?php

$color = new ImagickPixel('rgba(90%, 20%, 20%, 0.75)');

echo "Alpha value is ".$color->getColorValue(Imagick::COLOR_ALPHA).PHP_EOL;
echo "".PHP_EOL;
echo "Red value is ".$color->getColorValue(Imagick::COLOR_RED).PHP_EOL;
echo "Green value is ".$color->getColorValue(Imagick::COLOR_GREEN).PHP_EOL;
echo "Blue value is ".$color->getColorValue(Imagick::COLOR_BLUE).PHP_EOL;
echo "".PHP_EOL;
echo "Cyan value is ".$color->getColorValue(Imagick::COLOR_CYAN).PHP_EOL;
echo "Magenta value is ".$color->getColorValue(Imagick::COLOR_MAGENTA).PHP_EOL;
echo "Yellow value is ".$color->getColorValue(Imagick::COLOR_YELLOW).PHP_EOL;
echo "Black value is ".$color->getColorValue(Imagick::COLOR_BLACK).PHP_EOL;

?>

以上例程会输出:

Alpha value is 0.74999618524453

Red value is 0.90000762951095
Green value is 0.2
Blue value is 0.2

Cyan value is 0.90000762951095
Magenta value is 0.2
Yellow value is 0.2
Black value is 0

ImagickPixel::getColorValueQuantum

Description

说明

public <span class="type">intfloat <span class="methodname">ImagickPixel::getColorValueQuantum ( <span class="methodparam">int $color )

Gets the quantum value of a color in the ImagickPixel. Return value is a float if ImageMagick was compiled with HDRI, otherwise an integer.

参数

此函数没有参数。

返回值

The quantum value of the color element. Float if ImageMagick was compiled with HDRI, otherwise an int.

范例

示例 #1 <span class="function">ImagickPixel::getColorValueQuantum

<?php
        $color = new \ImagickPixel('rgb(128, 5, 255)');
        $colorRed = $color->getColorValueQuantum(\Imagick::COLOR_RED);
        $colorGreen = $color->getColorValueQuantum(\Imagick::COLOR_GREEN);
        $colorBlue = $color->getColorValueQuantum(\Imagick::COLOR_BLUE);
        $colorAlpha = $color->getColorValueQuantum(\Imagick::COLOR_ALPHA);

        printf(
            "Red: %s Green: %s  Blue %s Alpha: %s",
            $colorRed,
            $colorGreen,
            $colorBlue,
            $colorAlpha
        );

?>

ImagickPixel::getHSL

Returns the normalized HSL color of the ImagickPixel object

说明

public array ImagickPixel::getHSL ( <span class="methodparam">void )

Returns the normalized HSL color described by the ImagickPixel object, with each of the three values as floating point numbers between 0.0 and 1.0.

返回值

Returns the HSL value in an array with the keys "hue", "saturation", and "luminosity". Throws ImagickPixelException on failure.

范例

示例 #1 Basic Imagick::getHSL example

<?php

$color = new ImagickPixel('rgb(90%, 10%, 10%)');

$colorInfo = $color->getHSL();

print_r($colorInfo);

?>

以上例程会输出:

Array
(
    [hue] => 0
    [saturation] => 0.80001220740379
    [luminosity] => 0.50000762951095
)

注释

Note:

Available with ImageMagick library version 6.2.9 and higher.

ImagickPixel::getIndex

Description

说明

public int <span class="methodname">ImagickPixel::getIndex ( <span class="methodparam">void )

Gets the colormap index of the pixel wand.

参数

此函数没有参数。

返回值

ImagickPixel::isPixelSimilar

Check the distance between this color and another

说明

public bool ImagickPixel::isPixelSimilar ( <span class="methodparam">ImagickPixel $color , <span class="type">float $fuzz )

Checks the distance between the color described by this ImagickPixel object and that of the provided object, by plotting their RGB values on the color cube. If the distance between the two points is less than the fuzz value given, the colors are similar. This method replaces ImagickPixel::isSimilar() and correctly normalises the fuzz value to ImageMagick QuantumRange.

参数

color
The ImagickPixel object to compare this object against.

fuzz
The maximum distance within which to consider these colors as similar. The theoretical maximum for this value is the square root of three (1.732).

返回值

成功时返回 true

ImagickPixel::isPixelSimilarQuantum

Description

说明

public bool ImagickPixel::isPixelSimilarQuantum ( string $color [, <span class="type">string $fuzz ] )

Returns true if the distance between two colors is less than the specified distance. The fuzz value should be in the range 0-QuantumRange. The maximum value represents the longest possible distance in the colorspace. e.g. from RGB(0, 0, 0) to RGB(255, 255, 255) for the RGB colorspace

参数

color

fuzz

返回值

ImagickPixel::isSimilar

Check the distance between this color and another

说明

public bool ImagickPixel::isSimilar ( <span class="methodparam">ImagickPixel $color , <span class="type">float $fuzz )

Warning

本函数还未编写文档,仅有参数列表。

Checks the distance between the color described by this ImagickPixel object and that of the provided object, by plotting their RGB values on the color cube. If the distance between the two points is less than the fuzz value given, the colors are similar. Deprecated in favour of ImagickPixel::isPixelSimilar().

参数

color
The ImagickPixel object to compare this object against.

fuzz
The maximum distance within which to consider these colors as similar. The theoretical maximum for this value is the square root of three (1.732).

返回值

成功时返回 true

范例

示例 #1 ImagickPixel::isSimilar

<?php
        // The tests below are written with the maximum distance expressed as 255
        // so we need to scale them by the square root of 3 - the diagonal length
        // of a unit cube.
        $root3 = 1.732050807568877;

        $tests = array(
            ['rgb(245, 0, 0)',      'rgb(255, 0, 0)',   9 / $root3,         false,],
            ['rgb(245, 0, 0)',      'rgb(255, 0, 0)',  10 / $root3,         true,],
            ['rgb(0, 0, 0)',        'rgb(7, 7, 0)',     9 / $root3,         false,],
            ['rgb(0, 0, 0)',        'rgb(7, 7, 0)',    10 / $root3,         true,],
            ['rgba(0, 0, 0, 1)',    'rgba(7, 7, 0, 1)', 9 / $root3,         false,],
            ['rgba(0, 0, 0, 1)',    'rgba(7, 7, 0, 1)',    10 / $root3,     true,],
            ['rgb(128, 128, 128)',  'rgb(128, 128, 120)',   7 / $root3,     false,],
            ['rgb(128, 128, 128)',  'rgb(128, 128, 120)',   8 / $root3,     true,],
            ['rgb(0, 0, 0)',        'rgb(255, 255, 255)',   254.9,          false,],
            ['rgb(0, 0, 0)',        'rgb(255, 255, 255)',   255,            true,],
            ['rgb(255, 0, 0)',      'rgb(0, 255, 255)',     254.9,          false,],
            ['rgb(255, 0, 0)',      'rgb(0, 255, 255)',     255,            true,],
            ['black',               'rgba(0, 0, 0)',        0.0,            true],
            ['black',               'rgba(10, 0, 0, 1.0)',  10.0 / $root3,  true],);

        $output = "<table width='100%' class='infoTable'><thead>
                <tr>
                <th>
                Color 1
                </th>
                <th>
                Color 2
                </th>
                <th>
                    Test distance * 255
                </th>
                <th>
                    Is within distance
                </th>
                </tr>
        </thead>";

        $output .= "<tbody>";

        foreach ($tests as $testInfo) {
            $color1 = $testInfo[0];
            $color2 = $testInfo[1];
            $distance = $testInfo[2];
            $expectation = $testInfo[3];
            $testDistance = ($distance / 255.0);

            $color1Pixel = new \ImagickPixel($color1);
            $color2Pixel = new \ImagickPixel($color2);

            $isSimilar = $color1Pixel->isPixelSimilar($color2Pixel, $testDistance);


            if ($isSimilar !== $expectation) {
                echo "Test distance failed. Color [$color1] compared to color [$color2] is not within distance $testDistance FAILED.".NL;
            }

            $layout = "<tr>
                <td>%s</td>
                <td>%s</td>
                <td>%s</td>
                <td style='text-align: center;'>%s</td>
            </tr>";

            $output .= sprintf(
                $layout,
                $color1,
                $color2,
                $distance,
                $isSimilar ? 'yes' : 'no'
            );
        }

        $output .= "</tbody></table>";

        return $output;

?>

ImagickPixel::setColor

Sets the color

说明

public bool ImagickPixel::setColor ( <span class="methodparam">string $color )

Warning

本函数还未编写文档,仅有参数列表。

Sets the color described by the ImagickPixel object, with a string (e.g. "blue", "#0000ff", "rgb(0,0,255)", "cmyk(100,100,100,10)", etc.).

参数

color
The color definition to use in order to initialise the ImagickPixel object.

返回值

Returns true if the specified color was set, false otherwise.

范例

示例 #1 ImagickPixel::setColor

<?php
function setColor() {
    $draw = new \ImagickDraw();

    $strokeColor = new \ImagickPixel('green');
    $fillColor = new \ImagickPixel();
    $fillColor->setColor('rgba(100%, 75%, 0%, 1.0)');

    $draw->setstrokewidth(3.0);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);

    $image = new \Imagick();
    $image->newImage(500, 500, "SteelBlue2");
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickPixel::setColorCount

Description

说明

public bool ImagickPixel::setcolorcount ( <span class="methodparam">int $colorCount )

Sets the color count associated with this color.

参数

colorCount

返回值

成功时返回 true

ImagickPixel::setColorValue

Sets the normalized value of one of the channels

说明

public bool ImagickPixel::setColorValue ( <span class="methodparam">int $color , float $value )

Sets the value of the specified channel of this object to the provided value, which should be between 0 and 1. This function can be used to provide an opacity channel to an ImagickPixel object.

参数

color
One of the Imagick color constants e.g. \Imagick::COLOR_GREEN or \Imagick::COLOR_ALPHA.

value
The value to set this channel to, ranging from 0 to 1.

返回值

成功时返回 true

范例

示例 #1 Basic Imagick::setColorValue usage

<?php

$color  = new \ImagickPixel('firebrick');

$color->setColorValue(Imagick::COLOR_ALPHA, 0.5);

print_r($color->getcolor(true));
?>

以上例程会输出:

Array
(
    [r] => 0.69803921568627
    [g] => 0.13333333333333
    [b] => 0.13333333333333
    [a] => 0.50000762951095
)

ImagickPixel::setColorValueQuantum

Description

说明

public bool ImagickPixel::setColorValueQuantum ( int $color , <span class="type">intfloat $value )

Sets the quantum value of a color element of the ImagickPixel.

Warning

本函数还未编写文档,仅有参数列表。

参数

color
Which color element to set e.g. \Imagick::COLOR_GREEN.

value
The quantum value to set the color element to. This should be a float if ImageMagick was compiled with HDRI otherwise an int in the range 0 to Imagick::getQuantum().

返回值

成功时返回 true

范例

示例 #1 <span class="function">ImagickPixel::setColorValueQuantum

<?php
function setColorValueQuantum() {
    $image = new \Imagick();

    $quantumRange = $image->getQuantumRange();

    $draw = new \ImagickDraw();
    $color = new \ImagickPixel('blue');
    $color->setcolorValueQuantum(\Imagick::COLOR_RED, 128 * $quantumRange['quantumRangeLong'] / 256);

    $draw->setstrokewidth(1.0);
    $draw->setStrokeColor($color);
    $draw->setFillColor($color);
    $draw->rectangle(200, 200, 300, 300);

    $image->newImage(500, 500, "SteelBlue2");
    $image->setImageFormat("png");

    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

ImagickPixel::setHSL

Sets the normalized HSL color

说明

public bool ImagickPixel::setHSL ( <span class="methodparam">float $hue , float $saturation , <span class="type">float $luminosity )

Sets the color described by the ImagickPixel object using normalized values for hue, saturation and luminosity.

参数

hue
The normalized value for hue, described as a fractional arc (between 0 and 1) of the hue circle, where the zero value is red.

saturation
The normalized value for saturation, with 1 as full saturation.

luminosity
The normalized value for luminosity, on a scale from black at 0 to white at 1, with the full HS value at 0.5 luminosity.

返回值

成功时返回 true

范例

示例 #1 Use ImagickPixel::setHSL to modify a color

<?php

//Create an almost pure red color
$color = new ImagickPixel('rgb(90%, 10%, 10%)');

//Get it's HSL values
$colorInfo = $color->getHSL();

//Rotate the hue by 180 degrees
$newHue = $colorInfo['hue'] + 0.5;
if ($newHue > 1) {
    $newHue = $newHue - 1;
}

//Set the ImagickPixel to the new color
$colorInfo = $color->setHSL($newHue, $colorInfo['saturation'], $colorInfo['luminosity']);

//Check that the new color is blue/green
$colorInfo = $color->getcolor();
print_r($colorInfo);

?>

以上例程会输出:

Array
(
    [r] => 26
    [g] => 230
    [b] => 230
    [a] => 255
)

注释

Note:

Available with ImageMagick library version 6.2.9 and higher.

ImagickPixel::setIndex

Description

说明

public bool ImagickPixel::setIndex ( <span class="methodparam">int $index )

Sets the colormap index of the pixel wand.

参数

index

返回值

成功时返回 true

类摘要

ImagickPixelIterator

class ImagickPixelIterator {

public bool clear ( <span class="methodparam">void )

public <span class="methodname">__construct ( <span class="methodparam">Imagick $wand )

public bool destroy ( <span class="methodparam">void )

public array getCurrentIteratorRow ( <span class="methodparam">void )

public int <span class="methodname">getIteratorRow ( <span class="methodparam">void )

public array getNextIteratorRow ( <span class="methodparam">void )

public array getPreviousIteratorRow ( <span class="methodparam">void )

public bool newPixelIterator ( <span class="methodparam">Imagick $wand )

public bool newPixelRegionIterator ( <span class="methodparam">Imagick $wand , int $x , int $y , int $columns , <span class="type">int $rows )

public bool resetIterator ( <span class="methodparam">void )

public bool setIteratorFirstRow ( <span class="methodparam">void )

public bool setIteratorLastRow ( <span class="methodparam">void )

public bool setIteratorRow ( <span class="methodparam">int $row )

public bool syncIterator ( <span class="methodparam">void )

}

ImagickPixelIterator::clear

Clear resources associated with a PixelIterator

说明

public bool ImagickPixelIterator::clear ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Clear resources associated with a PixelIterator.

返回值

成功时返回 true

范例

示例 #1 ImagickPixelIterator::clear

<?php
function clear($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));

    $imageIterator = $imagick->getPixelRegionIterator(100, 100, 250, 200);

    /* Loop through pixel rows */
    foreach ($imageIterator as $pixels) { 
        /** @var $pixel \ImagickPixel */
        /* Loop through the pixels in the row (columns) */
        foreach ($pixels as $column => $pixel) { 
            if ($column % 2) {
                /* Paint every second pixel black*/
                $pixel->setColor("rgba(0, 0, 0, 0)"); 
            }
        }
        /* Sync the iterator, this is important to do on each iteration */
        $imageIterator->syncIterator();
    }

    $imageIterator->clear();

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

ImagickPixelIterator::__construct

The ImagickPixelIterator constructor

说明

public <span class="methodname">ImagickPixelIterator::__construct ( <span class="methodparam">Imagick $wand )

Warning

本函数还未编写文档,仅有参数列表。

The ImagickPixelIterator constructor

返回值

成功时返回 true

范例

示例 #1 <span class="function">ImagickPixelIterator::construct

<?php
function construct($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imageIterator = new \ImagickPixelIterator($imagick);

    /* Loop through pixel rows */
    foreach ($imageIterator as $pixels) { 
        /* Loop through the pixels in the row (columns) */
        foreach ($pixels as $column => $pixel) { 
            /** @var $pixel \ImagickPixel */
            if ($column % 2) {
                /* Paint every second pixel black*/
                $pixel->setColor("rgba(0, 0, 0, 0)");
            }
        }
        /* Sync the iterator, this is important to do on each iteration */
        $imageIterator->syncIterator();
    }

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

ImagickPixelIterator::destroy

Deallocates resources associated with a PixelIterator

说明

public bool ImagickPixelIterator::destroy ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Deallocates resources associated with a PixelIterator.

返回值

成功时返回 true

ImagickPixelIterator::getCurrentIteratorRow

Returns the current row of ImagickPixel objects

说明

public array <span class="methodname">ImagickPixelIterator::getCurrentIteratorRow ( void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the current row as an array of ImagickPixel objects from the pixel iterator.

返回值

Returns a row as an array of ImagickPixel objects that can themselves be iterated.

ImagickPixelIterator::getIteratorRow

Returns the current pixel iterator row

说明

public int <span class="methodname">ImagickPixelIterator::getIteratorRow ( <span class="methodparam">void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the current pixel iterator row.

返回值

Returns the integer offset of the row, throwing ImagickPixelIteratorException on error.

ImagickPixelIterator::getNextIteratorRow

Returns the next row of the pixel iterator

说明

public array ImagickPixelIterator::getNextIteratorRow ( void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the next row as an array of pixel wands from the pixel iterator.

返回值

Returns the next row as an array of ImagickPixel objects, throwing ImagickPixelIteratorException on error.

范例

示例 #1 <span class="function">ImagickPixelIterator::getNextIteratorRow

<?php
function getNextIteratorRow($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imageIterator = $imagick->getPixelIterator();

    $count = 0;
    while ($pixels = $imageIterator->getNextIteratorRow()) {
        if (($count % 3) == 0) {
            /* Loop through the pixels in the row (columns) */
            foreach ($pixels as $column => $pixel) { 
                /** @var $pixel \ImagickPixel */
                if ($column % 2) {
                    /* Paint every second pixel black*/
                    $pixel->setColor("rgba(0, 0, 0, 0)");
                }
            }
            /* Sync the iterator, this is important to do on each iteration */
            $imageIterator->syncIterator(); 
        }

        $count += 1;
    }

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

ImagickPixelIterator::getPreviousIteratorRow

Returns the previous row

说明

public array <span class="methodname">ImagickPixelIterator::getPreviousIteratorRow ( void )

Warning

本函数还未编写文档,仅有参数列表。

Returns the previous row as an array of pixel wands from the pixel iterator.

返回值

Returns the previous row as an array of ImagickPixelWand objects from the ImagickPixelIterator, throwing ImagickPixelIteratorException on error.

ImagickPixelIterator::newPixelIterator

Returns a new pixel iterator

说明

public bool ImagickPixelIterator::newPixelIterator ( Imagick $wand )

Warning

本函数还未编写文档,仅有参数列表。

Returns a new pixel iterator.

返回值

成功时返回 true。 Throwing ImagickPixelIteratorException.

ImagickPixelIterator::newPixelRegionIterator

Returns a new pixel iterator

说明

public bool <span class="methodname">ImagickPixelIterator::newPixelRegionIterator ( Imagick $wand , int $x , int $y , int $columns , <span class="type">int $rows )

Warning

本函数还未编写文档,仅有参数列表。

Returns a new pixel iterator.

参数

wand

x

y

columns

rows

返回值

Returns a new ImagickPixelIterator on success; on failure, throws ImagickPixelIteratorException.

ImagickPixelIterator::resetIterator

Resets the pixel iterator

说明

public bool ImagickPixelIterator::resetIterator ( void )

Warning

本函数还未编写文档,仅有参数列表。

Resets the pixel iterator. Use it in conjunction with ImagickPixelIterator::getNextIteratorRow() to iterate over all the pixels in a pixel container.

返回值

成功时返回 true

范例

示例 #1 <span class="function">ImagickPixelIterator::resetIterator

<?php
function resetIterator($imagePath) {

    $imagick = new \Imagick(realpath($imagePath));

    $imageIterator = $imagick->getPixelIterator();

    /* Loop trough pixel rows */
    foreach ($imageIterator as $pixels) {
        /* Loop through the pixels in the row (columns) */
        foreach ($pixels as $column => $pixel) {
            /** @var $pixel \ImagickPixel */
            if ($column % 2) {

                /* Make every second pixel 25% red*/
                $pixel->setColorValue(\Imagick::COLOR_RED, 64); 
            }
        }
        /* Sync the iterator, this is important to do on each iteration */
        $imageIterator->syncIterator();
    }

    $imageIterator->resetiterator();

    /* Loop trough pixel rows */
    foreach ($imageIterator as $pixels) {
        /* Loop through the pixels in the row (columns) */
        foreach ($pixels as $column => $pixel) {
            /** @var $pixel \ImagickPixel */
            if ($column % 3) {
                $pixel->setColorValue(\Imagick::COLOR_BLUE, 64); /* Make every second pixel a little blue*/
                //$pixel->setColor("rgba(0, 0, 128, 0)"); /* Paint every second pixel black*/
            }
        }
        $imageIterator->syncIterator(); /* Sync the iterator, this is important to do on each iteration */
    }

    $imageIterator->clear();

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

ImagickPixelIterator::setIteratorFirstRow

Sets the pixel iterator to the first pixel row

说明

public bool <span class="methodname">ImagickPixelIterator::setIteratorFirstRow ( void )

Warning

本函数还未编写文档,仅有参数列表。

Sets the pixel iterator to the first pixel row.

返回值

成功时返回 true

ImagickPixelIterator::setIteratorLastRow

Sets the pixel iterator to the last pixel row

说明

public bool ImagickPixelIterator::setIteratorLastRow ( void )

Warning

本函数还未编写文档,仅有参数列表。

Sets the pixel iterator to the last pixel row.

返回值

成功时返回 true

ImagickPixelIterator::setIteratorRow

Set the pixel iterator row

说明

public bool ImagickPixelIterator::setIteratorRow ( int $row )

Warning

本函数还未编写文档,仅有参数列表。

Set the pixel iterator row.

参数

row

返回值

成功时返回 true

范例

示例 #1 <span class="function">ImagickPixelIterator::setIteratorRow

<?php
function setIteratorRow($imagePath) {
    $imagick = new \Imagick(realpath($imagePath));
    $imageIterator = $imagick->getPixelRegionIterator(200, 100, 200, 200);

    for ($x = 0; $x < 20; $x++) {        
        $imageIterator->setIteratorRow($x * 5);
        $pixels = $imageIterator->getCurrentIteratorRow();
        /* Loop through the pixels in the row (columns) */
        foreach ($pixels as $pixel) {
            /** @var $pixel \ImagickPixel */
            /* Paint every second pixel black*/
            $pixel->setColor("rgba(0, 0, 0, 0)"); 
        }

        /* Sync the iterator, this is important to do on each iteration */
        $imageIterator->syncIterator();
    }

    header("Content-Type: image/jpg");
    echo $imagick;
}

?>

ImagickPixelIterator::syncIterator

Syncs the pixel iterator

说明

public bool ImagickPixelIterator::syncIterator ( void )

Warning

本函数还未编写文档,仅有参数列表。

Syncs the pixel iterator.

返回值

成功时返回 true


本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除