Configure size limits to balance quality and performance in CE.SDK applications.

CE.SDK processes images and videos client-side, which means size limits depend on the user’s GPU capabilities and available memory. Understanding and configuring these limits helps you build applications that deliver high-quality results while maintaining smooth performance across different devices.
This guide covers how to configure the maxImageSize setting, query GPU capabilities, validate export dimensions, and handle size-related errors gracefully.
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 reduces memory usage and improves performance across devices. 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.
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 application’s requirements and target hardware capabilities.
Reading the Current Setting#
To check what maxImageSize value is currently configured:
// Get the current maxImageSize settingconst currentMaxSize = engine.editor.getSetting('maxImageSize');console.log('Current maxImageSize:', currentMaxSize);// Default is 4096 pixelsThis returns the maximum size in pixels as an integer value (e.g., 4096 for the default 4096×4096 limit). You might display this value in your UI to inform users about the current quality settings, or use it to make runtime decisions about asset loading strategies.
Setting a New Value#
Configure maxImageSize to minimize memory usage on constrained devices:
// Configure maxImageSize for different use cases// This must be set BEFORE loading images to ensure they're downscaled
// Low memory devices (mobile, tablets) - use 2048 for safetyengine.editor.setSetting('maxImageSize', 2048);
// High quality (professional workflows, desktop)// engine.editor.setSetting('maxImageSize', 8192);
console.log( 'Updated maxImageSize:', engine.editor.getSetting('maxImageSize'));The setting takes effect immediately for newly loaded images. Images already loaded on the canvas retain their current resolution until reloaded.
Observing Settings Changes#
Subscribe to setting changes to update your UI when maxImageSize is modified:
// Subscribe to settings changes to update UI when maxImageSize changesengine.editor.onSettingsChanged(() => { const newMaxSize = engine.editor.getSetting('maxImageSize'); console.log('maxImageSize changed to:', newMaxSize); // In a real app, update UI here to reflect the new setting});
// The subscription returns an unsubscribe function if you need to clean up later// const unsubscribe = engine.editor.onSettingsChanged(() => { ... });// unsubscribe(); // Call when no longer neededThis callback fires whenever any setting changes through the Settings API. You can use it to update quality indicators in your interface, recalculate memory estimates, or trigger asset reloading with the new size limit.
GPU Capability Detection#
Modern browsers expose GPU capabilities through WebGL, which bounds the images that the device can hold and a color mask export. A PNG, JPEG, WebP, TGA or raw export renders in strips, so the GPU does not bound it. With outputProfileMode or embedProfiles, a PNG, JPEG or WebP export renders in one surface, which getMaxExportSize() bounds.
// Query GPU max texture size to understand export limitsconst canvas = document.createElement('canvas');const gl = canvas.getContext('webgl2') || canvas.getContext('webgl');
if (gl) { const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); console.log('GPU Max Texture Size:', maxTextureSize);
// Most modern GPUs support 4096×4096 to 16384×16384 // Safe baseline is 4096×4096 for universal compatibility}The MAX_TEXTURE_SIZE parameter returns the maximum width or height (in pixels) for a texture on the current GPU. Most modern GPUs support 4096×4096 to 16384×16384, while older or integrated GPUs may be limited to smaller dimensions.
You can use this information to:
- Set conservative
maxImageSizedefaults based on detected capabilities - Show warnings when users attempt a color mask export that exceeds
getMaxExportSize() - Provide quality presets that match the device’s capabilities
- Calculate safe dimensions for a color mask export automatically
Troubleshooting#
Common issues and solutions when working with size limits:
| Issue | Cause | Solution |
|---|---|---|
| Images appear blurry/low quality | maxImageSize too low |
Increase maxImageSize if GPU supports it (query MAX_TEXTURE_SIZE first) |
| Out of memory errors during editing | maxImageSize too high |
Decrease maxImageSize to reduce memory footprint |
| Color mask export fails | Output exceeds getMaxExportSize() |
Reduce export dimensions, or export without a color mask, which renders in strips |
A PNG, JPEG or WebP export with outputProfileMode or embedProfiles fails |
Output exceeds getMaxExportSize(), because such an export renders in one surface |
Reduce export dimensions |
| Video export fails | Resolution/duration too high | Export at 1080p instead of 4K, or reduce video duration to under 2 minutes |
| Inconsistent results across devices | Different GPU capabilities | Set conservative maxImageSize (4096) or detect capabilities programmatically |
| Images load slowly | High maxImageSize on slow hardware |
Lower maxImageSize to reduce processing time, especially on mobile devices |
| Export succeeds but file is too large | No compression applied | Use JPEG format with quality settings, or apply PNG compression options |
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 export 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