Show:

Q_Image Class

Module: Q

Q Image class

Item Index

Methods

Events

Methods

applyImage

(
  • $base
  • $part
)
private static

Helper function for building a wavatar. This loads an image and adds it to our composite using the given color values.

Parameters:

  • $base GDImageLink
  • $part String

avatar

(
  • $hash
  • [$size=Q_AVATAR_SIZE]
  • [$type='wavatar']
  • [$gravatar=false]
)
GDImageLink static

Returns png avatar image. Can check gravatar.com for avatar

Parameters:

  • $hash String

    The md5 hash to build avatar

  • [$size=Q_AVATAR_SIZE] Integer optional

    Avatar size in pixels

  • [$type='wavatar'] Object optional

    Type of avatar - one of 'wavatar', 'monster', 'imageid'

  • [$gravatar=false] Boolean optional

Returns:

GDImageLink:

buildIAvatar

(
  • $hash
  • $size
)
GDImageLink private static

Builds the avatar.

Parameters:

  • $hash Integer
  • $size Integer

Returns:

GDImageLink:

buildIAvatar

(
  • $hash
  • $size
)
GDImageLink private static

Builds the avatar.

Parameters:

  • $hash Integer
  • $size Integer

Returns:

GDImageLink:

buildWAvatar

(
  • $hash
  • $size
)
GDImageLink private static

Builds the avatar.

Parameters:

  • $hash Integer
  • $size Integer

Returns:

GDImageLink:

getCenter

(
  • $shape
  • $fR
  • $fG
  • $fB
  • $bR
  • $bG
  • $bB
  • $usebg
)
GDImageLink private static

generate sprite for center block

Parameters:

  • $shape Integer
  • $fR Integer
  • $fG Integer
  • $fB Integer
  • $bR Integer
  • $bG Integer
  • $bB Integer
  • $usebg Integer

Returns:

GDImageLink:

getSprite

(
  • $shape
  • $R
  • $G
  • $B
  • $rotation
)
GDImageLink private static

generate sprite for corners and sides

Parameters:

  • $shape Integer
  • $R Integer
  • $G Integer
  • $B Integer
  • $rotation Integer

Returns:

GDImageLink:

hsl2rgb

(
  • $h
  • $s
  • $l
)
Array private static

Handy function for converting hus/sat/lum color values to RGB, which makes it very easy to generate random-yet-still-vibrant colors

Parameters:

  • $h Integer
  • $s Integer
  • $l Integer

Returns:

Array:

RGB vlue as array($R, $G, $B)

put

(
  • $filename
  • $hash
  • [$size=Q_AVATAR_SIZE]
  • [$type='wavatar']
  • [$gravatar=false]
)
GDImageLink static

Saves an avatar image, in a certain size. Can check gravatar.com for avatar

Parameters:

  • $filename String

    The name of image file

  • $hash String

    The md5 hash to build avatar

  • [$size=Q_AVATAR_SIZE] Integer optional

    Avatar size in pixels

  • [$type='wavatar'] String optional

    Type of avatar - one of 'wavatar', 'monster', 'imageid'

  • [$gravatar=false] Boolean optional

Returns:

GDImageLink:

resize

(
  • $in_filename
  • $out_filename
  • $sizes
)
Boolean static

Resizes an image file and saves it as another file

Parameters:

  • $in_filename String

    The filename of image to load.

  • $out_filename String

    Where to save the result. The extension determines the file type to save.

  • $sizes Array

    An array of options, including: "width": this lets you specify the width of the result "height": this lets you specify the height of the result "width_max": this lets you specify the max width of the result "height_max": this lets you specify the max height of the result

Returns:

Boolean:

Whether the result was saved successfully

save

(
  • $params
  • [$params.save=array("x"
)
Array static

Saves an image, usually sent by the client, in one or more sizes.

Parameters:

  • $params Array
    • [data] String optional

      the image data

    • [path="uploads"] String optional

      parent path under web dir (see subpath)

    • [subpath=""] String optional

      subpath that should follow the path, to save the image under

    • [merge=""] String optional

      path under web dir for an optional image to use as a background

    • [crop] String optional

      array with keys "x", "y", "w", "h" to crop the original image

    • [skipAccess=false] String optional

      if true, skips the check for authorization to write files there

  • [$params.save=array("x" String

    => "")] array of $size => $basename pairs where the size is of the format "WxH", and either W or H can be empty.

Returns:

Array:

an array of ($size => $fullImagePath) pairs

Events

Q/image/save

After

Event Payload:

  • user String
  • path String
  • subpath String
  • writePath String
  • data String