diff --git a/crates/engine/src/cmd/adjust_cmds/replace_color_range.rs b/crates/engine/src/cmd/adjust_cmds/replace_color_range.rs
index c144811812f..3bb6cf312cd 100644
--- a/crates/engine/src/cmd/adjust_cmds/replace_color_range.rs
+++ b/crates/engine/src/cmd/adjust_cmds/replace_color_range.rs
@@ -2,6 +2,8 @@
use photocraft_algo::{selection, tone};
use photocraft_cms::{Builtin, TransformOptions};
use photocraft_doc::SampleType;
+use photocraft_geom::Rect;
+use photocraft_raster::Surface;
use serde_json::Value;
use super::{bad, num};
@@ -9,6 +11,14 @@ use crate::{EngineError, Result, Session};
const CMD: &str = "image.adjustments.replaceColor";
+/// Unstored pixels can still be selected when the mask has a nonzero default.
+fn edit_bounds(content: Rect, selected: Option<&Surface>) -> Rect {
+ match selected {
+ Some(mask) if mask.default_pixel().first() == Some(&0.0) => content.intersect(&mask.content_bounds()),
+ _ => content,
+ }
+}
+
/// Validate original precision before checking order and converting to native f32.
fn bound(p: &Value, key: &str) -> Result<[f64; 3]> {
let values = p.get(key).and_then(Value::as_array).filter(|a| a.len() == 3).ok_or_else(|| bad(CMD, format!("`{key}` must be three finite Lab numbers")))?;
@@ -72,7 +82,7 @@ pub(super) fn apply(s: &mut Session, p: &Value) -> Result