ruby-libgd is a modern native Ruby binding to the GD Graphics Library — a fast, embeddable raster engine for charts, dashboards, GIS, and scientific graphics.
ruby-libgd provides a native 2D raster graphics engine for Ruby based on the GD C library.
It exposes a complete drawing, text, filtering, composition and image I/O API through the GD::Image class.
| Class | Description |
|---|---|
GD::Image |
Raster image canvas and all drawing, filtering and export operations |
| Method | Description |
|---|---|
GD::Image.new |
Create a new truecolor canvas |
GD::Image.open |
Load an image from disk |
width |
Image width |
height |
Image height |
color |
Allocate a color (RGBA) |
clone |
Duplicate the image |
destroy |
Free image memory |
| Method | Description |
|---|---|
GD::Color.rgb |
Create an RGB color |
GD::Color.rgba |
Create an RGBA color |
GD::Color |
Color model |
| Method | Description |
|---|---|
line |
Draw a straight line |
rectangle |
Draw a rectangle outline |
filled_rectangle |
Draw a filled rectangle |
ellipse |
Draw an ellipse |
filled_ellipse |
Draw a filled ellipse |
circle |
Draw a circle |
filled_circle |
Draw a filled circle |
polygon |
Draw a polygon |
filled_polygon |
Draw a filled polygon |
| Method | Description |
|---|---|
text |
Draw UTF-8 TrueType text |
| Method | Description |
|---|---|
filter |
Apply a GD image filter |
filter("sepia") |
Native sepia tone (ruby-libgd) |
| Method | Description |
|---|---|
crop |
Crop to a new image |
scale |
Resize to a new image |
resize |
Alias for scale |
clone |
Duplicate the image |
| Method | Description |
|---|---|
copy |
Copy a region from another image |
copy_resize |
Copy & resize (optionally resampled) |
| Method | Description |
|---|---|
GD::Image.new |
Create a blank image |
GD::Image.open |
Load from file |
save |
Save to PNG / JPEG / WebP |
to_png |
Encode to PNG and return bytes |