Add Image > Expand/Resize Canvas to Fit All Content

I’m often adding pictures that go outside the Canvas and need to include them to the canvas. However, I found no immediate command to expand the canvas to fit such items.

  • Resize Canvas… require manual numerical input. Besides, there is no new Canvas size preview oin the background like Aseprite, so I need measure in advance, guess, or input a very big value to be safe
  • Trim to Selection works nice, but I need to select a Rectangle bigger than necessary to make it work (in addition, since Showing content outside canvas is not implemented, see Show and edit content outside the canvas - #14 by EyeOdin, I cannot see the pictures outside canvas so my rectangle selection is also a guess, unless there is only one picture and I have used the Transform tool on it just before)
  • Trim to Current Layer and Trim to Image Size will not expand the canvas

In addition, after doing Resize Canvas… or Trim to Selection with some margin, I need to reshrink the canvas with an extra Trim to Image Size for instance.

I suggest two commands:

  • Image > Expand Canvas to Fit All Content: only expand canvas, never reduce its size, to fit all content including outside the canvas
  • Image > Resize Canvas to Fit All Content: expand and trim as necessary, so the final canvas is the minimum bounding box containing all elements, whether they were inside or outside the canvas previously

There’s also this Feature Request about “Resize to Current Layer” that has an extensive discussion in it:
Request for Resize to Current Layer function

I’d have the following comments on your initial statements:

Trim to Current Layer does expand the canvas, with the consequence of deleting all content outside the final expanded canvas size.

How is that different from a general ‘Resize Canvas to Fit All Content’ that would either expand or contract the canvas size as needed?

That says that a command called ‘Resize’ performs a ‘trim’ action.
The words ‘Resize’ and ‘Trim’ are normally used for actions with distinct results regarding any removal of content.
A better term would be “Trim Canvas to Fit All Content”

1 Like

it might be possible to do that with a python script.

1 Like

Have you tried to do the following:

  1. Ctrl + Click on layer thumbnail
  2. Image - Trim to selection

This will reshape image such that it will have all the conten of the layer.

I did not try to fiddle with multiple kayers though. I am sure there hase to be a way to select everything from all layers.

Turn off any background layer.
Do New Layer From Visible.
Select Opaque (Replace)
Image → Trim to Selection

2 Likes

+1
I think it would be a nice QoL improvement to have a “Expand Canvas to Fit All Content” option.
(preferably which takes the largest X and Y value among all layers and adjusts the canvas based on those values)

2 Likes

But then you should vote for it, instead of dropping the, at least in this forum, undesirable “+1”.
It is a wasted gesture, and it won’t be counted/taken into account for the “wantedness” of a feature request. So if you want to support a feature request, you should scroll up to the top of the page and use the voting feature on the left side of the topics headline (at least if you view Krita-Artists with LTR-Notation, it should be on the left).

Michelist

1 Like

I suppose you are looking for something like this:
actuator-plugin-02

Is it correct?

3 Likes

What is that button and where did you get it from?

1 Like

It is an icon from Actuator Plugin.
I created a sequence of actions to achieve the result shown in the gif above.

Here are the actions:

3 Likes

I guess “remove layer” must mean Delete?

I’m on Android so I tried doing those steps myself. That was interesting, it worked! :+1:

2 Likes

experience after GIMP:

there is no “Fit Canvas to Layers” function that takes one click. You do it in a few steps:
1

there is no “Crop to Content” function at all:
crop

These things in GIMP for me are routine things that I don’t get distracted by: I do it quickly, without looking, without thinking. In Krita, it is more complicated.

It makes no sense to suggest “just stay in GIMP”. On the GIMP forum, I also write about more successful Krita solutions that should be borrowed.

thank you

2 Likes

It’s Image → Trim to Current Layer
That will resize the canvas to the bounding box of the current layer’s image content and then remove all off-canvas content.
In case there is already off-canvas content that affects the initial resize operation, you can do Image → Trim to Image Size, which will remove all off-canvas content from all layers.

did you watch the GIF in which I reproduce and confirm my argument?

I have several layers. And I need to cover all the layers.
“Image → Trim to Current Layer” leave me one layer.
“Crop to Content” remove the void around all layers.
The “Trim to Current Layer” remove everything and leave just one layer.

these are not just words, it is reproduced and captured on video

I tried to but everything happens too quickly.

I think I may understand what’s happening here (or I may be wrong):
GIMP has variable size layers and the size of a layer can be adjusted in various ways, such as by making it fit the content on it.

Krita has infinite size layers (limited by RAM size and other technical limitations).
The canvas is a rectangular ‘viewing hole’ over the layers.
The canvas size and position relative to the layers can be changed.
The >individual layers scale< and position can be changed relative to the current canvas.
(Edit: I said ‘layers size’, I meant ‘individual layers scale’.)

When you say “Crop to content”, do you mean crop the layer size to its content?
If you do mean that, then the concept of layer size does not exist in krita.

If you mean something different then please produce static screenshots that illustrate the concept of what you are trying to do.

1 Like

You might not have intended it, but that sounds like a really snarky comment aimed at someone who’s trying to help you.

2 Likes

OK, let’s try a regular mp4 video, not a GIF. Can we?

On the forum, we must certainly be able to conveniently exchange objective factual material of what is happening in the programs, in addition to textual descriptions of what we see and think. This will save our total time.
Forum forbids me to upload .mp4.
In two videos I duplicate what was in the GIF.

Link one: fit
Link two: crop

“Crop to Content” this function in GIMP “cuts the emptiness” in the canvas. If the canvas is filled with emptiness - the function will reduce the size of the canvas to the nearest pixel. By “emptiness” in this function is meant 100.0% level of transparency in the alpha channel.
For artists, the function is not so in demand. But it is very much in demand for routine image processing in internet. There is no such functionality in Krita yet.

Krita’s “Trim to Image Size” is a simple function that will just clear all data outside of the convas. It doesn’t do anything else. It does not change the canvas size.

The conditional solution is to preliminarily merge the layers in one layer. And then “trim to layer”. However, combining layers is destructive and irreversible. In the future, you may need to work with each layer separately.

“Trim to Layer” cannot clip to the nearest non-empty pixel. “Crop to Content” can do. Reproducing video: link not able due forum rules for me.
This is not an alternative. The functions are not interchangeable. Such a feature would be a nice addition in Krita, not a replacement for current functionality.

does this deserve to be Featured Requests?

you can make your own python extension to crop as you want if you want also.

1 Like

You can do it with Actuator:

3 Likes