-
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
textThe string to render.
fromThe basepoint (roughly the lower left corner) of the first letter.
fontListA list of font filenames to look for. The first match will be used.
colorThe font color.
sizeThe height of the font in typographical points (pt).
angleThe 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
Imageto an indexed palette of colors from larger color spaces. IndexImages only make sense with 2 or more colors, and willthrownonsense valuesDeclaration
Swift
public func reduceColors(max numberOfColors: Int, shouldDither: Bool = true) throwsParameters
numberOfColorsmaximum number of colors
shouldDithertrue 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
Imageinstance from given image data in specified raster format. IfDefaultImportableRasterFormatis omitted, all supported raster formats will be evaluated.Declaration
Swift
public convenience init(data: Data, as format: ImportableFormat = .any) throwsParameters
dataThe image data
rasterFormatThe raster format of image data (e.g. png, webp, …). Defaults to
.any -
Exports the image as
Dataobject in specified raster format.Declaration
Swift
public func export(as format: ExportableFormat = .png) throws -> DataParameters
formatThe raster format of the returning image data (e.g. as jpg, png, …). Defaults to
.pngReturn Value
The image data
View on GitHub