From 4ba295db37e1d42a2db116eb23fe2344c6cfe6e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 02:20:07 +0000 Subject: [PATCH] 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 --- frontend/src/js/modules/image/frame_fit.js | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/frontend/src/js/modules/image/frame_fit.js b/frontend/src/js/modules/image/frame_fit.js index cfcd1fa..81ac049 100644 --- a/frontend/src/js/modules/image/frame_fit.js +++ b/frontend/src/js/modules/image/frame_fit.js @@ -164,26 +164,41 @@ class Image_frame_fit_class { resultCanvas.height = img.naturalHeight; resultCanvas.getContext('2d').drawImage(img, 0, 0); + var fitW = img.naturalWidth; + var fitH = img.naturalHeight; + if (params.new_layer) { var dataURL = img.src; app.State.do_action( 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({ name: `${frameKey} fit`, type: 'image', data: dataURL, x: 0, y: 0, - width: img.naturalWidth, - height: img.naturalHeight, - width_original: img.naturalWidth, - height_original: img.naturalHeight, - }) + width: fitW, + height: fitH, + width_original: fitW, + height_original: fitH, + }), + new app.Actions.Prepare_canvas_action('do'), ]) ); } else { app.State.do_action( 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'), ]) ); }