Search Docs
Loading...
Skip to content

Size Limits

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

5 mins
estimated time
GitHub

CE.SDK processes images and videos on the device, so size limits depend on the available memory and the device’s rendering hardware. Tuning these limits keeps memory use predictable on smaller devices while still letting capable devices export at high resolution.

This guide covers reading and writing the maxImageSize setting, observing setting changes, querying the device’s maximum export size, and handling export failures.

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 and downscales images that exceed the configured limit before they reach the canvas. The default is 4096×4096 pixels, which keeps memory use predictable on a wide range of devices.

Export resolution is limited by the device’s rendering hardware and available memory. 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 on capable devices, bounded by GPU texture size and available memory. For import, CE.SDK does not impose artificial limits, but maximum video size is bounded by available device memory and the native media framework’s decoder capabilities. The maximum export dimension varies by device and can be queried via engine.editor.getMaxExportSize().
Frame Rate 30 FPS at 1080p is broadly supported; 60 FPS and high-resolution exports benefit from hardware acceleration via the device’s native media frameworks.
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#

Read and modify maxImageSize through the Settings API. The setting is an integer (pixels), so use the Int accessors on engine.editor.

Reading the Current Setting#

To check the value currently in effect:

let currentMaxImageSize = try engine.editor.getSettingInt("maxImageSize")
// The default value is 4096 pixels.

The default is 4096. Read this value at startup to surface it in your UI, or to make runtime decisions about asset loading.

Setting a New Value#

Apply a new limit before loading images so newly loaded textures are downscaled to the new size:

// Lower the limit on memory-constrained devices. Apply this before loading
// images so newly loaded textures are downscaled to the new limit.
try engine.editor.setSettingInt("maxImageSize", value: 2048)
// Or raise it for high-quality workflows on capable devices:
// try engine.editor.setSettingInt("maxImageSize", value: 8192)

Images already on the canvas keep their loaded resolution until they are reloaded. Lower values reduce memory pressure on phones and tablets; higher values preserve detail on desktops and higher-end devices.

Observing Settings Changes#

Subscribe to settings changes through the onSettingsChanged async stream. The stream emits Void on every setting change, so read the value back inside the loop:

// Observe settings changes via an AsyncStream and react to new values. Cancel
// the task to unsubscribe.
let observation = Task {
for await _ in engine.editor.onSettingsChanged {
let newMaxImageSize = try engine.editor.getSettingInt("maxImageSize")
_ = newMaxImageSize
}
}
// ...
observation.cancel()

A Combine variant is also available as engine.editor.onSettingsChangedPublisher. Cancel the consuming Task (or the Combine subscription) to unsubscribe.

Device Export Capabilities#

The maximum export size on the current device is exposed directly:

// The engine reports the maximum export size supported on the current device.
// The value is an upper bound of at most 23170 px. Exports may still fail
// for memory or other reasons.
let maxExportSize = try engine.editor.getMaxExportSize()

getMaxExportSize() returns the limit in pixels for both sides of a color mask export and of the images, gradients and effects that a PDF export draws as pixels. The value is the GPU limit of the device, but never more than 23,170 px. A PNG, JPEG, WebP, TGA or raw export renders in strips, so this value does not bound it. A PNG, JPEG or WebP export with outputProfileMode or embedProfiles renders in one surface, so this value bounds it. The reported value is an upper bound: exports may still fail for memory reasons even when both dimensions are below it.

Use the value to:

  • Cap export presets to dimensions the device can render
  • Warn users when a requested export exceeds the device limit
  • Pick a conservative default maxImageSize for the device class

You can also pre-validate a planned color mask export against the limit. getWidth(_:) and getHeight(_:) only return absolute pixel values when the scene’s design unit is .px and the block’s size mode is .absolute. With .percent the value is a fraction of the parent’s size; with .auto it is derived from the block’s content. Verify both before comparing to getMaxExportSize():

// getWidth/getHeight only return absolute pixel values when the scene's
// design unit is .px AND the block's size mode is .absolute. With .percent
// the value is a fraction of the parent's size; with .auto it is derived
// from the block's content. Check both before comparing to the pixel-based
// device limit.
let designUnit = try engine.scene.getDesignUnit()
let widthMode = try engine.block.getWidthMode(page)
let heightMode = try engine.block.getHeightMode(page)
if designUnit == .px, widthMode == .absolute, heightMode == .absolute {
let pageWidth = try engine.block.getWidth(page)
let pageHeight = try engine.block.getHeight(page)
let withinLimit = Int(pageWidth.rounded(.up)) <= maxExportSize
&& Int(pageHeight.rounded(.up)) <= maxExportSize
_ = withinLimit
}

Handling Export Errors#

engine.block.export(_:mimeType:options:) is async throws, so wrap it in a do/catch block and provide a fallback when an export fails. A practical recovery is to lower maxImageSize, then retry with smaller targetWidth/targetHeight values:

// Catch export errors so the app can recover. Common remediations are
// lowering targetWidth/targetHeight or reducing maxImageSize.
// ExportOptions.targetWidth/targetHeight are always in pixels.
do {
let pngData = try await engine.block.export(page, mimeType: .png)
_ = pngData
} catch {
try engine.editor.setSettingInt("maxImageSize", value: 2048)
let retryOptions = ExportOptions(targetWidth: 1920, targetHeight: 1080)
let retryData = try await engine.block.export(page, mimeType: .png, options: retryOptions)
_ = retryData
}

This pattern lets the app keep delivering an export even when the first attempt is too large for the current device or memory pressure is high.

Troubleshooting#

Issue Cause Solution
Images appear blurry on the canvas maxImageSize is below the source resolution Raise maxImageSize if the device has the memory headroom
Out-of-memory crashes during editing maxImageSize is too high for the device Lower maxImageSize, especially on phones and tablets
Export throws unexpectedly A side exceeds the limit of its format, a buffered file exceeds 4 GiB, or a color mask export, or an export with outputProfileMode or embedProfiles, exceeds getMaxExportSize() Reduce targetWidth/targetHeight, or stream a PNG, JPEG or raw export
Video export fails Resolution or duration exceeds device capability Export at 1080p instead of 4K, or shorten the video
Inconsistent results across devices Different rendering hardware Set a conservative maxImageSize (4096) and gate larger color mask exports on getMaxExportSize()

API Reference#

Method Description
engine.editor.getSettingInt(_:) Reads an integer setting (e.g. maxImageSize)
engine.editor.setSettingInt(_:value:) Updates an integer setting
engine.editor.onSettingsChanged AsyncStream<Void> that emits when any setting changes
engine.editor.getMaxExportSize() Returns the device’s maximum export dimension in pixels
engine.block.export(_:mimeType:options:) Exports a block as image data
engine.block.getWidth(_:) / getHeight(_:) Returns block dimensions in the scene’s design unit. Values are absolute only when the size mode is .absolute; .percent returns a parent-relative fraction and .auto returns a content-derived value
engine.block.getWidthMode(_:) / getHeightMode(_:) Returns the size mode (.absolute, .percent, or .auto) used for the dimension
engine.scene.getDesignUnit() / setDesignUnit(_:) Reads or sets the scene’s design unit

Next Steps#

Explore related guides to build complete export workflows: