Sign up now! · Forgot password?
RSS/Atom feed identi.ca Twitter

Any way to resize all the layers in an xcf file to fit the canvas?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

Elle Stone
2018-03-11 14:21:45 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

Hi All,

Of course all the layers can be resized one by one to fit the canvas. But I've been doing a *lot* of rearranging/moving of different groups of layers, and clicking on each layer one by one to resize it is rather time-consuming and involves a lot of clicking. Right now that's 17 layers and four groups.

Is there a magic command, or maybe an easy script that can be run to resize all the layers to fit the canvas, all at once?

Also, does the layer mask resize when the layer is resized?

In case it matters, I'm using GIMP 2.9.8 on Linux.

Best, Elle

Carol Spears
2018-03-11 16:06:42 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On Sun, Mar 11, 2018 at 10:21 AM, Elle Stone

wrote:

Hi All,

Of course all the layers can be resized one by one to fit the canvas. But I've been doing a *lot* of rearranging/moving of different groups of layers, and clicking on each layer one by one to resize it is rather time-consuming and involves a lot of clicking. Right now that's 17 layers and four groups.

Is there a magic command, or maybe an easy script that can be run to resize all the layers to fit the canvas, all at once?

It is much much easier to resize the canvas to fit all of the layers.

Also, does the layer mask resize when the layer is resized?

I just tried this and it does. You can try this also, Edit -->Undo is a friend....

carol

Ofnuts
2018-03-11 20:57:21 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 03/11/18 15:21, Elle Stone wrote:

Hi All,

Of course all the layers can be resized one by one to fit the canvas. But I've been doing a *lot* of rearranging/moving of different groups of layers, and clicking on each layer one by one to resize it is rather time-consuming and involves a lot of clicking. Right now that's 17 layers and four groups.

Is there a magic command, or maybe an easy script that can be run to resize all the layers to fit the canvas, all at once?

Also, does the layer mask resize when the layer is resized?

In case it matters, I'm using GIMP 2.9.8 on Linux.

Best, Elle

My trick for this (on 2.8):

- Image>Canvas size and add 1 px, and select "resize all layers"

- Image>Canvas size and remove 1 px, and select "resize all layers"

Otherwise, in the python console:

image=image=gimp.image_list()[0] # or other ways to obtain image

for layer in image.layers: layer.resize_to_image_size()

(strike [enter] twice)

Ofnuts
2018-03-11 21:41:26 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 03/11/18 21:57, Ofnuts wrote:

On 03/11/18 15:21, Elle Stone wrote:

Hi All,

Of course all the layers can be resized one by one to fit the canvas. But I've been doing a *lot* of rearranging/moving of different groups of layers, and clicking on each layer one by one to resize it is rather time-consuming and involves a lot of clicking. Right now that's 17 layers and four groups.

Is there a magic command, or maybe an easy script that can be run to resize all the layers to fit the canvas, all at once?

Also, does the layer mask resize when the layer is resized?

In case it matters, I'm using GIMP 2.9.8 on Linux.

Best, Elle

My trick for this (on 2.8):

- Image>Canvas size and add 1 px, and select "resize all layers"

- Image>Canvas size and remove 1 px, and select "resize all layers"

Otherwise, in the python console:

image=image=gimp.image_list()[0] # or other ways to obtain image

for layer in image.layers: layer.resize_to_image_size()

(strike [enter] twice)

Since I have sen this question asked many times, I made a short script out of it:

See ofn-layers-to-image-size at https://sourceforge.net/projects/gimp-tools/files/scripts/

Elle Stone
2018-03-12 14:03:53 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 03/11/2018 12:06 PM, Carol Spears wrote:

It is much much easier to resize the canvas to fit all of the layers.

All the layers are different sizes, so I don't think this would work, would it? Unless you mean what Ofnuts described, resizing by a pixel, and then resizing again to return to the original canvas size. I never would have thought of that trick.

Also, does the layer mask resize when the layer is resized?

I just tried this and it does. You can try this also, Edit -->Undo is a friend....

Thanks! for checking. Actually I did try, but I couldn't tell what was happening. I should have spent more time experimenting to determine what was really happening.

On 03/11/2018 05:41 PM, Ofnuts wrote:

My trick for this (on 2.8):

- Image>Canvas size and add 1 px, and select "resize all layers"

- Image>Canvas size and remove 1 px, and select "resize all layers"

Otherwise, in the python console:

    image=image=gimp.image_list()[0] # or other ways to obtain image

    for layer in image.layers: layer.resize_to_image_size()

(strike [enter] twice)

Since I have sen this question asked many times, I made a short script out of it:

See ofn-layers-to-image-size at https://sourceforge.net/projects/gimp-tools/files/scripts/

Hi Ofnuts,

Thanks much! for the trick and the script. Hopefully I won't be resizing this particular image any further, but the next time I resize an image I'll figure out how to use the script, or at least will use the trick.

Best, Elle

Joao S. O. Bueno
2018-03-12 14:39:48 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

Hi -your scritp does not seem to account for layer groups (as in, layers inside groups won't be resized).

If they are, it is because layer.resize_to_image_size() in a group also resizes its contents - and it works, but it means that invisible layers inside visible groups will be affected as well.

best regards,

js -> wrote:

On 03/11/18 21:57, Ofnuts wrote:

On 03/11/18 15:21, Elle Stone wrote:

Hi All,

Of course all the layers can be resized one by one to fit the canvas. But I've been doing a *lot* of rearranging/moving of different groups of layers, and clicking on each layer one by one to resize it is rather time-consuming and involves a lot of clicking. Right now that's 17 layers and four groups.

Is there a magic command, or maybe an easy script that can be run to resize all the layers to fit the canvas, all at once?

Also, does the layer mask resize when the layer is resized?

In case it matters, I'm using GIMP 2.9.8 on Linux.

Best, Elle

My trick for this (on 2.8):

- Image>Canvas size and add 1 px, and select "resize all layers"

- Image>Canvas size and remove 1 px, and select "resize all layers"

Otherwise, in the python console:

image=image=gimp.image_list()[0] # or other ways to obtain image

for layer in image.layers: layer.resize_to_image_size()

(strike [enter] twice)

Since I have sen this question asked many times, I made a short script out of it:

See ofn-layers-to-image-size at https://sourceforge.net/projects/gimp-tools/files/scripts/

_______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list

Carol Spears
2018-03-12 14:52:25 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On Mon, Mar 12, 2018 at 10:03 AM, Elle Stone

wrote:

On 03/11/2018 12:06 PM, Carol Spears wrote:

It is much much easier to resize the canvas to fit all of the layers.

All the layers are different sizes, so I don't think this would work,

would it? Unless you mean what Ofnuts described, resizing by a pixel, and then resizing again to return to the original canvas size. I never would have thought of that trick.

Image --> Resize Canvas to Layers

carol

Kevin Cozens
2018-03-12 15:27:45 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 2018-03-12 10:03 AM, Elle Stone wrote:

See ofn-layers-to-image-size at
https://sourceforge.net/projects/gimp-tools/files/scripts/

[snip]

Thanks much! for the trick and the script. Hopefully I won't be resizing this particular image any further, but the next time I resize an image I'll figure out how to use the script, or at least will use the trick.

That script could be worth including as part of what ships with GIMP.

Cheers!

Kevin.

http://www.ve3syb.ca/                | "Nerds make the shiny things that
https://www.patreon.html/KevinCozens | distract the mouth-breathers, and
                                      | that's why we're powerful"
Owner of Elecraft K2 #2172           |
#include       |             --Chris Hardwick
Ofnuts
2018-03-12 23:32:40 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 03/12/18 15:39, Joao S. O. Bueno wrote:

Hi -your scritp does not seem to account for layer groups (as in, layers inside groups won't be resized).

If they are, it is because layer.resize_to_image_size() in a group also resizes its contents - and it works, but it means that invisible layers inside visible groups will be affected as well.

best regards,

js ->

Will ponder this and update the script :)

Elle Stone
2018-03-13 11:46:44 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

Hmm, in GIMP-2.9, in Preferences, under "Dialog Defaults", there is an option to always resize all the layers to the canvas size.

Well, that would solve the problem of resizing the layers to fit the canvas, at least if the canvas is larger than and includes all the content of all the layers. But sometimes layers are offset from the canvas, and have content outside the canvas.

Ofnuts
2018-03-13 12:05:47 UTC (9 months ago)

Any way to resize all the layers in an xcf file to fit the canvas?

On 03/13/18 12:46, Elle Stone wrote:

Hmm, in GIMP-2.9, in Preferences, under "Dialog Defaults", there is an option to always resize all the layers to the canvas size.

Well, that would solve the problem of resizing the layers to fit the canvas, at least if the canvas is larger than and includes all the content of all the layers. But sometimes layers are offset from the canvas, and have content outside the canvas.

As far as I can tell, this is just a default used when you start Image>Canvas size. So, nothing really changed since 2.8.