Configure size limits to balance quality and performance in headless Node.js workflows.
CE.SDK processes images and videos in server environments using CPU and GPU resources, which means size limits depend on your server’s hardware capabilities and available memory. Understanding and configuring these limits helps you build automation workflows that deliver high-quality results while maintaining efficient resource usage in batch processing, serverless functions, and containerized deployments.
This guide covers how to configure the maxImageSize setting for headless workflows, understand server-side constraints, and implement robust error handling for size-related scenarios in production deployments.
Understanding Size Limits#
CE.SDK manages size limits at two stages: input (when loading images) and output (when exporting). The maxImageSize setting controls input resolution, automatically downscaling images that exceed the configured limit (default: 4096×4096px). This prevents memory issues in serverless functions and containerized environments. A PNG, JPEG, WebP, TGA or raw export renders in strips. Only the side limit of its format bounds it: JPEG 65,500, WebP 16,383 and TGA 65,535 pixels. A larger export in these formats fails before rendering with ENCODE.OUTPUT_SIZE_EXCEEDS_FORMAT_MAX. A buffered export must also give a file under 4 GiB, and otherwise fails with ENCODE.OUTPUT_FILE_EXCEEDS_BUFFER_MAX. A streamed PNG, JPEG or raw export has no such file limit. WebP and TGA hold all pixels until the end, so they need the memory of the whole image. getMaxExportSize() bounds a color mask export and the layers of a PDF. It also bounds a PNG, JPEG or WebP export with outputProfileMode or embedProfiles, because such an export renders in one surface. Available RAM and the deployment environment (serverless memory limits, container quotas, VM allocations) still apply to the strips. When @cesdk/node runs the WASM engine, it uses software rendering with conservative limits. The native engine renders on the GPU where available.
Resolution & Duration Limits#
| Constraint | Recommendation / Limit |
|---|---|
| Input Resolution | Maximum input resolution is 4096×4096 pixels. Images from external sources (e.g., Unsplash) are resized to this size before rendering on the canvas. You can modify this value using the maxImageSize setting. |
| Output Resolution | A PNG, JPEG, WebP, TGA or raw export renders in strips. Only its format limits each side: JPEG 65,500, WebP 16,383 and TGA 65,535 pixels. A buffered export must also give a file under 4 GiB. A color mask export and the layers of a PDF stay within getMaxExportSize(). So does a PNG, JPEG or WebP export with outputProfileMode or embedProfiles. |
All image processing in CE.SDK happens on the device running the engine, so the input limit depends on the maximum texture size supported by its hardware. The default limit of 4096×4096 is a safe baseline that works universally. Higher input resolutions (e.g., 8192×8192) may work on certain devices but could fail on others. WebP and TGA exports hold all pixels until the end, so they also need the memory of the whole image.
| Constraint | Recommendation / Limit |
|---|---|
| Resolution | Up to 4K UHD is supported for playback and export, depending on the user’s hardware and available GPU resources. For import, CE.SDK does not impose artificial limits, but maximum video size is bounded by available memory: WASM-based builds (the browser and the WASM engine of @cesdk/node) are limited by the 32-bit address space of WebAssembly (wasm32) and, in the browser, by the engine’s memory limit (4 GB on desktop, 2 GB on phones and tablets), while native builds such as the native engine of @cesdk/node can use the full process memory. |
| Frame Rate | 30 FPS at 1080p is broadly supported; 60 FPS and high-res exports benefit from hardware acceleration |
| Duration | Stories and reels of up to 2 minutes are fully supported. Longer videos are also supported, but we generally found a maximum duration of 10 minutes to be a good balance for a smooth editing experience and a pleasant export duration of around one minute on modern hardware. |
Configuring maxImageSize#
You can read and modify the maxImageSize setting using the Settings API to match your server infrastructure and automation requirements.
Reading the Current Setting#
To check what maxImageSize value is currently configured:
// Read the current maxImageSize settingconst currentMaxImageSize = engine.editor.getSetting('maxImageSize');console.log(`Current maxImageSize: ${currentMaxImageSize}px`);// Default is 4096 pixels - safe baseline for universal compatibilityThis returns the maximum size in pixels as an integer value (e.g., 4096 for the default 4096×4096 limit). You might log this value during server startup to verify configuration, use it to make runtime decisions about asset loading strategies, or include it in diagnostics when troubleshooting export failures.
Setting a New Value#
Configure maxImageSize to minimize memory usage in serverless and containerized environments:
// Configure maxImageSize for low memory environments// This must be set BEFORE loading images to ensure they're downscaledengine.editor.setSetting('maxImageSize', 2048);console.log( `Updated maxImageSize: ${engine.editor.getSetting('maxImageSize')}px`);The setting takes effect immediately for newly loaded images. Images already loaded in the scene retain their current resolution until reloaded.
Observing Settings Changes#
Subscribe to setting changes to log configuration updates or trigger automation workflows:
// Subscribe to settings changes to react to configuration updatesconst unsubscribe = engine.editor.onSettingsChanged(() => { const newMaxImageSize = engine.editor.getSetting('maxImageSize'); console.log(`maxImageSize changed to: ${newMaxImageSize}px`);});This callback fires whenever any setting changes through the Settings API. You can use it to log configuration changes for auditing, update internal metrics tracking, or synchronize settings across distributed processing nodes.
GPU Capability Detection#
In server environments, rendering capabilities depend on the available hardware rather than browser-based WebGL. The native engine of @cesdk/node automatically selects the best available rendering backend (GPU via Metal or EGL, with CPU fallback), configurable via the device option.
When @cesdk/node runs the WASM engine, it uses software rendering with conservative limits that provide universal compatibility. The native engine uses hardware acceleration on servers with GPU access for faster processing. On the GPU, an export side may not exceed editor.getMaxExportSize(), so pass device: 'cpu' for a larger export.
You can use this information to:
- Set conservative
maxImageSizedefaults based on your server’s hardware specifications - Configure different limits for serverless functions vs. dedicated GPU servers
- Implement automatic fallback to lower resolutions when memory is constrained
- Calculate safe export dimensions based on available RAM and processing time limits
For production deployments, test your specific server configuration to determine optimal size limits that balance quality with resource constraints.
Troubleshooting#
Common issues and solutions when working with size limits in server environments:
| Issue | Cause | Solution |
|---|---|---|
| Images appear blurry in exports | maxImageSize too low |
Increase maxImageSize if server memory supports it (test with monitoring) |
| Out of memory errors during processing | maxImageSize too high |
Decrease maxImageSize to reduce memory footprint, or increase server memory allocation |
| Export fails silently | Output exceeds rendering backend limits | Reduce export dimensions or test server’s actual rendering capabilities |
| Serverless function timeout | Export takes too long for large images | Lower maxImageSize to 2048, reduce export dimensions, or use dedicated server |
| Inconsistent results across nodes | Different server configurations | Set conservative maxImageSize (4096) or normalize infrastructure |
| Batch processing runs out of memory | Concurrent exports exceed available RAM | Process sequentially, reduce maxImageSize, or increase server memory |
| Container OOM killed | Export exceeds container memory limit | Increase container memory quota or reduce maxImageSize |
API Reference#
Core methods for managing size limits and export operations:
| Method | Description |
|---|---|
engine.editor.getSetting() |
Retrieves the current value of a setting |
engine.editor.setSetting() |
Updates a setting value |
engine.editor.onSettingsChanged() |
Subscribes to setting change events |
engine.block.export() |
Exports a block as an image or video |
engine.block.getWidth() |
Gets the width of a block in pixels |
engine.block.getHeight() |
Gets the height of a block in pixels |
Next Steps#
Explore related guides to build complete server automation workflows:
- Settings Guide - Complete Settings API reference and configuration options
- File Format Support - Supported image and video formats with capabilities
- Export Overview - Fundamentals of exporting images and videos from CE.SDK
- Export to PDF - PDF export guide with multi-page support and print optimization