1

I have multiple layers (images of a playing card set) that are in different resolution and sizes. I would like to scale all these layers to have the same size. How can I do that?

What I have tried:

  • Using the link tool will scale them all proportinaly but I want them to be the same size.
  • Scaling a layer and then using the repeat last action (ctrl+F) doesn't seem to do anything.
  • I can select multiple layers using the align tool, but I can't scale them using it.
0

1 Answer 1

0

As far as I know, there's no automated way to do this in GIMP using the standard set of tools or operations.

However there is a plugin shown here which might work for you. It scales the currently selected layer to the canvas size. It can be repeated for different layers using Ctrl+F. Special thanks must go to Stack Overflow user: jsbueno for providing the code.

#! /usr/bin/env python
# coding: utf-8

from gimpfu import *

def scale_layer_to_canvas_size(img, layer):
    pdb.gimp_image_undo_group_start(img)
    factor = min (float(img.width) / layer.width,
                 float(img.height) / layer.height)

    layer.scale(int(layer.width * factor), int(layer.height * factor))
    layer.set_offsets((img.width - layer.width) / 2,
        (img.height - layer.height) / 2)
    pdb.gimp_image_undo_group_end(img)

register("scale-layer-to-canvas-size",
    "Scale layer to canvas size",
    "Scales the layer to canvas size, keeping the aspect ratio",
    "João S. O. Bueno", "Public domain", "2014",
    N_("Scale layer to canvas size..."),
    "*",
    [(PF_IMAGE, "image",       "Input image", None),
     (PF_DRAWABLE, "layer", "Input drawable", None), ], [],
    scale_layer_to_canvas_size,  menu="<Image>/Layer/",
    )

main()

Copy and paste the python code into a text file, change the extension to .py and put it in your Plugins folder in GIMP, and restart GIMP.

You will find a new entry under Layer > Scale Layer to Canvas size.

I tested this with GIMP 2.10. Seems to work perfectly. I'm not entirely sure if will do everything you what you want though. If the images don't all have the same aspect ratio, you may have to crop it after doing the scaling.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.