PHP 클래스 SimpleImage

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details: http://www.gnu.org/licenses/gpl.html
파일 보기 프로젝트 열기: sjardim/Hugopit 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$quality Default output image quality

보호된 프로퍼티들

프로퍼티 타입 설명
$filename
$height
$image
$imagestring
$original_info
$width

공개 메소드들

메소드 설명
__construct ( null | string $filename = null, integer $width = null, integer | null $height = null, null | string $color = null ) : SimpleImage Create instance and load an image, or create an image from scratch
__destruct ( ) Destroy image resource
adaptive_resize ( integer $width, integer | null $height = null ) : SimpleImage Adaptive resize
auto_orient ( ) : SimpleImage Rotates and/or flips an image automatically so the orientation will be correct (based on exif 'Orientation')
best_fit ( integer $max_width, integer $max_height ) : SimpleImage Best fit (proportionally resize to fit in specified width/height)
blur ( string $type = 'selective', integer $passes = 1 ) : SimpleImage Blur
brightness ( integer $level ) : SimpleImage Brightness
colorize ( string $color, float | integer $opacity ) : SimpleImage Colorize
contrast ( integer $level ) : SimpleImage Contrast
create ( integer $width, integer | null $height = null, null | string $color = null ) : SimpleImage Create an image from scratch
crop ( integer $x1, integer $y1, integer $x2, integer $y2 ) : SimpleImage Crop an image
desaturate ( ) : SimpleImage Desaturate (grayscale)
edges ( ) : SimpleImage Edge Detect
emboss ( ) : SimpleImage Emboss
fill ( string $color = '#000000' ) : SimpleImage Fill image with color
fit_to_height ( integer $height ) : SimpleImage Fit to height (proportionally resize to specified height)
fit_to_width ( integer $width ) : SimpleImage Fit to width (proportionally resize to specified width)
flip ( string $direction ) : SimpleImage Flip an image horizontally or vertically
get_height ( ) : integer Get the current height
get_orientation ( ) : string Get the current orientation
get_original_info ( ) : array Get info about the original image
get_width ( ) : integer Get the current width
invert ( ) : SimpleImage Invert
load ( string $filename ) : SimpleImage Load an image
load_base64 ( $base64string ) : SimpleImage Load a base64 string as image
mean_remove ( ) : SimpleImage Mean Remove
opacity ( float | integer $opacity ) Changes the opacity level of the image
output ( null | string $format = null, integer | null $quality = null ) Outputs image without saving
output_base64 ( null | string $format = null, integer | null $quality = null ) : string Outputs image as data base64 to use as img src
overlay ( string $overlay, string $position = 'center', float | integer $opacity = 1, integer $x_offset, integer $y_offset ) : SimpleImage Overlay
pixelate ( integer $block_size = 10 ) : SimpleImage Pixelate
resize ( integer $width, integer $height ) : SimpleImage Resize an image to the specified dimensions
rotate ( integer $angle, string $bg_color = '#000000' ) : SimpleImage Rotate an image
save ( null | string $filename = null, null | integer $quality = null ) : SimpleImage Save an image
sepia ( ) : SimpleImage Sepia
sketch ( ) : SimpleImage Sketch
smooth ( integer $level ) : SimpleImage Smooth
text ( string $text, string $font_file, float | integer $font_size = 12, string $color = '#000000', string $position = 'center', integer $x_offset, integer $y_offset ) : SimpleImage Add text to an image
thumbnail ( integer $width, integer | null $height = null ) : SimpleImage Thumbnail

보호된 메소드들

메소드 설명
file_ext ( string $filename ) : string Returns the file extension of the specified file
get_meta_data ( ) : SimpleImage Get meta data of image or base64 string
imagecopymerge_alpha ( $dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct ) Same as PHP's imagecopymerge() function, except preserves alpha-transparency in 24-bit PNGs
keep_within ( integer | float $value, integer | float $min, integer | float $max ) : integer | float Ensures $value is always within $min and $max range.
normalize_color ( string $color ) : array | boolean Converts a hex color value to its RGB equivalent

메소드 상세

__construct() 공개 메소드

Create instance and load an image, or create an image from scratch
public __construct ( null | string $filename = null, integer $width = null, integer | null $height = null, null | string $color = null ) : SimpleImage
$filename null | string Path to image file (may be omitted to create image from scratch)
$width integer Image width (is used for creating image from scratch)
$height integer | null If omitted - assumed equal to $width (is used for creating image from scratch)
$color null | string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
(is used for creating image from scratch)
리턴 SimpleImage

__destruct() 공개 메소드

Destroy image resource
public __destruct ( )

adaptive_resize() 공개 메소드

This function has been deprecated and will be removed in an upcoming release. Please update your code to use the thumbnail() method instead. The arguments for both methods are exactly the same.
public adaptive_resize ( integer $width, integer | null $height = null ) : SimpleImage
$width integer
$height integer | null If omitted - assumed equal to $width
리턴 SimpleImage

auto_orient() 공개 메소드

Rotates and/or flips an image automatically so the orientation will be correct (based on exif 'Orientation')
public auto_orient ( ) : SimpleImage
리턴 SimpleImage

best_fit() 공개 메소드

Shrink the image proportionally to fit inside a $width x $height box
public best_fit ( integer $max_width, integer $max_height ) : SimpleImage
$max_width integer
$max_height integer
리턴 SimpleImage

blur() 공개 메소드

Blur
public blur ( string $type = 'selective', integer $passes = 1 ) : SimpleImage
$type string selective|gaussian
$passes integer Number of times to apply the filter
리턴 SimpleImage

brightness() 공개 메소드

Brightness
public brightness ( integer $level ) : SimpleImage
$level integer Darkest = -255, lightest = 255
리턴 SimpleImage

colorize() 공개 메소드

Colorize
public colorize ( string $color, float | integer $opacity ) : SimpleImage
$color string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
$opacity float | integer 0-1
리턴 SimpleImage

contrast() 공개 메소드

Contrast
public contrast ( integer $level ) : SimpleImage
$level integer Min = -100, max = 100
리턴 SimpleImage

create() 공개 메소드

Create an image from scratch
public create ( integer $width, integer | null $height = null, null | string $color = null ) : SimpleImage
$width integer Image width
$height integer | null If omitted - assumed equal to $width
$color null | string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
리턴 SimpleImage

crop() 공개 메소드

Crop an image
public crop ( integer $x1, integer $y1, integer $x2, integer $y2 ) : SimpleImage
$x1 integer Left
$y1 integer Top
$x2 integer Right
$y2 integer Bottom
리턴 SimpleImage

desaturate() 공개 메소드

Desaturate (grayscale)
public desaturate ( ) : SimpleImage
리턴 SimpleImage

edges() 공개 메소드

Edge Detect
public edges ( ) : SimpleImage
리턴 SimpleImage

emboss() 공개 메소드

Emboss
public emboss ( ) : SimpleImage
리턴 SimpleImage

file_ext() 보호된 메소드

Returns the file extension of the specified file
protected file_ext ( string $filename ) : string
$filename string
리턴 string

fill() 공개 메소드

Fill image with color
public fill ( string $color = '#000000' ) : SimpleImage
$color string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
리턴 SimpleImage

fit_to_height() 공개 메소드

Fit to height (proportionally resize to specified height)
public fit_to_height ( integer $height ) : SimpleImage
$height integer
리턴 SimpleImage

fit_to_width() 공개 메소드

Fit to width (proportionally resize to specified width)
public fit_to_width ( integer $width ) : SimpleImage
$width integer
리턴 SimpleImage

flip() 공개 메소드

Flip an image horizontally or vertically
public flip ( string $direction ) : SimpleImage
$direction string x|y
리턴 SimpleImage

get_height() 공개 메소드

Get the current height
public get_height ( ) : integer
리턴 integer

get_meta_data() 보호된 메소드

Get meta data of image or base64 string
protected get_meta_data ( ) : SimpleImage
리턴 SimpleImage

get_orientation() 공개 메소드

Get the current orientation
public get_orientation ( ) : string
리턴 string portrait|landscape|square

get_original_info() 공개 메소드

Get info about the original image
public get_original_info ( ) : array
리턴 array
 array(
	width        => 320,
	height       => 200,
	orientation  => ['portrait', 'landscape', 'square'],
	exif         => array(...),
	mime         => ['image/jpeg', 'image/gif', 'image/png'],
	format       => ['jpeg', 'gif', 'png']
)

get_width() 공개 메소드

Get the current width
public get_width ( ) : integer
리턴 integer

imagecopymerge_alpha() 보호된 메소드

Same as PHP's imagecopymerge() function, except preserves alpha-transparency in 24-bit PNGs
protected imagecopymerge_alpha ( $dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct )
$dst_im
$src_im
$dst_x
$dst_y
$src_x
$src_y
$src_w
$src_h
$pct

invert() 공개 메소드

Invert
public invert ( ) : SimpleImage
리턴 SimpleImage

keep_within() 보호된 메소드

If lower, $min is returned. If higher, $max is returned.
protected keep_within ( integer | float $value, integer | float $min, integer | float $max ) : integer | float
$value integer | float
$min integer | float
$max integer | float
리턴 integer | float

load() 공개 메소드

Load an image
public load ( string $filename ) : SimpleImage
$filename string Path to image file
리턴 SimpleImage

load_base64() 공개 메소드

Load a base64 string as image
public load_base64 ( $base64string ) : SimpleImage
리턴 SimpleImage

mean_remove() 공개 메소드

Mean Remove
public mean_remove ( ) : SimpleImage
리턴 SimpleImage

normalize_color() 보호된 메소드

Converts a hex color value to its RGB equivalent
protected normalize_color ( string $color ) : array | boolean
$color string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
리턴 array | boolean

opacity() 공개 메소드

Changes the opacity level of the image
public opacity ( float | integer $opacity )
$opacity float | integer 0-1

output() 공개 메소드

Outputs image without saving
public output ( null | string $format = null, integer | null $quality = null )
$format null | string If omitted or null - format of original file will be used, may be gif|jpg|png
$quality integer | null Output image quality in percents 0-100

output_base64() 공개 메소드

Outputs image as data base64 to use as img src
public output_base64 ( null | string $format = null, integer | null $quality = null ) : string
$format null | string If omitted or null - format of original file will be used, may be gif|jpg|png
$quality integer | null Output image quality in percents 0-100
리턴 string

overlay() 공개 메소드

Overlay an image on top of another, works with 24-bit PNG alpha-transparency
public overlay ( string $overlay, string $position = 'center', float | integer $opacity = 1, integer $x_offset, integer $y_offset ) : SimpleImage
$overlay string An image filename or a SimpleImage object
$position string center|top|left|bottom|right|top left|top right|bottom left|bottom right
$opacity float | integer Overlay opacity 0-1
$x_offset integer Horizontal offset in pixels
$y_offset integer Vertical offset in pixels
리턴 SimpleImage

pixelate() 공개 메소드

Pixelate
public pixelate ( integer $block_size = 10 ) : SimpleImage
$block_size integer Size in pixels of each resulting block
리턴 SimpleImage

resize() 공개 메소드

Resize an image to the specified dimensions
public resize ( integer $width, integer $height ) : SimpleImage
$width integer
$height integer
리턴 SimpleImage

rotate() 공개 메소드

Rotate an image
public rotate ( integer $angle, string $bg_color = '#000000' ) : SimpleImage
$angle integer 0-360
$bg_color string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
리턴 SimpleImage

save() 공개 메소드

The resulting format will be determined by the file extension.
public save ( null | string $filename = null, null | integer $quality = null ) : SimpleImage
$filename null | string If omitted - original file will be overwritten
$quality null | integer Output image quality in percents 0-100
리턴 SimpleImage

sepia() 공개 메소드

Sepia
public sepia ( ) : SimpleImage
리턴 SimpleImage

sketch() 공개 메소드

Sketch
public sketch ( ) : SimpleImage
리턴 SimpleImage

smooth() 공개 메소드

Smooth
public smooth ( integer $level ) : SimpleImage
$level integer Min = -10, max = 10
리턴 SimpleImage

text() 공개 메소드

Add text to an image
public text ( string $text, string $font_file, float | integer $font_size = 12, string $color = '#000000', string $position = 'center', integer $x_offset, integer $y_offset ) : SimpleImage
$text string
$font_file string
$font_size float | integer
$color string
$position string
$x_offset integer
$y_offset integer
리턴 SimpleImage

thumbnail() 공개 메소드

This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified. Useful for generating thumbnails.
public thumbnail ( integer $width, integer | null $height = null ) : SimpleImage
$width integer
$height integer | null If omitted - assumed equal to $width
리턴 SimpleImage

프로퍼티 상세

$filename 보호되어 있는 프로퍼티

protected $filename

$height 보호되어 있는 프로퍼티

protected $height

$image 보호되어 있는 프로퍼티

protected $image

$imagestring 보호되어 있는 프로퍼티

protected $imagestring

$original_info 보호되어 있는 프로퍼티

protected $original_info

$quality 공개적으로 프로퍼티

Default output image quality
public $quality

$width 보호되어 있는 프로퍼티

protected $width