您的位置:首页技术文章
文章详情页

PHP扩展之图像处理2——Gmagick库使用示例及相关类和函数

【字号: 日期:2022-09-15 17:13:36浏览:2作者:猪猪
使用示例

<?php//初始化一个新的Gmagick对象$image = new Gmagick(’example.jpg’);//通过加载的图片生成缩略图(保持纵横比). $image->thumbnailImage(100, 0);//创建图片的边框, 然后模拟图像使其看上去像一幅油画$image->borderImage('yellow', 8, 8)->oilPaintImage(0.3);//将当前图片写入到一个文件$image->write(’example_thumbnail.jpg’);?>相关和类函数

1.Gmagick类

Gmagick::addimage — 添加一张新的图片到 Gmagick 对象图片列表Gmagick::addnoiseimage — 添加随机噪声到图片Gmagick::annotateimage — 为图片添加文字注释Gmagick::blurimage — 为图像添加模糊滤镜效果Gmagick::borderimage — 在图像四周添加边框Gmagick::charcoalimage — 模拟素描Gmagick::chopimage — 从图像中移除一块区域Gmagick::clear — 清除与Gmagick对象相关的所有资源Gmagick::commentimage — 添加注释到图像Gmagick::compositeimage — 合成一个图像到另一个图像Gmagick::__construct — Gmagick构造器Gmagick::cropimage — 裁剪获取图片指定区域Gmagick::cropthumbnailimage — 先缩放再裁剪从而创建一个指定尺寸的缩略图Gmagick::current — 当前目标Gmagick::cyclecolormapimage — Displaces an image’s colormapGmagick::deconstructimages — Returns certain pixel differences between imagesGmagick::despeckleimage — The despeckleimage purposeGmagick::destroy — 销毁Gmagick对象,释放内存空间Gmagick::drawimage — Renders the GmagickDraw object on the current imageGmagick::edgeimage — Enhance edges within the imageGmagick::embossimage — Returns a grayscale image with a three-dimensional effectGmagick::enhanceimage — Improves the quality of a noisy imageGmagick::equalizeimage — Equalizes the image histogramGmagick::flipimage — Creates a vertical mirror imageGmagick::flopimage — The flopimage purposeGmagick::frameimage — Adds a simulated three-dimensional borderGmagick::gammaimage — Gamma-corrects an imageGmagick::getcopyright — Returns the GraphicsMagick API copyright as a stringGmagick::getfilename — The filename associated with an image sequenceGmagick::getimagebackgroundcolor — Returns the image background colorGmagick::getimageblueprimary — Returns the chromaticy blue primary pointGmagick::getimagebordercolor — Returns the image border colorGmagick::getimagechanneldepth — Gets the depth for a particular image channelGmagick::getimagecolors — Returns the color of the specified colormap indexGmagick::getimagecolorspace — Gets the image colorspaceGmagick::getimagecompose — Returns the composite operator associated with the imageGmagick::getimagedelay — Gets the image delayGmagick::getimagedepth — Gets the depth of the imageGmagick::getimagedispose — Gets the image disposal methodGmagick::getimageextrema — Gets the extrema for the imageGmagick::getimagefilename — Returns the filename of a particular image in a sequenceGmagick::getimageformat — Returns the format of a particular image in a sequenceGmagick::getimagegamma — Gets the image gammaGmagick::getimagegreenprimary — Returns the chromaticy green primary pointGmagick::getimageheight — 返回图像高度Gmagick::getimagehistogram — Gets the image histogramGmagick::getimageindex — Gets the index of the current active imageGmagick::getimageinterlacescheme — Gets the image interlace schemeGmagick::getimageiterations — Gets the image iterationsGmagick::getimagematte — Return if the image has a matte channelGmagick::getimagemattecolor — Returns the image matte colorGmagick::getimageprofile — Returns the named image profile.Gmagick::getimageredprimary — Returns the chromaticity red primary pointGmagick::getimagerenderingintent — Gets the image rendering intentGmagick::getimageresolution — Gets the image X and Y resolutionGmagick::getimagescene — Gets the image sceneGmagick::getimagesignature — Generates an SHA-256 message digestGmagick::getimagetype — Gets the potential image type.Gmagick::getimageunits — Gets the image units of resolutionGmagick::getimagewhitepoint — Returns the chromaticity white pointGmagick::getimagewidth — 返回图像宽度Gmagick::getpackagename — Returns the GraphicsMagick package name.Gmagick::getquantumdepth — Returns the Gmagick quantum depth as a string.Gmagick::getreleasedate — Returns the GraphicsMagick release date as a string.Gmagick::getsamplingfactors — Gets the horizontal and vertical sampling factor.Gmagick::getsize — 返回与当前gmagick对象相关联的尺寸Gmagick::getversion — 返回当前GraphicsMagick API的版本Gmagick::hasnextimage — 检查对象是否包含更多图像Gmagick::haspreviousimage — Checks if the object has a previous imageGmagick::implodeimage — Creates a new image as a copyGmagick::labelimage — Adds a label to an image.Gmagick::levelimage — Adjusts the levels of an imageGmagick::magnifyimage — Scales an image proportionally 2xGmagick::mapimage — Replaces the colors of an image with the closest color from a reference image.Gmagick::medianfilterimage — Applies a digital filterGmagick::minifyimage — Scales an image proportionally to half its sizeGmagick::modulateimage — Control the brightness, saturation, and hueGmagick::motionblurimage — Simulates motion blurGmagick::newimage — 创建一个新的图像Gmagick::nextimage — 移动到下一张图片Gmagick::normalizeimage — Enhances the contrast of a color imageGmagick::oilpaintimage — 模拟油画效果(使用示例:本篇文章开头的示例代码)Gmagick::previousimage — Move to the previous image in the objectGmagick::profileimage — Adds or removes a profile from an imageGmagick::quantizeimage — Analyzes the colors within a reference imageGmagick::quantizeimages — The quantizeimages purposeGmagick::queryfontmetrics — Returns an array representing the font metricsGmagick::queryfonts — Returns the configured fontsGmagick::queryformats — Returns formats supported by Gmagick.Gmagick::radialblurimage — Radial blurs an imageGmagick::raiseimage — Creates a simulated 3d button-like effectGmagick::read — 从文件名中读取图像Gmagick::readimage — 从文件名中读取图像Gmagick::readimageblob — Reads image from a binary stringGmagick::readimagefile — The readimagefile purposeGmagick::reducenoiseimage — Smooths the contours of an imageGmagick::removeimage — Removes an image from the image listGmagick::removeimageprofile — Removes the named image profile and returns itGmagick::resampleimage — Resample image to desired resolutionGmagick::resizeimage — 调整图像尺寸Gmagick::rollimage — 偏移图像Gmagick::rotateimage — 旋转图片Gmagick::scaleimage — 调整图片大小Gmagick::separateimagechannel — Separates a channel from the imageGmagick::setfilename — 在读取或者写入图片之前设置文件名Gmagick::setimagebackgroundcolor — 设置图像背景色Gmagick::setimageblueprimary — Sets the image chromaticity blue primary point.Gmagick::setimagebordercolor — 设置图像边框颜色.Gmagick::setimagechanneldepth — Sets the depth of a particular image channelGmagick::setimagecolorspace — Sets the image colorspaceGmagick::setimagecompose — Sets the image composite operatorGmagick::setimagedelay — Sets the image delayGmagick::setimagedepth — Sets the image depthGmagick::setimagedispose — Sets the image disposal methodGmagick::setimagefilename — 在一个序列中设置特定图片的文件名Gmagick::setimageformat — Sets the format of a particular imageGmagick::setimagegamma — Sets the image gammaGmagick::setimagegreenprimary — TSets the image chromaticity green primary point.Gmagick::setimageindex — Set the iterator to the position in the image list specified with the index parameterGmagick::setimageinterlacescheme — Sets the interlace scheme of the image.Gmagick::setimageiterations — Sets the image iterations.Gmagick::setimageprofile — Adds a named profile to the Gmagick objectGmagick::setimageredprimary — Sets the image chromaticity red primary point.Gmagick::setimagerenderingintent — Sets the image rendering intentGmagick::setimageresolution — Sets the image resolutionGmagick::setimagescene — 设置图片场景Gmagick::setimagetype — 设置图片类型Gmagick::setimageunits — Sets the image units of resolution.Gmagick::setimagewhitepoint — Sets the image chromaticity white point.Gmagick::setsamplingfactors — Sets the image sampling factors.Gmagick::setsize — Sets the size of the Gmagick objectGmagick::shearimage — Creating a parallelogramGmagick::solarizeimage — Applies a solarizing effect to the imageGmagick::spreadimage — Randomly displaces each pixel in a blockGmagick::stripimage — Strips an image of all profiles and commentsGmagick::swirlimage — Swirls the pixels about the center of the imageGmagick::thumbnailimage — Changes the size of an imageGmagick::trimimage — Remove edges from the imageGmagick::write — 将图片写入到指定文件名,如果文件名为空,则图片写入到Gmagick::ReadImage()或者Gmagick::SetImageFilename()设置的文件名中。Gmagick::writeimage — 将图片写入指定文件名,与Gmagick::write的区别在于writeimage函数包含一个可选的布尔参数all_frames。

2.GmagickDraw 类

GmagickDraw::annotate — Draws text on the imageGmagickDraw::arc — Draws an arcGmagickDraw::bezier — Draws a bezier curveGmagickDraw::ellipse — Draws an ellipse on the imageGmagickDraw::getfillcolor — Returns the fill colorGmagickDraw::getfillopacity — Returns the opacity used when drawingGmagickDraw::getfont — Returns the fontGmagickDraw::getfontsize — Returns the font pointsizeGmagickDraw::getfontstyle — Returns the font styleGmagickDraw::getfontweight — Returns the font weightGmagickDraw::getstrokecolor — Returns the color used for stroking object outlinesGmagickDraw::getstrokeopacity — Returns the opacity of stroked object outlinesGmagickDraw::getstrokewidth — Returns the width of the stroke used to draw object outlinesGmagickDraw::gettextdecoration — Returns the text decorationGmagickDraw::gettextencoding — Returns the code set used for text annotationsGmagickDraw::line — The line purposeGmagickDraw::point — Draws a pointGmagickDraw::polygon — Draws a polygonGmagickDraw::polyline — Draws a polylineGmagickDraw::rectangle — Draws a rectangleGmagickDraw::rotate — Applies the specified rotation to the current coordinate spaceGmagickDraw::roundrectangle — Draws a rounded rectangleGmagickDraw::scale — Adjusts the scaling factorGmagickDraw::setfillcolor — Sets the fill color to be used for drawing filled objects.GmagickDraw::setfillopacity — The setfillopacity purposeGmagickDraw::setfont — Sets the fully-specified font to use when annotating with text.GmagickDraw::setfontsize — Sets the font pointsize to use when annotating with text.GmagickDraw::setfontstyle — Sets the font style to use when annotating with textGmagickDraw::setfontweight — Sets the font weightGmagickDraw::setstrokecolor — Sets the color used for stroking object outlines.GmagickDraw::setstrokeopacity — Specifies the opacity of stroked object outlines.GmagickDraw::setstrokewidth — Sets the width of the stroke used to draw object outlines.GmagickDraw::settextdecoration — Specifies a decorationGmagickDraw::settextencoding — Specifies specifies the text code set

3.GmagickPixel 类

GmagickPixel::__construct — The GmagickPixel constructorGmagickPixel::getcolor — Returns the colorGmagickPixel::getcolorcount — Returns the color count associated with this colorGmagickPixel::getcolorvalue — Gets the normalized value of the provided color channelGmagickPixel::setcolor — Sets the colorGmagickPixel::setcolorvalue — Sets the normalized value of one of the channels
标签: PHP
相关文章: