GDImage

public class GDImage

Import & Export

  • 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. If DefaultImportableRasterFormat is omitted, all supported raster formats will be evaluated.

    Throws

    GDError if data in rasterFormat could not be converted

    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.

    Throws

    GDError if the export of self in specified raster format failed.

    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