Fix Fit to Frame: resize canvas to match output dimensions
The fitted image was processed and inserted correctly but the canvas (config.WIDTH/HEIGHT) was never updated, so the result was clipped to the original canvas size. Now wraps both new-layer and replace-layer paths in Prepare_canvas_action + Update_config_action so the canvas expands (or shrinks) to the target frame size automatically. https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
This commit is contained in:
@@ -164,26 +164,41 @@ class Image_frame_fit_class {
|
|||||||
resultCanvas.height = img.naturalHeight;
|
resultCanvas.height = img.naturalHeight;
|
||||||
resultCanvas.getContext('2d').drawImage(img, 0, 0);
|
resultCanvas.getContext('2d').drawImage(img, 0, 0);
|
||||||
|
|
||||||
|
var fitW = img.naturalWidth;
|
||||||
|
var fitH = img.naturalHeight;
|
||||||
|
|
||||||
if (params.new_layer) {
|
if (params.new_layer) {
|
||||||
var dataURL = img.src;
|
var dataURL = img.src;
|
||||||
app.State.do_action(
|
app.State.do_action(
|
||||||
new app.Actions.Bundle_action('frame_fit_layer', 'Fit to Frame', [
|
new app.Actions.Bundle_action('frame_fit_layer', 'Fit to Frame', [
|
||||||
|
new app.Actions.Prepare_canvas_action('undo'),
|
||||||
|
new app.Actions.Update_config_action({
|
||||||
|
WIDTH: fitW,
|
||||||
|
HEIGHT: fitH,
|
||||||
|
}),
|
||||||
new app.Actions.Insert_layer_action({
|
new app.Actions.Insert_layer_action({
|
||||||
name: `${frameKey} fit`,
|
name: `${frameKey} fit`,
|
||||||
type: 'image',
|
type: 'image',
|
||||||
data: dataURL,
|
data: dataURL,
|
||||||
x: 0, y: 0,
|
x: 0, y: 0,
|
||||||
width: img.naturalWidth,
|
width: fitW,
|
||||||
height: img.naturalHeight,
|
height: fitH,
|
||||||
width_original: img.naturalWidth,
|
width_original: fitW,
|
||||||
height_original: img.naturalHeight,
|
height_original: fitH,
|
||||||
})
|
}),
|
||||||
|
new app.Actions.Prepare_canvas_action('do'),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
app.State.do_action(
|
app.State.do_action(
|
||||||
new app.Actions.Bundle_action('frame_fit', 'Fit to Frame', [
|
new app.Actions.Bundle_action('frame_fit', 'Fit to Frame', [
|
||||||
new app.Actions.Update_layer_image_action(resultCanvas)
|
new app.Actions.Prepare_canvas_action('undo'),
|
||||||
|
new app.Actions.Update_config_action({
|
||||||
|
WIDTH: fitW,
|
||||||
|
HEIGHT: fitH,
|
||||||
|
}),
|
||||||
|
new app.Actions.Update_layer_image_action(resultCanvas),
|
||||||
|
new app.Actions.Prepare_canvas_action('do'),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user