SVG Converter API - Ruby Gem

SVG Converter transforms vector SVG files into raster image formats. Convert SVG logos, icons, and illustrations to PNG, JPG, or WebP for use in applications that don't support vector graphics.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_svgconverter'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_svgconverter

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_svgconverter'

# Initialize the client
client = APIVerve::Svgconverter::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  image: "",
  outputFormat: "png",
  quality: 90,
  maxWidth: 1920,
  maxHeight: 1080
})

# Print the response
puts response

File Upload

# Upload a file
response = client.execute_with_file("/path/to/file.jpg")

# Or use a URL
response = client.execute_with_url("https://example.com/image.jpg")

Error Handling

begin
  response = client.execute({ image: "", outputFormat: "png", quality: 90, maxWidth: 1920, maxHeight: 1080 })
  puts response["data"]
rescue APIVerve::Svgconverter::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Svgconverter::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Svgconverter::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "inputFormat": "svg",
    "outputFormat": "png",
    "inputSize": 12456,
    "outputSize": 89012,
    "mimeType": "image/png",
    "expires": 1707350400000,
    "downloadURL": "https://storage.googleapis.com/apiverve/svgconverter/a1b2c3d4.png"
  },
  "code": 200
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.