图像处理(ImageMagick)

目录

类摘要

Imagick

class Imagick implements Iterator {

bool adaptiveBlurImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool adaptiveResizeImage ( int $columns , int $rows [, bool $bestfit = FALSE [, bool $legacy = FALSE ]] )

bool adaptiveSharpenImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool adaptiveThresholdImage ( int $width , int $height , int $offset )

bool addImage ( Imagick $source )

bool addNoiseImage ( int $noise_type [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool affineTransformImage ( ImagickDraw $matrix )

bool animateImages ( string $x_server )

bool annotateImage ( ImagickDraw $draw_settings , float $x , float $y , float $angle , string $text )

Imagick appendImages ( bool $stack )

public bool autoLevelImage ([ int $channel = Imagick::CHANNEL_DEFAULT ] )

Imagick averageImages ( void )

bool blackThresholdImage ( mixed $threshold )

public bool blueShiftImage ([ float $factor = 1.5 ] )

bool blurImage ( float $radius , float $sigma [, int $channel ] )

bool borderImage ( mixed $bordercolor , int $width , int $height )

public bool brightnessContrastImage ( float $brightness , float $contrast [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool charcoalImage ( float $radius , float $sigma )

bool chopImage ( int $width , int $height , int $x , int $y )

public bool clampImage ([ int $channel = Imagick::CHANNEL_DEFAULT ] )

bool clear ( void )

bool clipImage ( void )

public void clipImagePath ( string $pathname , string $inside )

bool clipPathImage ( string $pathname , bool $inside )

Imagick clone ( void )

bool clutImage ( Imagick $lookup_table [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Imagick coalesceImages ( void )

bool colorFloodfillImage ( mixed $fill , float $fuzz , mixed $bordercolor , int $x , int $y )

bool colorizeImage ( mixed $colorize , mixed $opacity [, bool $legacy = FALSE ] )

public bool colorMatrixImage ( array $color_matrix = Imagick::CHANNEL_DEFAULT )

Imagick combineImages ( int $channelType )

bool commentImage ( string $comment )

array compareImageChannels ( Imagick $image , int $channelType , int $metricType )

Imagick compareImageLayers ( int $method )

array compareImages ( Imagick $compare , int $metric )

bool compositeImage ( Imagick $composite_object , int $composite , int $x , int $y [, int $channel = Imagick::CHANNEL_ALL ] )

__construct ([ mixed $files ] )

bool contrastImage ( bool $sharpen )

bool contrastStretchImage ( float $black_point , float $white_point [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool convolveImage ( array $kernel [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public int count ([ int $mode = 0 ] )

bool cropImage ( int $width , int $height , int $x , int $y )

bool cropThumbnailImage ( int $width , int $height )

Imagick current ( void )

bool cycleColormapImage ( int $displace )

bool decipherImage ( string $passphrase )

Imagick deconstructImages ( void )

bool deleteImageArtifact ( string $artifact )

public bool deleteImageProperty ( string $name )

public bool deskewImage ( float $threshold )

bool despeckleImage ( void )

bool destroy ( void )

bool displayImage ( string $servername )

bool displayImages ( string $servername )

bool distortImage ( int $method , array $arguments , bool $bestfit )

bool drawImage ( ImagickDraw $draw )

bool edgeImage ( float $radius )

bool embossImage ( float $radius , float $sigma )

bool encipherImage ( string $passphrase )

bool enhanceImage ( void )

bool equalizeImage ( void )

bool evaluateImage ( int $op , float $constant [, int $channel = Imagick::CHANNEL_DEFAULT ] )

public array exportImagePixels ( int $x , int $y , int $width , int $height , string $map , int $STORAGE )

bool extentImage ( int $width , int $height , int $x , int $y )

public bool filter ( ImagickKernel $ImagickKernel [, int $channel = Imagick::CHANNEL_UNDEFINED ] )

Imagick flattenImages ( void )

bool flipImage ( void )

bool floodFillPaintImage ( mixed $fill , float $fuzz , mixed $target , int $x , int $y , bool $invert [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool flopImage ( void )

public bool forwardFourierTransformimage ( bool $magnitude )

bool frameImage ( mixed $matte_color , int $width , int $height , int $inner_bevel , int $outer_bevel )

public bool functionImage ( int $function , array $arguments [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Imagick fxImage ( string $expression [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool gammaImage ( float $gamma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool gaussianBlurImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

int getColorspace ( void )

int getCompression ( void )

int getCompressionQuality ( void )

string getCopyright ( void )

string getFilename ( void )

string getFont ( void )

string getFormat ( void )

int getGravity ( void )

string getHomeURL ( void )

Imagick getImage ( void )

int getImageAlphaChannel ( void )

string getImageArtifact ( string $artifact )

public string getImageAttribute ( string $key )

ImagickPixel getImageBackgroundColor ( void )

string getImageBlob ( void )

array getImageBluePrimary ( void )

ImagickPixel getImageBorderColor ( void )

int getImageChannelDepth ( int $channel )

float getImageChannelDistortion ( Imagick $reference , int $channel , int $metric )

float getImageChannelDistortions ( Imagick $reference , int $metric [, int $channel = Imagick::CHANNEL_DEFAULT ] )

array getImageChannelExtrema ( int $channel )

public array getImageChannelKurtosis ([ int $channel = Imagick::CHANNEL_DEFAULT ] )

array getImageChannelMean ( int $channel )

array getImageChannelRange ( int $channel )

array getImageChannelStatistics ( void )

Imagick getImageClipMask ( void )

ImagickPixel getImageColormapColor ( int $index )

int getImageColors ( void )

int getImageColorspace ( void )

int getImageCompose ( void )

int getImageCompression ( void )

int getImageCompressionQuality ( void )

int getImageDelay ( void )

int getImageDepth ( void )

int getImageDispose ( void )

float getImageDistortion ( MagickWand $reference , int $metric )

array getImageExtrema ( void )

string getImageFilename ( void )

string getImageFormat ( void )

float getImageGamma ( void )

array getImageGeometry ( void )

int getImageGravity ( void )

array getImageGreenPrimary ( void )

int getImageHeight ( void )

array getImageHistogram ( void )

int getImageIndex ( void )

int getImageInterlaceScheme ( void )

int getImageInterpolateMethod ( void )

int getImageIterations ( void )

int getImageLength ( void )

string getImageMagickLicense ( void )

bool getImageMatte ( void )

ImagickPixel getImageMatteColor ( void )

public string getImageMimeType ( void )

int getImageOrientation ( void )

array getImagePage ( void )

ImagickPixel getImagePixelColor ( int $x , int $y )

string getImageProfile ( string $name )

array getImageProfiles ([ string $pattern = "*" [, bool $include_values = TRUE ]] )

array getImageProperties ([ string $pattern = "*" [, bool $include_values = TRUE ]] )

string getImageProperty ( string $name )

array getImageRedPrimary ( void )

Imagick getImageRegion ( int $width , int $height , int $x , int $y )

int getImageRenderingIntent ( void )

array getImageResolution ( void )

string getImagesBlob ( void )

int getImageScene ( void )

string getImageSignature ( void )

int getImageSize ( void )

int getImageTicksPerSecond ( void )

float getImageTotalInkDensity ( void )

int getImageType ( void )

int getImageUnits ( void )

int getImageVirtualPixelMethod ( void )

array getImageWhitePoint ( void )

int getImageWidth ( void )

int getInterlaceScheme ( void )

int getIteratorIndex ( void )

int getNumberImages ( void )

string getOption ( string $key )

string getPackageName ( void )

array getPage ( void )

ImagickPixelIterator getPixelIterator ( void )

ImagickPixelIterator getPixelRegionIterator ( int $x , int $y , int $columns , int $rows )

float getPointSize ( void )

public static int getQuantum ( void )

array getQuantumDepth ( void )

array getQuantumRange ( void )

public static string getRegistry ( string $key )

string getReleaseDate ( void )

int getResource ( int $type )

int getResourceLimit ( int $type )

array getSamplingFactors ( void )

array getSize ( void )

int getSizeOffset ( void )

array getVersion ( void )

public bool haldClutImage ( Imagick $clut [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool hasNextImage ( void )

bool hasPreviousImage ( void )

public string identifyFormat ( string $embedText )

array identifyImage ([ bool $appendRawOutput = FALSE ] )

bool implodeImage ( float $radius )

public bool importImagePixels ( int $x , int $y , int $width , int $height , string $map , int $storage , array $pixels )

public bool inverseFourierTransformImage ( Imagick $complement , bool $magnitude )

bool labelImage ( string $label )

bool levelImage ( float $blackPoint , float $gamma , float $whitePoint [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool linearStretchImage ( float $blackPoint , float $whitePoint )

bool liquidRescaleImage ( int $width , int $height , float $delta_x , float $rigidity )

public static array listRegistry ( void )

bool magnifyImage ( void )

bool mapImage ( Imagick $map , bool $dither )

bool matteFloodfillImage ( float $alpha , float $fuzz , mixed $bordercolor , int $x , int $y )

bool medianFilterImage ( float $radius )

Imagick mergeImageLayers ( int $layer_method )

bool minifyImage ( void )

bool modulateImage ( float $brightness , float $saturation , float $hue )

Imagick montageImage ( ImagickDraw $draw , string $tile_geometry , string $thumbnail_geometry , int $mode , string $frame )

Imagick morphImages ( int $number_frames )

public bool morphology ( int $morphologyMethod , int $iterations , ImagickKernel $ImagickKernel [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Imagick mosaicImages ( void )

bool motionBlurImage ( float $radius , float $sigma , float $angle [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool negateImage ( bool $gray [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool newImage ( int $cols , int $rows , mixed $background [, string $format ] )

bool newPseudoImage ( int $columns , int $rows , string $pseudoString )

bool nextImage ( void )

bool normalizeImage ([ int $channel = Imagick::CHANNEL_DEFAULT ] )

bool oilPaintImage ( float $radius )

bool opaquePaintImage ( mixed $target , mixed $fill , float $fuzz , bool $invert [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool optimizeImageLayers ( void )

bool orderedPosterizeImage ( string $threshold_map [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool paintFloodfillImage ( mixed $fill , float $fuzz , mixed $bordercolor , int $x , int $y [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool paintOpaqueImage ( mixed $target , mixed $fill , float $fuzz [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool paintTransparentImage ( mixed $target , float $alpha , float $fuzz )

bool pingImage ( string $filename )

bool pingImageBlob ( string $image )

bool pingImageFile ( resource $filehandle [, string $fileName ] )

bool polaroidImage ( ImagickDraw $properties , float $angle )

bool posterizeImage ( int $levels , bool $dither )

bool previewImages ( int $preview )

bool previousImage ( void )

bool profileImage ( string $name , string $profile )

bool quantizeImage ( int $numberColors , int $colorspace , int $treedepth , bool $dither , bool $measureError )

bool quantizeImages ( int $numberColors , int $colorspace , int $treedepth , bool $dither , bool $measureError )

array queryFontMetrics ( ImagickDraw $properties , string $text [, bool $multiline ] )

array queryFonts ([ string $pattern = "*" ] )

array queryFormats ([ string $pattern = "*" ] )

bool radialBlurImage ( float $angle [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool raiseImage ( int $width , int $height , int $x , int $y , bool $raise )

bool randomThresholdImage ( float $low , float $high [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool readImage ( string $filename )

bool readImageBlob ( string $image [, string $filename ] )

bool readImageFile ( resource $filehandle [, string $fileName = NULL ] )

public bool readImages ( array $filenames )

bool recolorImage ( array $matrix )

bool reduceNoiseImage ( float $radius )

public bool remapImage ( Imagick $replacement , int $DITHER )

bool removeImage ( void )

string removeImageProfile ( string $name )

bool render ( void )

bool resampleImage ( float $x_resolution , float $y_resolution , int $filter , float $blur )

bool resetImagePage ( string $page )

bool resizeImage ( int $columns , int $rows , int $filter , float $blur [, bool $bestfit = FALSE [, bool $legacy = FALSE ]] )

bool rollImage ( int $x , int $y )

bool rotateImage ( mixed $background , float $degrees )

public bool rotationalBlurImage ( float $angle [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool roundCorners ( float $x_rounding , float $y_rounding [, float $stroke_width = 10 [, float $displace = 5 [, float $size_correction = -6 ]]] )

bool sampleImage ( int $columns , int $rows )

bool scaleImage ( int $cols , int $rows [, bool $bestfit = FALSE [, bool $legacy = FALSE ]] )

public bool segmentImage ( int $COLORSPACE , float $cluster_threshold , float $smooth_threshold [, bool $verbose = FALSE ] )

public bool selectiveBlurImage ( float $radius , float $sigma , float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool separateImageChannel ( int $channel )

bool sepiaToneImage ( float $threshold )

bool setBackgroundColor ( mixed $background )

bool setColorspace ( int $COLORSPACE )

bool setCompression ( int $compression )

bool setCompressionQuality ( int $quality )

bool setFilename ( string $filename )

bool setFirstIterator ( void )

bool setFont ( string $font )

bool setFormat ( string $format )

bool setGravity ( int $gravity )

bool setImage ( Imagick $replace )

bool setImageAlphaChannel ( int $mode )

bool setImageArtifact ( string $artifact , string $value )

public bool setImageAttribute ( string $key , string $value )

bool setImageBackgroundColor ( mixed $background )

bool setImageBias ( float $bias )

public void setImageBiasQuantum ( string $bias )

bool setImageBluePrimary ( float $x , float $y )

bool setImageBorderColor ( mixed $border )

bool setImageChannelDepth ( int $channel , int $depth )

bool setImageClipMask ( Imagick $clip_mask )

bool setImageColormapColor ( int $index , ImagickPixel $color )

bool setImageColorspace ( int $colorspace )

bool setImageCompose ( int $compose )

bool setImageCompression ( int $compression )

bool setImageCompressionQuality ( int $quality )

bool setImageDelay ( int $delay )

bool setImageDepth ( int $depth )

bool setImageDispose ( int $dispose )

bool setImageExtent ( int $columns , int $rows )

bool setImageFilename ( string $filename )

bool setImageFormat ( string $format )

bool setImageGamma ( float $gamma )

bool setImageGravity ( int $gravity )

bool setImageGreenPrimary ( float $x , float $y )

bool setImageIndex ( int $index )

bool setImageInterlaceScheme ( int $interlace_scheme )

bool setImageInterpolateMethod ( int $method )

bool setImageIterations ( int $iterations )

bool setImageMatte ( bool $matte )

bool setImageMatteColor ( mixed $matte )

bool setImageOpacity ( float $opacity )

bool setImageOrientation ( int $orientation )

bool setImagePage ( int $width , int $height , int $x , int $y )

bool setImageProfile ( string $name , string $profile )

bool setImageProperty ( string $name , string $value )

bool setImageRedPrimary ( float $x , float $y )

bool setImageRenderingIntent ( int $rendering_intent )

bool setImageResolution ( float $x_resolution , float $y_resolution )

bool setImageScene ( int $scene )

bool setImageTicksPerSecond ( int $ticks_per_second )

bool setImageType ( int $image_type )

bool setImageUnits ( int $units )

bool setImageVirtualPixelMethod ( int $method )

bool setImageWhitePoint ( float $x , float $y )

bool setInterlaceScheme ( int $interlace_scheme )

bool setIteratorIndex ( int $index )

bool setLastIterator ( void )

bool setOption ( string $key , string $value )

bool setPage ( int $width , int $height , int $x , int $y )

bool setPointSize ( float $point_size )

public bool setProgressMonitor ( callable $callback )

public static bool setRegistry ( string $key , string $value )

bool setResolution ( float $x_resolution , float $y_resolution )

bool setResourceLimit ( int $type , int $limit )

bool setSamplingFactors ( array $factors )

bool setSize ( int $columns , int $rows )

bool setSizeOffset ( int $columns , int $rows , int $offset )

bool setType ( int $image_type )

bool shadeImage ( bool $gray , float $azimuth , float $elevation )

bool shadowImage ( float $opacity , float $sigma , int $x , int $y )

bool sharpenImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool shaveImage ( int $columns , int $rows )

bool shearImage ( mixed $background , float $x_shear , float $y_shear )

bool sigmoidalContrastImage ( bool $sharpen , float $alpha , float $beta [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool sketchImage ( float $radius , float $sigma , float $angle )

public Imagick smushImages ( bool $stack , int $offset )

bool solarizeImage ( int $threshold )

public bool sparseColorImage ( int $SPARSE_METHOD , array $arguments [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool spliceImage ( int $width , int $height , int $x , int $y )

bool spreadImage ( float $radius )

public bool statisticImage ( int $type , int $width , int $height [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Imagick steganoImage ( Imagick $watermark_wand , int $offset )

bool stereoImage ( Imagick $offset_wand )

bool stripImage ( void )

public Imagick subImageMatch ( Imagick $Imagick [, array &$offset [, float &$similarity ]] )

bool swirlImage ( float $degrees )

Imagick textureImage ( Imagick $texture_wand )

bool thresholdImage ( float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool thumbnailImage ( int $columns , int $rows [, bool $bestfit = FALSE [, bool $fill = FALSE [, bool $legacy = FALSE ]]] )

bool tintImage ( mixed $tint , mixed $opacity [, bool $legacy = FALSE ] )

string __toString ( void )

Imagick transformImage ( string $crop , string $geometry )

bool transformImageColorspace ( int $colorspace )

bool transparentPaintImage ( mixed $target , float $alpha , float $fuzz , bool $invert )

bool transposeImage ( void )

bool transverseImage ( void )

bool trimImage ( float $fuzz )

bool uniqueImageColors ( void )

bool unsharpMaskImage ( float $radius , float $sigma , float $amount , float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] )

bool valid ( void )

bool vignetteImage ( float $blackPoint , float $whitePoint , int $x , int $y )

bool waveImage ( float $amplitude , float $length )

bool whiteThresholdImage ( mixed $threshold )

bool writeImage ([ string $filename = NULL ] )

bool writeImageFile ( resource $filehandle [, string $format ] )

bool writeImages ( string $filename , bool $adjoin )

bool writeImagesFile ( resource $filehandle [, 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 effectsGet methodsSet methodsRead/write imagesOther
Imagick::adaptiveBlurImageImagick::getCompressionImagick::setBackgroundColorImagick::__constructImagick::clear
Imagick::adaptiveResizeImageImagick::getFilenameImagick::setCompressionQualityImagick::addImageImagick::clone
Imagick::adaptiveSharpenImageImagick::getFormatImagick::setCompressionImagick::appendImagesImagick::current
Imagick::adaptiveThresholdImageImagick::getImageBackgroundColorImagick::setFilenameImagick::getFilenameImagick::destroy
Imagick::addNoiseImageImagick::getImageBlobImagick::getImagesBlobImagick::setFormatImagick::getFormat
Imagick::affinetransformimageImagick::getImageBluePrimaryImagick::setImageBackgroundColorImagick::getImageFilenameImagick::getHomeURL
Imagick::annotateImageImagick::getImageBorderColorImagick::setFirstIteratorImagick::getImageFormatImagick::commentImage
Imagick::averageImagesImagick::getImageChannelDepthImagick::setImageBiasImagick::getImageImagick::getNumberImages
Imagick::blackThresholdImageImagick::getImageChannelDistortionImagick::setImageBluePrimaryImagick::setImageFilenameImagick::getReleaseDate
Imagick::blurImageImagick::getImageChannelExtremaImagick::setImageBorderColorImagick::setImageFormatImagick::getVersion
Imagick::borderImageImagick::getImageChannelMeanImagick::setImageChannelDepthImagick::readImageFileImagick::hasNextImage
Imagick::charcoalImageImagick::getImageChannelStatisticsImagick::setImageColormapColorImagick::readImageImagick::hasPreviousImage
Imagick::chopImageImagick::getImageColormapColorImagick::setImageColorSpaceImagick::writeImagesImagick::labelImage
Imagick::clipImageImagick::getImageColorspaceImagick::setImageComposeImagick::writeImageImagick::newImage
Imagick::clipPathImageImagick::getImageColorsImagick::setImageCompression Imagick::newPseudoImage
Imagick::coalesceImagesImagick::getImageComposeImagick::setImageDelay Imagick::nextImage
Imagick::colorFloodFillImageImagick::getImageDelayImagick::setImageDepth Imagick::pingImageBlob
Imagick::colorizeImageImagick::getImageDepthImagick::setImageDispose Imagick::pingImageFile
Imagick::combineImagesImagick::getImageDisposeImagick::setImageDispose Imagick::pingImage
Imagick::compareImageChannelsImagick::getImageDistortionImagick::setImageExtent Imagick::previousImage
Imagick::compareImageLayersImagick::getImageExtremaImagick::setImageFilename Imagick::profileImage
Imagick::compositeImageImagick::getImageFilenameImagick::setImageFormat Imagick::queryFormats
Imagick::contrastImageImagick::getImageFormatImagick::setImageGamma Imagick::removeImageProfile
Imagick::contrastStretchImageImagick::getImageGammaImagick::setImageGreenPrimary Imagick::removeImage
Imagick::convolveImageImagick::getImageGeometryImagick::setImageIndex Imagick::setFirstIterator
Imagick::cropImageImagick::getImageGreenPrimaryImagick::setImageInterpolateMethod Imagick::setImageIndex
Imagick::cycleColormapImageImagick::getImageHeightImagick::setImageIterations Imagick::valid
Imagick::deconstructImagesImagick::getImageHistogramImagick::setImageMatteColor Imagick::getCopyright
Imagick::drawImageImagick::getImageIndexImagick::setImageMatte  
Imagick::edgeImageImagick::getImageInterlaceSchemeImagick::setImagePage  
Imagick::embossImageImagick::getImageInterpolateMethodImagick::setImageProfile  
Imagick::enhanceImageImagick::getImageIterationsImagick::setImageProperty  
Imagick::equalizeImageImagick::getImageMatteColorImagick::setImageRedPrimary  
Imagick::evaluateImageImagick::getImageMatteImagick::setImageRenderingIntent  
Imagick::flattenImagesImagick::getImagePageImagick::setImageResolution  
Imagick::flipImageImagick::getImagePixelColorImagick::setImageScene  
Imagick::flopImageImagick::getImageProfileImagick::setImageTicksPerSecond  
 Imagick::getImagePropertyImagick::setImageType  
Imagick::fxImageImagick::getImageRedPrimaryImagick::setImageUnits  
Imagick::gammaImageImagick::getImageRegionImagick::setImageVirtualPixelMethod  
Imagick::gaussianBlurImageImagick::getImageRenderingIntentImagick::setImageWhitepoint  
Imagick::implodeImageImagick::getImageResolutionImagick::setInterlaceScheme  
Imagick::levelImageImagick::getImageSceneImagick::setOption  
Imagick::linearStretchImageImagick::getImageSignatureImagick::setPage  
Imagick::magnifyImageImagick::getImageTicksPerSecondImagick::setResolution  
Imagick::matteFloodFillImageImagick::getImageTotalInkDensityImagick::setResourceLimit  
Imagick::medianFilterImageImagick::getImageTypeImagick::setSamplingFactors  
Imagick::minifyImageImagick::getImageUnitsImagick::setSizeOffset  
Imagick::modulateImageImagick::getImageVirtualPixelMethodImagick::setSize  
Imagick::montageImageImagick::getImageWhitepointImagick::setType  
Imagick::morphImagesImagick::getImageWidth   
Imagick::mosaicImagesImagick::getImage   
Imagick::motionBlurImageImagick::getInterlaceScheme   
Imagick::negateImageImagick::getNumberImages   
Imagick::normalizeImageImagick::getOption   
Imagick::oilPaintImageImagick::getPackageName   
Imagick::optimizeImageLayersImagick::getPage   
Imagick::paintOpaqueImageImagick::getPixelIterator   
Imagick::paintTransparentImageImagick::getPixelRegionIterator   
Imagick::posterizeImageImagick::getQuantumDepth   
Imagick::radialBlurImageImagick::getQuantumRange   
Imagick::raiseImageImagick::getResourceLimit   
Imagick::randomThresholdImageImagick::getResource   
Imagick::reduceNoiseImageImagick::getSamplingFactors   
Imagick::renderImagick::getSizeOffset   
Imagick::resampleImageImagick::getSize   
Imagick::resizeImageImagick::identifyImage   
Imagick::rollImageImagick::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

说明

bool Imagick::adaptiveBlurImage ( float $radius , float $sigma [, 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 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

说明

bool Imagick::adaptiveResizeImage ( int $columns , int $rows [, bool $bestfit = FALSE [, bool $legacy = 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。

更新日志

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

范例

示例 #1 Using 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

说明

bool Imagick::adaptiveSharpenImage ( float $radius , float $sigma [, 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

说明

bool Imagick::adaptiveThresholdImage ( 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 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

说明

bool Imagick::addImage ( 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

说明

bool Imagick::addNoiseImage ( 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

说明

bool Imagick::affineTransformImage ( 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 = 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

说明

bool Imagick::animateImages ( 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

说明

bool Imagick::annotateImage ( ImagickDraw $draw_settings , float $x , float $y , float $angle , 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

说明

Imagick Imagick::appendImages ( 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 ([ int $channel = 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

说明

Imagick Imagick::averageImages ( void )

Average a set of images.

返回值

Returns a new Imagick object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::blackThresholdImage

Forces all pixels below the threshold into black

说明

bool Imagick::blackThresholdImage ( 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

更新日志

版本说明
2.1.0Now 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 ([ float $factor = 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

说明

bool Imagick::blurImage ( float $radius , float $sigma [, 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

说明

bool Imagick::borderImage ( mixed $bordercolor , int $width , 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

更新日志

版本说明
2.1.0Now 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 ( float $brightness , float $contrast [, 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 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

说明

bool Imagick::charcoalImage ( 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

说明

bool Imagick::chopImage ( 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 ([ int $channel = 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

说明

bool Imagick::clear ( void )

Clears all resources associated to Imagick object

返回值

成功时返回 TRUE

Imagick::clipImage

Clips along the first path from the 8BIM profile

说明

bool Imagick::clipImage ( void )

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

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::clipImagePath

Description

说明

public void Imagick::clipImagePath ( 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

说明

bool Imagick::clipPathImage ( 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

说明

Imagick Imagick::clone ( 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.

更新日志

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

Imagick::clutImage

Replaces colors in the image

说明

bool Imagick::clutImage ( Imagick $lookup_table [, 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

说明

Imagick Imagick::coalesceImages ( 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

说明

bool Imagick::colorFloodfillImage ( mixed $fill , float $fuzz , mixed $bordercolor , int $x , 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。

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::colorizeImage ( mixed $colorize , mixed $opacity [, 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。

更新日志

版本说明
2.1.0Now 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 ( array $color_matrix = 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

说明

Imagick Imagick::combineImages ( 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

说明

bool Imagick::commentImage ( 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

说明

array Imagick::compareImageChannels ( Imagick $image , int $channelType , 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

说明

Imagick Imagick::compareImageLayers ( 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 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

说明

array Imagick::compareImages ( 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 Imagick::compositeImage ( Imagick $composite_object , int $composite , int $x , int $y [, int $channel = 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

说明

Imagick::__construct ([ 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

说明

bool Imagick::contrastImage ( 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

说明

bool Imagick::contrastStretchImage ( float $black_point , float $white_point [, int $channel = 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

说明

bool Imagick::convolveImage ( array $kernel [, int $channel = 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 Imagick::count ([ int $mode = 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 Imagick::cropImage ( 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 Imagick::cropThumbnailImage ( int $width , int $height )

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

参数

width
缩略图的宽

height
缩略图的高

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::current

Returns a reference to the current Imagick object

说明

Imagick Imagick::current ( 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

说明

bool Imagick::cycleColormapImage ( 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

说明

bool Imagick::decipherImage ( 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

说明

Imagick Imagick::deconstructImages ( 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

说明

bool Imagick::deleteImageArtifact ( 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 ( 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 ( 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

说明

bool Imagick::despeckleImage ( 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

说明

bool Imagick::destroy ( 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

说明

bool Imagick::displayImage ( 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

说明

bool Imagick::displayImages ( 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

说明

bool Imagick::distortImage ( int $method , array $arguments , 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 Imagick::drawImage ( ImagickDraw $draw )

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

参数

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

返回值

成功时返回 TRUE

Imagick::edgeImage

Enhance edges within the image

说明

bool Imagick::edgeImage ( 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

说明

bool Imagick::embossImage ( 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

说明

bool Imagick::encipherImage ( string $passphrase )

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

参数

passphrase
The passphrase

返回值

成功时返回 TRUE

参见

  • Imagick::decipherImage

Imagick::enhanceImage

Improves the quality of a noisy image

说明

bool Imagick::enhanceImage ( 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

说明

bool Imagick::equalizeImage ( 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

说明

bool Imagick::evaluateImage ( int $op , 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 ( int $x , int $y , 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 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

说明

bool Imagick::extentImage ( 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

说明

public bool Imagick::filter ( ImagickKernel $ImagickKernel [, 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

说明

Imagick Imagick::flattenImages ( 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

说明

bool Imagick::flipImage ( 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

说明

bool Imagick::floodFillPaintImage ( mixed $fill , float $fuzz , mixed $target , int $x , int $y , bool $invert [, int $channel = 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 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

说明

bool Imagick::flopImage ( 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 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

说明

bool Imagick::frameImage ( mixed $matte_color , int $width , int $height , int $inner_bevel , 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。

更新日志

版本说明
2.1.0Now 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 ( int $function , array $arguments [, 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

说明

Imagick Imagick::fxImage ( string $expression [, 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

说明

bool Imagick::gammaImage ( float $gamma [, int $channel = 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

说明

bool Imagick::gaussianBlurImage ( float $radius , float $sigma [, 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

说明

int Imagick::getColorspace ( 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

说明

int Imagick::getCompression ( void )

Gets the object compression type.

返回值

Returns the compression constant

Imagick::getCompressionQuality

Gets the object compression quality

说明

int Imagick::getCompressionQuality ( void )

Gets the object compression quality.

返回值

Returns integer describing the compression quality

Imagick::getCopyright

Returns the ImageMagick API copyright as a string

说明

string Imagick::getCopyright ( 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

说明

string Imagick::getFilename ( void )

Returns the filename associated with an image sequence.

返回值

Returns a string on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getFont

Gets font

说明

string Imagick::getFont ( 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

说明

string Imagick::getFormat ( void )

Returns the format of the Imagick object.

返回值

Returns the format of the image.

错误/异常

错误时抛出 ImagickException。

Imagick::getGravity

Gets the gravity

说明

int Imagick::getGravity ( 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

说明

string Imagick::getHomeURL ( void )

Returns the ImageMagick home URL.

返回值

Returns a link to the imagemagick homepage.

Imagick::getImage

Returns a new Imagick object

说明

Imagick Imagick::getImage ( 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 Imagick::getImageAlphaChannel ( void )

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

返回值

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

错误/异常

错误时抛出 ImagickException。

Imagick::getImageArtifact

Get image artifact

说明

string Imagick::getImageArtifact ( 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

说明

public string Imagick::getImageAttribute ( string $key )

Returns a named attribute.

参数

key
The key of the attribute to get.

返回值

Imagick::getImageBackgroundColor

Returns the image background color

说明

ImagickPixel Imagick::getImageBackgroundColor ( 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

说明

string Imagick::getImageBlob ( 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

说明

array Imagick::getImageBluePrimary ( 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

说明

ImagickPixel Imagick::getImageBorderColor ( void )

Returns the image border color.

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::getImageChannelDepth

Gets the depth for a particular image channel

说明

int Imagick::getImageChannelDepth ( 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

说明

float Imagick::getImageChannelDistortion ( Imagick $reference , int $channel , 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

说明

float Imagick::getImageChannelDistortions ( Imagick $reference , int $metric [, int $channel = 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

说明

array Imagick::getImageChannelExtrema ( 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 = 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

说明

array Imagick::getImageChannelMean ( int $channel )

Gets the mean and standard deviation of one or more image channels. Return value is an associative array with the keys "mean" and "standardDeviation".

参数

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::getImageChannelRange

Gets channel range

说明

array Imagick::getImageChannelRange ( 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

说明

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. You can access the red channel mean, for example, like this:

返回值

成功时返回 TRUE

Imagick::getImageClipMask

Gets image clip mask

说明

Imagick Imagick::getImageClipMask ( 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

说明

ImagickPixel Imagick::getImageColormapColor ( 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

说明

int Imagick::getImageColors ( void )

Gets the number of unique colors in the image.

返回值

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

Imagick::getImageColorspace

Gets the image colorspace

说明

int Imagick::getImageColorspace ( 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

说明

int Imagick::getImageCompose ( void )

Returns the composite operator associated with the image.

返回值

成功时返回 TRUE

Imagick::getImageCompression

Gets the current image's compression type

说明

int Imagick::getImageCompression ( void )

Gets the current image's compression type.

返回值

Returns the compression constant

Imagick::getImageCompressionQuality

Gets the current image's compression quality

说明

int Imagick::getImageCompressionQuality ( void )

Gets the current image's compression quality

返回值

Returns integer describing the images compression quality

Imagick::getImageDelay

Gets the image delay

说明

int Imagick::getImageDelay ( void )

Gets the image delay.

返回值

Returns the image delay.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageDepth

Gets the image depth

说明

int Imagick::getImageDepth ( void )

Gets the image depth.

返回值

The image depth.

Imagick::getImageDispose

Gets the image disposal method

说明

int Imagick::getImageDispose ( void )

Gets the image disposal method.

返回值

Returns the dispose method on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageDistortion

Compares an image to a reconstructed image

说明

float Imagick::getImageDistortion ( MagickWand $reference , 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

说明

array Imagick::getImageExtrema ( 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

说明

string Imagick::getImageFilename ( 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

说明

string Imagick::getImageFormat ( 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

说明

float Imagick::getImageGamma ( void )

Gets the image gamma.

返回值

Returns the image gamma on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageGeometry

Gets the width and height as an associative array

说明

array Imagick::getImageGeometry ( 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

说明

int Imagick::getImageGravity ( void )

Gets the current gravity value of the image. Unlike 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

说明

array Imagick::getImageGreenPrimary ( 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

说明

int Imagick::getImageHeight ( void )

Returns the image height.

返回值

Returns the image height in pixels.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageHistogram

Gets the image histogram

说明

array Imagick::getImageHistogram ( void )

Returns the image histogram as an array of ImagickPixel objects.

返回值

Returns the image histogram as an array of ImagickPixel objects.

错误/异常

错误时抛出 ImagickException。

范例

示例 #1 Generates 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

说明

int Imagick::getImageIndex ( void )

Returns the index of the current active image within the Imagick object. This method has been deprecated. See Imagick::getIteratorIndex.

返回值

Returns an integer containing the index of the image in the stack.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageInterlaceScheme

Gets the image interlace scheme

说明

int Imagick::getImageInterlaceScheme ( void )

Gets the image interlace scheme.

返回值

Returns the interlace scheme as an integer on success. 错误时抛出 ImagickException

Imagick::getImageInterpolateMethod

Returns the interpolation method

说明

int Imagick::getImageInterpolateMethod ( 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

说明

int Imagick::getImageIterations ( void )

Gets the image iterations.

返回值

Returns the image iterations as an integer.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageLength

Returns the image length in bytes

说明

int Imagick::getImageLength ( void )

Returns the image length in bytes

返回值

Returns an int containing the current image size.

范例

示例 #1 Using Imagick::getImageLength:

Getting image length in bytes

<?php
$image = new Imagick('test.jpg');
echo $image->getImageLength() . ' bytes';
?>

Imagick::getImageMagickLicense

Returns a string containing the ImageMagick license

说明

string Imagick::getImageMagickLicense ( void )

Returns a string containing the ImageMagick license

返回值

Returns a string containing the ImageMagick license.

Imagick::getImageMatte

Return if the image has a matte channel

说明

bool Imagick::getImageMatte ( 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

说明

ImagickPixel Imagick::getImageMatteColor ( void )

Returns the image matte color.

返回值

Returns ImagickPixel object on success.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageMimeType

Description

说明

public string Imagick::getImageMimeType ( void )

Returns the image mime-type.

参数

此函数没有参数。

返回值

Imagick::getImageOrientation

Gets the image orientation

说明

int Imagick::getImageOrientation ( 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

说明

array Imagick::getImagePage ( 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

说明

ImagickPixel Imagick::getImagePixelColor ( int $x , 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

说明

string Imagick::getImageProfile ( 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

说明

array Imagick::getImageProfiles ([ string $pattern = "*" [, 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

说明

array Imagick::getImageProperties ([ string $pattern = "*" [, 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 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

说明

string Imagick::getImageProperty ( string $name )

Returns the named image property. 此方法在Imagick基于ImageMagick 6.3.2以上版本编译时可用。

参数

name
name of the property (for example Exif:DateTime)

范例

示例 #1 Using 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

说明

array Imagick::getImageRedPrimary ( 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

说明

Imagick Imagick::getImageRegion ( 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

说明

int Imagick::getImageRenderingIntent ( void )

Gets the image rendering intent.

返回值

Returns the image rendering intent.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageResolution

获取图像的x,y轴分辨率

说明

array Imagick::getImageResolution ( void )

获取图像的x,y轴分辨率

返回值

返回分辨率值的数组

错误/异常

错误时抛出 ImagickException。

Imagick::getImagesBlob

Returns all image sequences as a blob

说明

string Imagick::getImagesBlob ( 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

说明

int Imagick::getImageScene ( void )

Gets the image scene.

返回值

Returns the image scene.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageSignature

Generates an SHA-256 message digest

说明

string Imagick::getImageSignature ( 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

说明

int Imagick::getImageSize ( 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

说明

int Imagick::getImageTicksPerSecond ( void )

Gets the image ticks-per-second.

返回值

Returns the image ticks-per-second.

错误/异常

错误时抛出 ImagickException。

Imagick::getImageTotalInkDensity

Gets the image total ink density

说明

float Imagick::getImageTotalInkDensity ( void )

Gets the image total ink density.

返回值

Returns the image total ink density of the image. 错误时抛出 ImagickException

Imagick::getImageType

Gets the potential image type

说明

int Imagick::getImageType ( 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 Imagick::getImageUnits ( void )

获取图像的分辨率单位。

返回值

返回分辨率的单位

错误/异常

错误时抛出 ImagickException。

Imagick::getImageVirtualPixelMethod

Returns the virtual pixel method

说明

int Imagick::getImageVirtualPixelMethod ( 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

说明

array Imagick::getImageWhitePoint ( 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

说明

int Imagick::getImageWidth ( void )

Returns the image width.

返回值

Returns the image width.

错误/异常

错误时抛出 ImagickException。

Imagick::getInterlaceScheme

Gets the object interlace scheme

说明

int Imagick::getInterlaceScheme ( void )

Gets the object interlace scheme.

返回值

Gets the wand interlace scheme.

错误/异常

错误时抛出 ImagickException。

Imagick::getIteratorIndex

Gets the index of the current active image

说明

int Imagick::getIteratorIndex ( 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 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

说明

int Imagick::getNumberImages ( 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

说明

string Imagick::getOption ( 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

说明

string Imagick::getPackageName ( void )

Returns the ImageMagick package name.

返回值

Returns the ImageMagick package name as a string.

错误/异常

错误时抛出 ImagickException。

Imagick::getPage

Returns the page geometry

说明

array Imagick::getPage ( 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

说明

ImagickPixelIterator Imagick::getPixelIterator ( 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

说明

ImagickPixelIterator Imagick::getPixelRegionIterator ( int $x , int $y , 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 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

说明

float Imagick::getPointSize ( 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 static int Imagick::getQuantum ( void )

Returns the ImageMagick quantum range as an integer.

参数

此函数没有参数。

返回值

Imagick::getQuantumDepth

Gets the quantum depth

说明

array Imagick::getQuantumDepth ( void )

Returns the Imagick quantum depth as a string.

返回值

Returns the Imagick quantum depth as a string.

错误/异常

错误时抛出 ImagickException。

Imagick::getQuantumRange

Returns the Imagick quantum range

说明

array Imagick::getQuantumRange ( void )

Returns the quantum range for the Imagick instance.

返回值

Returns an associative array containing the quantum range as an integer ("quantumRangeLong") and as a string ("quantumRangeString").

错误/异常

错误时抛出 ImagickException。

Imagick::getRegistry

Description

说明

public static string Imagick::getRegistry ( 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

说明

string Imagick::getReleaseDate ( 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

说明

int Imagick::getResource ( 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

说明

int Imagick::getResourceLimit ( 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

说明

array Imagick::getSamplingFactors ( 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

说明

array Imagick::getSize ( 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 class="function">Imagick::setSize. If you want to get the actual width / height of the image, use class="function">Imagick::getImageWidth and 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

说明

int Imagick::getSizeOffset ( 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

说明

array Imagick::getVersion ( 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 ( Imagick $clut [, int $channel = 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

说明

bool Imagick::hasNextImage ( 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

说明

bool Imagick::hasPreviousImage ( 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 string Imagick::identifyFormat ( 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

说明

array Imagick::identifyImage ([ 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

说明

bool Imagick::implodeImage ( 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 ( int $x , int $y , int $width , int $height , string $map , int $storage , 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 , 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

说明

bool Imagick::labelImage ( string $label )

Adds a label to an image.

参数

label
The label to add

返回值

成功时返回 TRUE

Imagick::levelImage

Adjusts the levels of an image

说明

bool Imagick::levelImage ( float $blackPoint , float $gamma , float $whitePoint [, int $channel = 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

说明

bool Imagick::linearStretchImage ( 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

说明

bool Imagick::liquidRescaleImage ( int $width , int $height , float $delta_x , 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 static array Imagick::listRegistry ( 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

说明

bool Imagick::magnifyImage ( 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

说明

bool Imagick::mapImage ( Imagick $map , bool $dither )

参数

map

dither

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::matteFloodfillImage

Changes the transparency value of a color

说明

bool Imagick::matteFloodfillImage ( float $alpha , float $fuzz , mixed $bordercolor , int $x , 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。

更新日志

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

Imagick::medianFilterImage

Applies a digital filter

说明

bool Imagick::medianFilterImage ( 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

说明

Imagick Imagick::mergeImageLayers ( 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

说明

bool Imagick::minifyImage ( 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

说明

bool Imagick::modulateImage ( float $brightness , float $saturation , 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

说明

Imagick Imagick::montageImage ( ImagickDraw $draw , string $tile_geometry , string $thumbnail_geometry , int $mode , 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

说明

Imagick Imagick::morphImages ( 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. 错误时抛出 ImagickException

Imagick::morphology

Description

说明

public bool Imagick::morphology ( int $morphologyMethod , int $iterations , ImagickKernel $ImagickKernel [, 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 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 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 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 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 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 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 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 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. 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'. 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 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 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 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 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

说明

Imagick Imagick::mosaicImages ( 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

说明

bool Imagick::motionBlurImage ( float $radius , float $sigma , float $angle [, int $channel = 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

说明

bool Imagick::negateImage ( bool $gray [, int $channel = 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 Imagick::newImage ( int $cols , int $rows , 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

说明

bool Imagick::newPseudoImage ( 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

说明

bool Imagick::nextImage ( void )

Associates the next image in the image list with an Imagick object.

返回值

成功时返回 TRUE

Imagick::normalizeImage

Enhances the contrast of a color image

说明

bool Imagick::normalizeImage ([ int $channel = 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

说明

bool Imagick::oilPaintImage ( 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

说明

bool Imagick::opaquePaintImage ( mixed $target , mixed $fill , float $fuzz , bool $invert [, int $channel = 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

说明

bool Imagick::optimizeImageLayers ( 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 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

说明

bool Imagick::orderedPosterizeImage ( string $threshold_map [, 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 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

说明

bool Imagick::paintFloodfillImage ( mixed $fill , float $fuzz , mixed $bordercolor , int $x , int $y [, 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 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

说明

bool Imagick::paintOpaqueImage ( mixed $target , mixed $fill , float $fuzz [, 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。

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::paintTransparentImage ( mixed $target , float $alpha , 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。

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::pingImage ( 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

说明

bool Imagick::pingImageBlob ( 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

说明

bool Imagick::pingImageFile ( resource $filehandle [, 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

说明

bool Imagick::polaroidImage ( ImagickDraw $properties , 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

说明

bool Imagick::posterizeImage ( 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

说明

bool Imagick::previewImages ( 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

说明

bool Imagick::previousImage ( void )

Assocates the previous image in an image list with the Imagick object.

返回值

成功时返回 TRUE

Imagick::profileImage

Adds or removes a profile from an image

说明

bool Imagick::profileImage ( 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

说明

bool Imagick::quantizeImage ( int $numberColors , int $colorspace , int $treedepth , 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

说明

bool Imagick::quantizeImages ( int $numberColors , int $colorspace , int $treedepth , bool $dither , bool $measureError )

参数

numberColors

colorspace

treedepth

dither

measureError

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::queryFontMetrics

Returns an array representing the font metrics

说明

array Imagick::queryFontMetrics ( ImagickDraw $properties , string $text [, 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 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

说明

array Imagick::queryFonts ([ string $pattern = "*" ] )

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

说明

array Imagick::queryFormats ([ string $pattern = "*" ] )

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

说明

bool Imagick::radialBlurImage ( float $angle [, int $channel = 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

说明

bool Imagick::raiseImage ( 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

说明

bool Imagick::randomThresholdImage ( 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

说明

bool Imagick::readImage ( string $filename )

Reads image from filename

参数

filename

返回值

成功时返回 TRUE

Imagick::readImageBlob

从二进制字符串里读取图片

说明

bool Imagick::readImageBlob ( 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

说明

bool Imagick::readImageFile ( resource $filehandle [, string $fileName = NULL ] )

Reads image from open filehandle

参数

filehandle

fileName

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::readimages

Description

说明

public bool Imagick::readImages ( 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

说明

bool Imagick::recolorImage ( 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

说明

bool Imagick::reduceNoiseImage ( 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 ( Imagick $replacement , 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

说明

bool Imagick::removeImage ( void )

Removes an image from the image list.

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::removeImageProfile

Removes the named image profile and returns it

说明

string Imagick::removeImageProfile ( 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

说明

bool Imagick::render ( void )

Renders all preceding drawing commands.

返回值

成功时返回 TRUE

Imagick::resampleImage

Resample image to desired resolution

说明

bool Imagick::resampleImage ( float $x_resolution , float $y_resolution , 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

说明

bool Imagick::resetImagePage ( 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

说明

bool Imagick::resizeImage ( int $columns , int $rows , int $filter , float $blur [, bool $bestfit = FALSE [, 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

更新日志

版本说明
2.1.0Added 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

说明

bool Imagick::rollImage ( int $x , 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

说明

bool Imagick::rotateImage ( 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

更新日志

版本说明
2.1.0Now 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 ( float $angle [, int $channel = 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

说明

bool Imagick::roundCorners ( float $x_rounding , float $y_rounding [, float $stroke_width = 10 [, float $displace = 5 [, 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

说明

bool Imagick::sampleImage ( 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

说明

bool Imagick::scaleImage ( int $cols , int $rows [, bool $bestfit = FALSE [, bool $legacy = 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。

更新日志

版本说明
2.1.0Added 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 ( int $COLORSPACE , float $cluster_threshold , float $smooth_threshold [, bool $verbose = 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 ( float $radius , float $sigma , float $threshold [, int $channel = 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

说明

bool Imagick::separateImageChannel ( 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

说明

bool Imagick::sepiaToneImage ( 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

说明

bool Imagick::setBackgroundColor ( mixed $background )

Sets the object's default background color.

参数

background

返回值

成功时返回 TRUE

更新日志

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

Imagick::setColorspace

Set colorspace

说明

bool Imagick::setColorspace ( 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

说明

bool Imagick::setCompression ( 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

说明

bool Imagick::setCompressionQuality ( 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 Imagick::setImageCompressionQuality.

参数

quality
An integer between 1 and 100, 1 = high compression, 100 low compression.

返回值

成功时返回 TRUE

范例

示例 #1 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

说明

bool Imagick::setFilename ( 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

说明

bool Imagick::setFirstIterator ( void )

Sets the Imagick iterator to the first image.

返回值

成功时返回 TRUE

Imagick::setFont

Sets font

说明

bool Imagick::setFont ( 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 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

说明

bool Imagick::setFormat ( string $format )

Sets the format of the Imagick object.

参数

format

返回值

成功时返回 TRUE

Imagick::setGravity

Sets the gravity

说明

bool Imagick::setGravity ( 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

说明

bool Imagick::setImage ( 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

说明

bool Imagick::setImageAlphaChannel ( 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

说明

bool Imagick::setImageArtifact ( 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

说明

public bool Imagick::setImageAttribute ( string $key , string $value )

Warning

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

参数

key

value

返回值

成功时返回 TRUE

Imagick::setImageBackgroundColor

Sets the image background color

说明

bool Imagick::setImageBackgroundColor ( mixed $background )

Sets the image background color.

参数

background

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::setImageBias ( 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

说明

public void Imagick::setImageBiasQuantum ( string $bias )

Warning

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

参数

bias

返回值

Imagick::setImageBluePrimary

Sets the image chromaticity blue primary point

说明

bool Imagick::setImageBluePrimary ( float $x , float $y )

Sets the image chromaticity blue primary point.

参数

x

y

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageBorderColor

Sets the image border color

说明

bool Imagick::setImageBorderColor ( mixed $border )

Sets the image border color.

参数

border
The border color

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::setImageChannelDepth ( int $channel , int $depth )

Sets the depth of a particular image channel.

参数

channel

depth

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageClipMask

Sets image clip mask

说明

bool Imagick::setImageClipMask ( 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

说明

bool Imagick::setImageColormapColor ( int $index , ImagickPixel $color )

Sets the color of the specified colormap index.

参数

index

color

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageColorspace

Sets the image colorspace

说明

bool Imagick::setImageColorspace ( 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

说明

bool Imagick::setImageCompose ( 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 Imagick::setImageCompression ( int $compression )

参数

compression
COMPRESSION 常量里的一种

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageCompressionQuality

设置图片压缩的质量

说明

bool Imagick::setImageCompressionQuality ( int $quality )

设置图片压缩的质量

参数

quality
配置压缩质量的整数

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageDelay

Sets the image delay

说明

bool Imagick::setImageDelay ( 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 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

说明

bool Imagick::setImageDepth ( int $depth )

Sets the image depth.

参数

depth

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageDispose

Sets the image disposal method

说明

bool Imagick::setImageDispose ( int $dispose )

Sets the image disposal method.

参数

dispose

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageExtent

Sets the image size

说明

bool Imagick::setImageExtent ( 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

说明

bool Imagick::setImageFilename ( string $filename )

Sets the filename of a particular image in a sequence.

参数

filename

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageFormat

为图片设置指定的格式

说明

bool Imagick::setImageFormat ( string $format )

为图片设置指定的格式

参数

format
表示图片格式的一个字符串。支持的格式依赖于 ImageMagick 的安装。

返回值

成功时返回 TRUE

Imagick::setImageGamma

Sets the image gamma

说明

bool Imagick::setImageGamma ( float $gamma )

Sets the image gamma.

参数

gamma

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageGravity

Sets the image gravity

说明

bool Imagick::setImageGravity ( 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

说明

bool Imagick::setImageGreenPrimary ( float $x , float $y )

Sets the image chromaticity green primary point.

参数

x

y

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageIndex

Set the iterator position

说明

bool Imagick::setImageIndex ( int $index )

Set the iterator to the position in the image list specified with the index parameter.

This method has been deprecated. See Imagick::setIteratorIndex.

参数

index
The position to set the iterator to

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageInterlaceScheme

Sets the image compression

说明

bool Imagick::setImageInterlaceScheme ( int $interlace_scheme )

Sets the image compression.

参数

interlace_scheme

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageInterpolateMethod

Sets the image interpolate pixel method

说明

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

说明

bool Imagick::setImageIterations ( 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 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

说明

bool Imagick::setImageMatte ( 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

说明

bool Imagick::setImageMatteColor ( mixed $matte )

Sets the image matte color.

参数

matte

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

更新日志

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

Imagick::setImageOpacity

Sets the image opacity level

说明

bool Imagick::setImageOpacity ( 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

说明

bool Imagick::setImageOrientation ( 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

说明

bool Imagick::setImagePage ( 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

说明

bool Imagick::setImageProfile ( 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

说明

bool Imagick::setImageProperty ( string $name , string $value )

Sets a named property to the image. 此方法在Imagick基于ImageMagick 6.3.2以上版本编译时可用。

参数

name

value

范例

示例 #1 Using 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

说明

bool Imagick::setImageRedPrimary ( float $x , float $y )

Sets the image chromaticity red primary point.

参数

x

y

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageRenderingIntent

Sets the image rendering intent

说明

bool Imagick::setImageRenderingIntent ( int $rendering_intent )

Sets the image rendering intent.

参数

rendering_intent

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageResolution

Sets the image resolution

说明

bool Imagick::setImageResolution ( float $x_resolution , 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

说明

bool Imagick::setImageScene ( int $scene )

Sets the image scene.

参数

scene

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setImageTicksPerSecond

Sets the image ticks-per-second

说明

bool Imagick::setImageTicksPerSecond ( 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 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

说明

bool Imagick::setImageType ( int $image_type )

Sets the image type.

参数

image_type

返回值

成功时返回 TRUE

Imagick::setImageUnits

Sets the image units of resolution

说明

bool Imagick::setImageUnits ( int $units )

Sets the image units of resolution.

参数

units

返回值

成功时返回 TRUE

Imagick::setImageVirtualPixelMethod

Sets the image virtual pixel method

说明

bool Imagick::setImageVirtualPixelMethod ( int $method )

Sets the image virtual pixel method.

参数

method

返回值

成功时返回 TRUE

Imagick::setImageWhitePoint

Sets the image chromaticity white point

说明

bool Imagick::setImageWhitePoint ( float $x , float $y )

Sets the image chromaticity white point.

参数

x

y

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::setInterlaceScheme

Sets the image compression

说明

bool Imagick::setInterlaceScheme ( int $interlace_scheme )

Sets the image compression.

参数

interlace_scheme

返回值

成功时返回 TRUE

Imagick::setIteratorIndex

Set the iterator position

说明

bool Imagick::setIteratorIndex ( 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 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

说明

bool Imagick::setLastIterator ( void )

Sets the Imagick iterator to the last image.

返回值

成功时返回 TRUE

Imagick::setOption

Set an option

说明

bool Imagick::setOption ( string $key , string $value )

Associates one or more options with the wand.

参数

key

value

返回值

成功时返回 TRUE

范例

示例 #1 Attempt to reach '$extent' sizeImagick::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

说明

bool Imagick::setPage ( 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

说明

bool Imagick::setPointSize ( 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 ( 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 callback ( mixed $offset , 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 static bool Imagick::setRegistry ( 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

说明

bool Imagick::setResolution ( float $x_resolution , 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

说明

bool Imagick::setResourceLimit ( int $type , 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

说明

bool Imagick::setSamplingFactors ( 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

说明

bool Imagick::setSize ( 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

说明

bool Imagick::setSizeOffset ( 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

说明

bool Imagick::setType ( int $image_type )

Sets the image type attribute.

参数

image_type

返回值

成功时返回 TRUE

Imagick::shadeImage

Creates a 3D effect

说明

bool Imagick::shadeImage ( bool $gray , float $azimuth , 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

说明

bool Imagick::shadowImage ( float $opacity , float $sigma , int $x , 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

说明

bool Imagick::sharpenImage ( float $radius , float $sigma [, 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 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

说明

bool Imagick::shaveImage ( 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

说明

bool Imagick::shearImage ( mixed $background , float $x_shear , 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

更新日志

版本说明
2.1.0Now 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

说明

bool Imagick::sigmoidalContrastImage ( bool $sharpen , float $alpha , float $beta [, int $channel = 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 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

说明

bool Imagick::sketchImage ( float $radius , float $sigma , 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 ( 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

说明

bool Imagick::solarizeImage ( 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 ( int $SPARSE_METHOD , array $arguments [, int $channel = 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 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 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 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 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 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. 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

说明

bool Imagick::spliceImage ( 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

说明

bool Imagick::spreadImage ( 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 ( int $type , 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

说明

Imagick Imagick::steganoImage ( Imagick $watermark_wand , 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

说明

bool Imagick::stereoImage ( 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 Imagick::stripImage ( void )

去掉图片的所有配置和设置

返回值

成功时返回 TRUE

错误/异常

错误时抛出 ImagickException。

Imagick::subImageMatch

Description

说明

public Imagick Imagick::subImageMatch ( Imagick $Imagick [, array &$offset [, 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 Imagick::swirlImage ( 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 Imagick::textureImage ( 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

说明

bool Imagick::thresholdImage ( 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

说明

bool Imagick::thumbnailImage ( int $columns , int $rows [, bool $bestfit = FALSE [, bool $fill = FALSE [, bool $legacy = 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

说明

bool Imagick::tintImage ( mixed $tint , mixed $opacity [, 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。

更新日志

版本说明
2.1.0Now 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

说明

string Imagick::__toString ( 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

说明

Imagick Imagick::transformImage ( 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 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

说明

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 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 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

说明

bool Imagick::transparentPaintImage ( mixed $target , float $alpha , float $fuzz , 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 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

说明

bool Imagick::transposeImage ( 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

说明

bool Imagick::transverseImage ( 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

说明

bool Imagick::trimImage ( 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

说明

bool Imagick::uniqueImageColors ( 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

说明

bool Imagick::unsharpMaskImage ( float $radius , float $sigma , float $amount , 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

说明

bool Imagick::valid ( void )

Checks if the current item is valid.

返回值

成功时返回 TRUE

Imagick::vignetteImage

Adds vignette filter to the image

说明

bool Imagick::vignetteImage ( float $blackPoint , float $whitePoint , int $x , 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

说明

bool Imagick::waveImage ( 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 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

说明

bool Imagick::whiteThresholdImage ( 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

更新日志

版本说明
2.1.0Now 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 Imagick::writeImage ([ string $filename = NULL ] )

把图片写入指定的文件。如果指定文件参数的值是 NULL ,图片将会写入通过 Imagick::readImage() 或者 Imagick::setImageFilename() 设定的文件。

参数

filename
图片将被写入的文件名。文件的后缀指定了文件的类型。 可以强制指定图片的格式而不管文件的后缀名。在文件名前面加上一个前缀,例如 “jpg:test.png”。

返回值

成功时返回 TRUE

Imagick::writeImageFile

Writes an image to a filehandle

说明

bool Imagick::writeImageFile ( resource $filehandle [, 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

说明

bool Imagick::writeImages ( string $filename , bool $adjoin )

Writes an image or image sequence.

参数

filename

adjoin

返回值

成功时返回 TRUE

Imagick::writeImagesFile

Writes frames to a filehandle

说明

bool Imagick::writeImagesFile ( resource $filehandle [, 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 {

bool affine ( array $affine )

bool annotation ( float $x , float $y , string $text )

bool arc ( float $sx , float $sy , float $ex , float $ey , float $sd , float $ed )

bool bezier ( array $coordinates )

bool circle ( float $ox , float $oy , float $px , float $py )

bool clear ( void )

ImagickDraw clone ( void )

bool color ( float $x , float $y , int $paintMethod )

bool comment ( string $comment )

bool composite ( int $compose , float $x , float $y , float $width , float $height , Imagick $compositeWand )

__construct ( void )

bool destroy ( void )

bool ellipse ( float $ox , float $oy , float $rx , float $ry , float $start , float $end )

string getClipPath ( void )

int getClipRule ( void )

int getClipUnits ( void )

ImagickPixel getFillColor ( void )

float getFillOpacity ( void )

int getFillRule ( void )

string getFont ( void )

string getFontFamily ( void )

float getFontSize ( void )

public int getFontStretch ( void )

int getFontStyle ( void )

int getFontWeight ( void )

int getGravity ( void )

bool getStrokeAntialias ( void )

ImagickPixel getStrokeColor ( void )

array getStrokeDashArray ( void )

float getStrokeDashOffset ( void )

int getStrokeLineCap ( void )

int getStrokeLineJoin ( void )

int getStrokeMiterLimit ( void )

float getStrokeOpacity ( void )

float getStrokeWidth ( void )

int getTextAlignment ( void )

bool getTextAntialias ( void )

int getTextDecoration ( void )

string getTextEncoding ( void )

public float getTextInterlineSpacing ( void )

public float getTextInterwordSpacing ( void )

public float getTextKerning ( void )

ImagickPixel getTextUnderColor ( void )

string getVectorGraphics ( void )

bool line ( float $sx , float $sy , float $ex , float $ey )

bool matte ( float $x , float $y , int $paintMethod )

bool pathClose ( void )

bool pathCurveToAbsolute ( float $x1 , float $y1 , float $x2 , float $y2 , float $x , float $y )

bool pathCurveToQuadraticBezierAbsolute ( float $x1 , float $y1 , float $x , float $y )

bool pathCurveToQuadraticBezierRelative ( float $x1 , float $y1 , float $x , float $y )

bool pathCurveToQuadraticBezierSmoothAbsolute ( float $x , float $y )

bool pathCurveToQuadraticBezierSmoothRelative ( float $x , float $y )

bool pathCurveToRelative ( float $x1 , float $y1 , float $x2 , float $y2 , float $x , float $y )

bool pathCurveToSmoothAbsolute ( float $x2 , float $y2 , float $x , float $y )

bool pathCurveToSmoothRelative ( float $x2 , float $y2 , float $x , float $y )

bool pathEllipticArcAbsolute ( float $rx , float $ry , float $x_axis_rotation , bool $large_arc_flag , bool $sweep_flag , float $x , float $y )

bool pathEllipticArcRelative ( float $rx , float $ry , float $x_axis_rotation , bool $large_arc_flag , bool $sweep_flag , float $x , float $y )

bool pathFinish ( void )

bool pathLineToAbsolute ( float $x , float $y )

bool pathLineToHorizontalAbsolute ( float $x )

bool pathLineToHorizontalRelative ( float $x )

bool pathLineToRelative ( float $x , float $y )

bool pathLineToVerticalAbsolute ( float $y )

bool pathLineToVerticalRelative ( float $y )

bool pathMoveToAbsolute ( float $x , float $y )

bool pathMoveToRelative ( float $x , float $y )

bool pathStart ( void )

bool point ( float $x , float $y )

bool polygon ( array $coordinates )

bool polyline ( array $coordinates )

bool pop ( void )

bool popClipPath ( void )

bool popDefs ( void )

bool popPattern ( void )

bool push ( void )

bool pushClipPath ( string $clip_mask_id )

bool pushDefs ( void )

bool pushPattern ( string $pattern_id , float $x , float $y , float $width , float $height )

bool rectangle ( float $x1 , float $y1 , float $x2 , float $y2 )

bool render ( void )

public bool resetVectorGraphics ( void )

bool rotate ( float $degrees )

bool roundRectangle ( float $x1 , float $y1 , float $x2 , float $y2 , float $rx , float $ry )

bool scale ( float $x , float $y )

bool setClipPath ( string $clip_mask )

bool setClipRule ( int $fill_rule )

bool setClipUnits ( int $clip_units )

bool setFillAlpha ( float $opacity )

bool setFillColor ( ImagickPixel $fill_pixel )

bool setFillOpacity ( float $fillOpacity )

bool setFillPatternURL ( string $fill_url )

bool setFillRule ( int $fill_rule )

bool setFont ( string $font_name )

bool setFontFamily ( string $font_family )

bool setFontSize ( float $pointsize )

bool setFontStretch ( int $fontStretch )

bool setFontStyle ( int $style )

bool setFontWeight ( int $font_weight )

bool setGravity ( int $gravity )

public bool setResolution ( float $x_resolution , float $y_resolution )

bool setStrokeAlpha ( float $opacity )

bool setStrokeAntialias ( bool $stroke_antialias )

bool setStrokeColor ( ImagickPixel $stroke_pixel )

bool setStrokeDashArray ( array $dashArray )

bool setStrokeDashOffset ( float $dash_offset )

bool setStrokeLineCap ( int $linecap )

bool setStrokeLineJoin ( int $linejoin )

bool setStrokeMiterLimit ( int $miterlimit )

bool setStrokeOpacity ( float $stroke_opacity )

bool setStrokePatternURL ( string $stroke_url )

bool setStrokeWidth ( float $stroke_width )

bool setTextAlignment ( int $alignment )

bool setTextAntialias ( bool $antiAlias )

bool setTextDecoration ( int $decoration )

bool setTextEncoding ( string $encoding )

public bool setTextInterlineSpacing ( float $spacing )

public bool setTextInterwordSpacing ( float $spacing )

public bool setTextKerning ( float $kerning )

bool setTextUnderColor ( ImagickPixel $under_color )

bool setVectorGraphics ( string $xml )

bool setViewbox ( int $x1 , int $y1 , int $x2 , int $y2 )

bool skewX ( float $degrees )

bool skewY ( float $degrees )

bool translate ( float $x , float $y )

}

ImagickDraw::affine

Adjusts the current affine transformation matrix

说明

bool ImagickDraw::affine ( 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

说明

bool ImagickDraw::annotation ( float $x , float $y , 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

说明

bool ImagickDraw::arc ( float $sx , float $sy , float $ex , float $ey , float $sd , 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

说明

bool ImagickDraw::bezier ( 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

说明

bool ImagickDraw::circle ( float $ox , float $oy , float $px , 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

说明

bool ImagickDraw::clear ( 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

说明

ImagickDraw ImagickDraw::clone ( 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

说明

bool ImagickDraw::color ( float $x , float $y , 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

说明

bool ImagickDraw::comment ( 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

说明

bool ImagickDraw::composite ( int $compose , float $x , float $y , float $width , float $height , 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

说明

ImagickDraw::__construct ( void )

Warning

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

The ImagickDraw constructor

返回值

没有返回值。

ImagickDraw::destroy

Frees all associated resources

说明

bool ImagickDraw::destroy ( void )

Warning

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

Frees all resources associated with the ImagickDraw object.

返回值

没有返回值。

ImagickDraw::ellipse

Draws an ellipse on the image

说明

bool ImagickDraw::ellipse ( float $ox , float $oy , float $rx , float $ry , 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

说明

string ImagickDraw::getClipPath ( 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

说明

int ImagickDraw::getClipRule ( 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

说明

int ImagickDraw::getClipUnits ( void )

Warning

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

Returns the interpretation of clip path units.

返回值

Returns an int on success.

ImagickDraw::getFillColor

Returns the fill color

说明

ImagickPixel ImagickDraw::getFillColor ( void )

Warning

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

Returns the fill color used for drawing filled objects.

返回值

Returns an ImagickPixel object.

ImagickDraw::getFillOpacity

Returns the opacity used when drawing

说明

float ImagickDraw::getFillOpacity ( 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

说明

int ImagickDraw::getFillRule ( void )

Warning

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

Returns the fill rule used while drawing polygons.

返回值

Returns a FILLRULE_ constant

ImagickDraw::getFont

Returns the font

说明

string ImagickDraw::getFont ( 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

说明

string ImagickDraw::getFontFamily ( 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

说明

float ImagickDraw::getFontSize ( 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 ImagickDraw::getFontStretch ( void )

Gets the font stretch to use when annotating with text. Returns a StretchType.

参数

此函数没有参数。

返回值

ImagickDraw::getFontStyle

Returns the font style

说明

int ImagickDraw::getFontStyle ( 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

说明

int ImagickDraw::getFontWeight ( 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

说明

int ImagickDraw::getGravity ( 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

说明

bool ImagickDraw::getStrokeAntialias ( 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

说明

ImagickPixel ImagickDraw::getStrokeColor ( 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

说明

array ImagickDraw::getStrokeDashArray ( 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

说明

float ImagickDraw::getStrokeDashOffset ( 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

说明

int ImagickDraw::getStrokeLineCap ( 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

说明

int ImagickDraw::getStrokeLineJoin ( 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

说明

int ImagickDraw::getStrokeMiterLimit ( 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

说明

float ImagickDraw::getStrokeOpacity ( 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

说明

float ImagickDraw::getStrokeWidth ( 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

说明

int ImagickDraw::getTextAlignment ( 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

说明

bool ImagickDraw::getTextAntialias ( 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

说明

int ImagickDraw::getTextDecoration ( 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

说明

string ImagickDraw::getTextEncoding ( 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 ( void )

Gets the text kerning.

参数

此函数没有参数。

返回值

ImagickDraw::getTextUnderColor

Returns the text under color

说明

ImagickPixel ImagickDraw::getTextUnderColor ( 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

说明

string ImagickDraw::getVectorGraphics ( 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

说明

bool ImagickDraw::line ( float $sx , float $sy , float $ex , 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

说明

bool ImagickDraw::matte ( float $x , float $y , 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

说明

bool ImagickDraw::pathClose ( 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

说明

bool ImagickDraw::pathCurveToAbsolute ( float $x1 , float $y1 , float $x2 , float $y2 , float $x , 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

说明

bool 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 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

说明

bool 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

说明

bool 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 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

说明

bool 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 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

说明

bool ImagickDraw::pathCurveToRelative ( float $x1 , float $y1 , float $x2 , float $y2 , float $x , 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

说明

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

说明

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

说明

bool ImagickDraw::pathEllipticArcAbsolute ( float $rx , float $ry , float $x_axis_rotation , bool $large_arc_flag , 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

说明

bool ImagickDraw::pathEllipticArcRelative ( float $rx , float $ry , float $x_axis_rotation , bool $large_arc_flag , 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

说明

bool ImagickDraw::pathFinish ( void )

Warning

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

Terminates the current path.

返回值

没有返回值。

ImagickDraw::pathLineToAbsolute

Draws a line path

说明

bool ImagickDraw::pathLineToAbsolute ( float $x , 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

说明

bool 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

说明

bool 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

说明

bool ImagickDraw::pathLineToRelative ( float $x , 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

说明

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

说明

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

说明

bool ImagickDraw::pathMoveToAbsolute ( float $x , 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

说明

bool ImagickDraw::pathMoveToRelative ( float $x , float $y )

Warning

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

Starts a new sub-path at the given coordinate using relative coordinates. The current point then becomes the specified coordinate.