extends SceneTree ## Renders an SVG to a square PNG, used to package the icon for Linux. ## ## Usage: godot --headless -s render_icon.gd -- func _initialize() -> void: var args: PackedStringArray = OS.get_cmdline_user_args() if args.size() != 3: printerr("Usage: godot --headless -s render_icon.gd -- ") quit(1) return var svg: String = FileAccess.get_file_as_string(args[0]) var source: Image = Image.new() # Load at 1x to read the SVG's own size, then scale so the result is pixels var error: int = source.load_svg_from_string(svg) if error == OK: var image: Image = Image.new() error = image.load_svg_from_string(svg, float(args[2]) / source.get_width()) if error == OK: error = image.save_png(args[1]) if error != OK: printerr("Could not render %s to %s (error %d)" % [args[0], args[1], error]) quit(error)