spb/zyquo-cloud Public MIT
Native macOS AI chat client for 12 cloud providers — your keys, every cloud model, one beautiful chat.
Swift 97.4%
Shell 1.7%
Makefile 1%
1#!/usr/bin/swift2//3// rasterize-svg.swift4// Zyquo Cloud5//6// Author: Simon-Pierre Boucher7// Mail: contact@spboucher.ai8//9// Renders an SVG to PNG at a given pixel size using AppKit's native SVG10// support (CoreSVG) — used because librsvg isn't installed on this machine.11// Usage: swift rasterize-svg.swift <in.svg> <out.png> <size>12//1314import AppKit1516let args = CommandLine.arguments17guard args.count == 4, let size = Int(args[3]) else {18 FileHandle.standardError.write(Data("usage: rasterize-svg.swift <in.svg> <out.png> <size>\n".utf8))19 exit(64)20}2122guard let image = NSImage(contentsOfFile: args[1]) else {23 FileHandle.standardError.write(Data("error: cannot load \(args[1])\n".utf8))24 exit(1)25}2627let pixels = CGFloat(size)28guard let rep = NSBitmapImageRep(29 bitmapDataPlanes: nil, pixelsWide: size, pixelsHigh: size,30 bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,31 colorSpaceName: .calibratedRGB, bytesPerRow: 0, bitsPerPixel: 032) else { exit(1) }3334NSGraphicsContext.saveGraphicsState()35NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)36NSGraphicsContext.current?.imageInterpolation = .high37image.draw(38 in: NSRect(x: 0, y: 0, width: pixels, height: pixels),39 from: .zero, operation: .copy, fraction: 140)41NSGraphicsContext.restoreGraphicsState()4243guard let png = rep.representation(using: .png, properties: [:]) else { exit(1) }44try! png.write(to: URL(fileURLWithPath: args[2]))45