-
Declaration
Swift
public enum FlipMode
-
Declaration
Swift
var internalImage: gdImagePtr!
-
Declaration
Swift
public var size: Size { get }
-
Declaration
Swift
public var transparent: Bool { get set }
-
Declaration
Swift
public enum ImageType
-
Declaration
Swift
public init?(width: Int, height: Int, type: ImageType = .truecolor)
-
Declaration
Swift
public init(gdImage: gdImagePtr)
-
Declaration
Swift
public func resizedTo(width: Int, height: Int, applySmoothing: Bool = true) -> GDImage?
-
Declaration
Swift
public func resizedTo(width: Int, applySmoothing: Bool = true) -> GDImage?
-
Declaration
Swift
public func resizedTo(height: Int, applySmoothing: Bool = true) -> GDImage?
-
Declaration
Swift
public func cropped(to rect: Rectangle) -> GDImage?
-
-
Renders an UTF-8 string onto the image.
The text will be rendered from the specified basepoint:
let basepoint = Point(x: 20, y: 200) image.renderText( “SwiftGD”, from: basepoint, fontList: [“SFCompact”], color: .red, size: 100, angle: .degrees(90) )
Declaration
Parameters
text
The string to render.
from
The basepoint (roughly the lower left corner) of the first letter.
fontList
A list of font filenames to look for. The first match will be used.
color
The font color.
size
The height of the font in typographical points (pt).
angle
The angle to rotate the rendered text from the basepoint perspective. Positive angles rotate clockwise.
Return Value
The rendered text bounding box. You can use this output to render the text off-image first, and then render it again, on the image, with the bounding box information (e.g., to center-align the text).
-
-
-
-
-
-
-
-
-
Declaration
Swift
public func flip(_ mode: FlipMode)
-
Declaration
Swift
public func pixelate(blockSize: Int)
-
Declaration
Swift
public func blur(radius: Int)
-
Declaration
Swift
public func colorize(using color: Color)
-
Declaration
Swift
public func desaturate()
-
Reduces
Image
to an indexed palette of colors from larger color spaces. IndexImage
s only make sense with 2 or more colors, and willthrow
nonsense valuesDeclaration
Swift
public func reduceColors(max numberOfColors: Int, shouldDither: Bool = true) throws
Parameters
numberOfColors
maximum number of colors
shouldDither
true will apply GD’s internal dithering algorithm
-
Declaration
Swift
deinit
-
Declaration
Swift
public convenience init?(url: URL)
-
Declaration
Swift
@discardableResult public func write(to url: URL, quality: Int = 100, allowOverwrite: Bool = false) -> Bool
-
Initializes a new
Image
instance from given image data in specified raster format. IfDefaultImportableRasterFormat
is omitted, all supported raster formats will be evaluated.Declaration
Swift
public convenience init(data: Data, as format: ImportableFormat = .any) throws
Parameters
data
The image data
rasterFormat
The raster format of image data (e.g. png, webp, …). Defaults to
.any
-
Exports the image as
Data
object in specified raster format.Declaration
Swift
public func export(as format: ExportableFormat = .png) throws -> Data
Parameters
format
The raster format of the returning image data (e.g. as jpg, png, …). Defaults to
.png
Return Value
The image data