Image Database Module
The Image Database Module is a core module included in the Carbon modding framework for Rust. It manages downloading, storing, mapping, and reusing images via Rust's FileStorage
system and Carbon’s own identifiers.
Note: This module is built into Carbon and does not require installation like traditional plugins. It is always enabled and cannot be disabled.
Overview
- Class Name:
ImageDatabaseModule
- Enabled by default: Yes
- Force enabled: Yes (cannot be disabled)
- Supports Configuration: No
- Source: Carbon.Common/ImageDatabaseModule
- Forces Modded Tag: No
This module allows plugins to download images from URLs, assign internal keys to them, and reuse them efficiently with caching. It also supports QR code generation.
Accessing the Module in Plugins
var imageDb = Carbon.Base.BaseModule.GetModule<ImageDatabaseModule>();
How It Works
Queue Image
imageDb.Queue("my-key", "https://example.com/image.png");
You can also directly add raw image data:
var imagePath = "carbon/data/someimage.png";
var bytes = File.ReadAllBytes(imagePath);
imageDb.AddImage("my-key", bytes);
Retrieve the stored image ID:
var imageId = imageDb.GetImage("my-key");
QR Code Generation
var qrId = imageDb.GetQRCode("https://carbonmod.gg");
Image Removal
imageDb.DeleteImage("https://example.com/image.png");
Default Images
These default images are queued automatically on startup or can be manually reloaded using the console command imagedb.loaddefaults
:
Example Use in Plugin
imageDb.Queue("logo", "https://mydomain.com/logo.png");
var id = imageDb.GetImage("logo");
For maximum compatibility, always check HasImage(key)
before trying to use it in a UI.