Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion Layer Scale #16

Closed
R0CH1TV opened this issue Dec 1, 2024 · 14 comments
Closed

Suggestion Layer Scale #16

R0CH1TV opened this issue Dec 1, 2024 · 14 comments
Labels
enhancement New feature or request

Comments

@R0CH1TV
Copy link

R0CH1TV commented Dec 1, 2024

Hello, maybe you can add option to resize scale based on canvas size...

Example

My canvas size is 40x20
image

My layers have different size
Original size
Layer1: 548x141
image
Layer2: 236x182
image

Resized
Layer1: 40x10 (fit on canvas size)
image

Layer2: 40x31 (exceed canvas size on height 31px) so you need resize by Height
image

Resize by height then (keeping scale ratio)
image

So basically you always try to resize by the largest value, but if the height or width still exceeds the canvas size, you resize whatever is exceeding it, but always maintaining the proportion.

@kamilburda kamilburda added the enhancement New feature or request label Dec 1, 2024
@kamilburda kamilburda added this to the 1.0 milestone Dec 1, 2024
@kamilburda
Copy link
Owner

kamilburda commented Dec 1, 2024

As I understand it, you're requesting "scale to fit" while also preserving the aspect ratio. I'll add this option in the next version. 🙂

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 1, 2024

As I understand it, you're requesting "scale to fit" while also preserving the aspect ratio. I'll add this option in the next version. 🙂

Yes, basically... but you always try to resize it by the largest value first, but if it is still larger than the canvas sizes, you try the other value.

Canvas Size: 40x20

Example:

Width: 500
Height: 350

but if you put width at : 40 and the height is 25
you need to resize the height to 20 and the width will be 35

that was just an example, sorry for the somewhat confusing explanation.

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 2, 2024

As I understand it, you're requesting "scale to fit" while also preserving the aspect ratio. I'll add this option in the next version. 🙂

Sorry for too many questions, and this annoying question, you have any ETA for new version?

@kamilburda
Copy link
Owner

Sorry for too many questions, and this annoying question

No worries 🙂

you have any ETA for new version?

I am in the middle of adding a major new feature to the plug-in, and that will take quite a while - possibly 1-2 months.

However, scaling to fit and keeping aspect ratio are actually quite useful features, and can be done fairly quickly, and I suppose I could drop a minor release before 1.0. I can't promise any exact ETA due to other commitments, though (such as my job 😅), but I'd wager it'd be some time before the holidays.

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 3, 2024

Sorry for too many questions, and this annoying question

No worries 🙂

you have any ETA for new version?

I am in the middle of adding a major new feature to the plug-in, and that will take quite a while - possibly 1-2 months.

However, scaling to fit and keeping aspect ratio are actually quite useful features, and can be done fairly quickly, and I suppose I could drop a minor release before 1.0. I can't promise any exact ETA due to other commitments, though (such as my job 😅), but I'd wager it'd be some time before the holidays.

I understand you !
would be very nice if you able to drop this feature when you have time this will help me a lot xD
but thank you !

@kamilburda
Copy link
Owner

I just released a new version containing the new scaling features. To fit each layer to the image canvas:

  1. Set the New width to 100 and the Unit for width to % of image width.
  2. Set the New height to 100 and the Unit for height to % of image height.
  3. Check Scale to fit.

Of course, if you need to specify other dimensions representing the canvas, such as 40 x 20, that can be done as well. Simply change the units to pixels and set the New width and height to 40 and 20, respectively.

However, there may be one problem with this approach - after the scaling, some parts of the layer may be displayed outside the image canvas. If you only want to export the layers using their dimensions (and not the image dimensions), simply check Use layer size if not already. Otherwise, you'll need to set layer offsets via a custom procedure (gimp-layer-set-offsets). However, if you need to use different values than pixels (e.g. center the layer with respect to the image canvas), this cannot currently be done, unless you find a custom script/plug-in that can then be inserted as a custom procedure in Batcher.

@kamilburda kamilburda removed this from the 1.0 milestone Dec 7, 2024
@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 7, 2024

I just released a new version containing the new scaling features. To fit each layer to the image canvas:

  1. Set the New width to 100 and the Unit for width to % of image width.
  2. Set the New height to 100 and the Unit for height to % of image height.
  3. Check Scale to fit.

Of course, if you need to specify other dimensions representing the canvas, such as 40 x 20, that can be done as well. Simply change the units to pixels and set the New width and height to 40 and 20, respectively.

However, there may be one problem with this approach - after the scaling, some parts of the layer may be displayed outside the image canvas. If you only want to export the layers using their dimensions (and not the image dimensions), simply check Use layer size if not already. Otherwise, you'll need to set layer offsets via a custom procedure (gimp-layer-set-offsets). However, if you need to use different values than pixels (e.g. center the layer with respect to the image canvas), this cannot currently be done, unless you find a custom script/plug-in that can then be inserted as a custom procedure in Batcher.

Really good job working amazing...
But like you said now my problem layers not centralized on canvas anymore,
it's hard to add option do "centralized" on canvas after resize?

@kamilburda
Copy link
Owner

kamilburda commented Dec 7, 2024

I have a Python script available for aligning layers: https://github.com/kamilburda/gimp-align-layers

I just updated it to work with GIMP 3. You can install it as any other GIMP plug-in/script. First restart GIMP so that the plug-in is registered, then in Batcher, find and add the python-fu-align-layers as a custom procedure. There you can adjust how to align the current layer - keep, left/top, center, right/bottom. You can apply additional offsets if needed.

You can ignore the reference layer (unless you inserted e.g. a background layer and would want to align the current layer against the background).

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 7, 2024

I have a Python script available for aligning layers: https://github.com/kamilburda/gimp-align-layers

I just updated it to work with GIMP 3. You can install it as any other GIMP plug-in/script. First restart GIMP so that the plug-in is registered, then in Batcher, find and add the python-fu-align-layers as a custom procedure. There you can adjust how to align the current layer - keep, left/top, center, right/bottom. You can apply additional offsets if needed.

You can ignore the reference layer (unless you inserted e.g. a background layer and would want to align the current layer against the background).

Sure i added and selected but i getting error

image

My settings

image

Folder scripts

image
Console gimp
image

@kamilburda
Copy link
Owner

kamilburda commented Dec 7, 2024

That's the plug-in-align-layers plug-in. You'll need to add python-fu-align-layers. I should probably have named my script differently. 😅

plug-in-align-layers can work if you have more 2 or more layers in the current image. However, since Batcher processes each layer separately, there is always only one layer in the image (unless you have a background/foreground).

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 7, 2024

That's the plug-in-align-layers plug-in. You'll need to add python-fu-align-layers. I should probably have named my script differently 😅

image

LOL problem i can't find that for some reason....
though console doesn't show any errors to load the script ,

image

Folder
image

Console:
image

@kamilburda
Copy link
Owner

Check if you have the scripts folder among the plug-ins folders. Also, you need to restart GIMP if you did not do so already.

@R0CH1TV
Copy link
Author

R0CH1TV commented Dec 7, 2024

worked thank u !!

@kamilburda
Copy link
Owner

Great, I'm considering this resolved then. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants