Gimp-Forum.net
How to resize an image so it's content would stay centered? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: How to resize an image so it's content would stay centered? (/Thread-How-to-resize-an-image-so-it-s-content-would-stay-centered)

Pages: 1 2


How to resize an image so it's content would stay centered? - guest273 - 05-29-2022

Hi everyone, guest273 here!

So, I'll try to keep it short:

For a Vegas Pro video project that I'm making I need to adjust an image in a particular way and I was pretty sure that it would be simple to do in gimp. It probably is, but since I use gimp only a couple of times a year I always return to it in a state where I'm struggling with the basics.

So, what I need / want to achieve using gimp:

I want to take this image with a crab logo:
(I'm still not sure which one I'll need - the one with transparency around the crab logo or the one where the logo has transparency).

[attachment=8011]
[attachment=8012]

And instead of it being a square pixel size I want to expand it to an easy to use 16:9 resolution.
I usually double-check resolutions using this website: https://pacoup.com/2011/06/12/list-of-true-169-resolutions/

Currently both of these images are 512x512 pixels. And ideally I'd like to make them either 1920x1080 or an even bigger size such as 3840x2160. Actually it's probably better to keep the image at the pixel size of 1920x1080 & to simply shrink the crab a little bit. What would be a convenient gimp set-up that would let me adjust the image size to my liking if I'd end up needing to resize it again later in such a manner that the crab logo would always end up centered in the middle?


The preferred result that I want to get with this is the crab logo staying centered at the very middle of the canvas both vertically and horizontally. Without the crab logo expanding in such a way that it would try to touch the left/right sides. For starters I'd like the logo to stay as 'big' as it is, but only the canvas to change size. (And if it's too big then change it to be smaller while keeping the same canvas size.) So far every time I've tried to expand the image / canvas the logo would end up either stretched or in a corner...

Edit: This is how I DONT want the image to turn out:
[attachment=8013]

So, why do I need this for my Vegas Pro project? Well, if someone can help me understand how to achieve the effect that I want then I'd have a better understanding of how to adjust the image in gimp first!

In short, I want to use this crab logo image as a custom shape for an iris transition.

An iris transition looks something like this:
https://www.youtube.com/watch?v=CkRmcgLXWug

Except that my iris wouldn't be a circle, it would be this crab outline.

So the way I'd switch from image 1 to image 2 would be that the 2nd image would appear in this crab shaped outline in the center of the image and each frame it would expand for a second until the 2nd image would end up over-taking the whole screen.

So the beginning image of the crab would need to look quite small compared to a 1920x1080 resolution image and then over the span of 1 second it would "grow" to the whole screen. (This would be simply done by me zooming in to the "belly of the crab")

I don't know if there are any people here who also do video editing in Vegas Pro here, but if there are, then I'm currently looking for a help-forum where I could get an answer on how to achieve the effect that I've described.

I hope that someone here can help me with the gimp part and thank you.


RE: How to resize an image so it's content would stay centered? - Krikor - 05-29-2022

I don't know if I understand correctly, but I think what you want is something like:
https://imgur.com/a/S49WNl8

Just create an image at the desired size (1920x1080), and adjust the crab's magnification to fit that dimension.

It is possible to make an animation in Gimp, but I don't know if it would be useful for later editing with your video editor.

https://ibb.co/0nnh0C9

[Image: lYSXXcU.gif]


RE: How to resize an image so it's content would stay centered? - rich2005 - 05-29-2022

I think for the scaling 512x512 (or any WxH) > 1080x1920

1) scale the to the height. Image -> Scale
2) Set the canvas size to 1080x1920 Image -> Canvas Size Center it / Set the fill type

example: https://i.imgur.com/jiAApIW.mp4

I did not quite get your description for the zoom something like Krikors animation or maybe this

https://i.imgur.com/qkkUSoe.mp4

edit: nearly forgot. The image is in Indexed Mode change it to RGB. Image -> Mode -> RGB


RE: How to resize an image so it's content would stay centered? - guest273 - 05-30-2022

Hi Krikor!

Thank you for your response! Smile

Quote:I don't know if I understand correctly, but I think what you want is something like:
https://imgur.com/a/S49WNl8

Just create an image at the desired size (1920x1080), and adjust the crab's magnification to fit that dimension.

Yeah, I'm still trying to figure out the Vegas Pro side of the project so I myself am not really sure what type of crab I'd need...

Anyway, at least the 1920x1080 crab picture might potentially solve the issue of "crab looks too square".


Quote:It is possible to make an animation in Gimp, but I don't know if it would be useful for later editing with your video editor.

https://ibb.co/0nnh0C9

[Image: lYSXXcU.gif]

For me the https://ibb.co/0nnh0C9 isn't loading, but it's just another way to view this gif you've created, right?

YES!
This is exactly what I need! And I can see that you've also used the 16:9 version of the crab!

So in another help-forum a stranger trying to help me made this: (Ignore the black crab)
https://vimeo.com/715191537/5672aa7417

It is the same effect but the square shaped crab has this problem that it doesn't really fill the top part of the screen quickly enough of so if you look closely in the final second of the zoom in it gets centered on the "crabs belly" more.

Anyway, the effect in Vegas Pro might end up taking too many video tracks, so a solid idea now is to make an animation like the one you've made here on gimp. It might even be easier in the end. I already know how the image that would be replaced would look. I might need to slightly adjust the new image that is appearing... wait, you can most likely do basic zoom-ins to adjust the final result in gimp right?

Anyway, here's the images that I would use:
https://imgur.com/a/MXLEXAi

The first image is the old one that is already on the screen from the start. (It might be wise to have like the first 5 or so frames of the animation just be that image with nothing changing so it's easier to integrate into the final video project.)
The 2nd or 3rd image is the one that would appear after the crab zoom in. (It's probably wiser to use the 2nd image & just zoom it in like the 3rd one, incase the zoom-in is too big so it would be easier to re-adjust afterwards.)  (& It also might be wise to have it like that for like an extra 5 or so frames with nothing changing once the transition is done so it's easier to integrate.)

If this ends up looking like I want it to with the addition of sound effects like "are you feeling it now MrKrabs" (from SpongeBob) & a couple of seconds from the 'Crab Rave' song this edit alone would be a banger.

Anyway, how do you do any of this stuff? I only use gimp exclusively to add transparency to images so you might need to explain from scratch.

- guest273.

Hi rich2005!

Thank you for your response! Smile


Quote:edit: nearly forgot. The image is in Indexed Mode change it to RGB.   Image -> Mode -> RGB


Yeah, someone in another forum suggested to me to change the crabs color to white (for easier masking) and I was struggling to figure out why the image was refusing to change colors but I eventually landed on the same conclusion. I'm guessing that indexed mode is a well known headache causer here. Big Grin


Quote:I think for the scaling 512x512 (or any WxH) > 1080x1920

1) scale the to the height.  Image -> Scale
2) Set the canvas size to 1080x1920 Image -> Canvas Size Center it / Set the fill type

example: https://i.imgur.com/jiAApIW.mp4

Ah, so that's how you did it. I was trying to scale directly from 512x512 to 1920x1080.
Oh. There's literally a button that says "center". Now I feel dumb.

Quote:I did not quite get your description for the zoom something like Krikors animation or maybe this

https://i.imgur.com/qkkUSoe.mp4

It's actually like both of your examples combined together.
Where there's already an image on the screen before and a new image has taken the crab outline and expands to fill the whole screen.

The square shaped crab actually has this problem that due to it's shape it takes too long to fill out the whole screen, so that's why I wanted to 16:9 version of the image.

Anyway, I did already respond to Krikor but I'll quote myself for the part that is relevant:


Quote:So in another help-forum a stranger trying to help me made this: (Ignore the black crab)
https://vimeo.com/715191537/5672aa7417

It is the same effect but the square shaped crab has this problem that it doesn't really fill the top part of the screen quickly enough of so if you look closely in the final second of the zoom in it gets centered on the "crabs belly" more.

Anyway, the effect in Vegas Pro might end up taking too many video tracks, so a solid idea now is to make an animation like the one you've made here on gimp. It might even be easier in the end. I already know how the image that would be replaced would look. I might need to slightly adjust the new image that is appearing... wait, you can most likely do basic zoom-ins to adjust the final result in gimp right?

Anyway, here's the images that I would use:
https://imgur.com/a/MXLEXAi

The first image is the old one that is already on the screen from the start. (It might be wise to have like the first 5 or so frames of the animation just be that image with nothing changing so it's easier to integrate into the final video project.)
The 2nd or 3rd image is the one that would appear after the crab zoom in. (It's probably wiser to use the 2nd image & just zoom it in like the 3rd one, incase the zoom-in is too big so it would be easier to re-adjust afterwards.) (& It also might be wise to have it like that for like an extra 5 or so frames with nothing changing once the transition is done so it's easier to integrate.)

If this ends up looking like I want it to with the addition of sound effects like "are you feeling it now MrKrabs" (from SpongeBob) & a couple of seconds from the 'Crab Rave' song this edit alone would be a banger.

Anyway, how do you do any of this stuff? I only use gimp exclusively to add transparency to images (well, plus a couple of minor things here and there) so you might need to explain from scratch.

Anyway, thank you once again.

- guest273.


RE: How to resize an image so it's content would stay centered? - Krikor - 05-30-2022

(05-30-2022, 03:26 PM)guest273 Wrote: Hi Krikor!

Thank you for your response! Smile


For me the https://ibb.co/0nnh0C9 isn't loading, but it's just another way to view this gif you've created, right?

YES!
This is exactly what I need! And I can see that you've also used the 16:9 version of the crab!

So in another help-forum a stranger trying to help me made this: (Ignore the black crab)
https://vimeo.com/715191537/5672aa7417

At https://ibb.co/0nnh0C9 is the animation in size 1920x1080. Maybe you can use it, whether or not to change the frames per second rate for the layers.
I leave this image attached. Smudge

(05-30-2022, 03:26 PM)guest273 Wrote: Anyway, how do you do any of this stuff? I only use gimp exclusively to add transparency to images so you might need to explain from scratch.

- guest273.

I believe that there is no one better than rich2005 to didactically detail any editing process in Gimp.  Wink


RE: How to resize an image so it's content would stay centered? - rich2005 - 05-30-2022

Quote:..I believe that there is no one better than rich2005 to didactically detail any editing process in Gimp.  Wink

Now there is a hope an a half Wink

I have broken my procedure into sections, makes it easier to follow, however the end result is a 1.2 second video (meant as a transition)
Half size version looks like this:  https://i.imgur.com/ChyQ7tO.mp4

1. Scale the image to 50 layers using the gimp_gmic_qt plugin. Get the plugin from http://www.gmic.eu

https://youtu.be/X3nCmXBfTjA  duration 4 min 30

2. Merge the 50 layer (scaled) layers with a 50 layer animation. You have to get the animation from somewhere. The merge uses Ofnuts ofn-interleave-layers.py python plugin
see: http://sourceforge.net/projects/gimp-tools/files/scripts  ofn-interleave-layers.zip dated 2020-04-25  Unzip read the help notes. The plugin goes in your plug-ins folder.

https://youtu.be/XOnrFITyQJw  duration 3 min 20

3. Exporting the 50 layers to individual files to render into a video. Many video editors will take a sequence of numbered files, Avidemux does and the one shown in the video Openshot. I normally use command line FFmpeg but the particular command is no good in Windows.
Exporting the layers uses a script  export-layers-plus.scm  Zipped and attached. Unzip and put in your Gimp scripts folder.

https://youtu.be/h1fIZKeAq4Q  duration 3 min


RE: How to resize an image so it's content would stay centered? - guest273 - 05-31-2022

(05-30-2022, 04:23 PM)Krikor Wrote: I believe that there is no one better than rich2005 to didactically detail any editing process in Gimp.  Wink

(05-30-2022, 09:02 PM)rich2005 Wrote:
Quote:..I believe that there is no one better than rich2005 to didactically detail any editing process in Gimp.  Wink

Now there is a hope an a half Wink

I have broken my procedure into sections, makes it easier to follow, however the end result is a 1.2 second video (meant as a transition)
Half size version looks like this:  https://i.imgur.com/ChyQ7tO.mp4

1. Scale the image to 50 layers using the gimp_gmic_qt plugin. Get the plugin from http://www.gmic.eu

https://youtu.be/X3nCmXBfTjA  duration 4 min 30

2. Merge the 50 layer (scaled) layers with a 50 layer animation. You have to get the animation from somewhere. The merge uses Ofnuts ofn-interleave-layers.py python plugin
see: http://sourceforge.net/projects/gimp-tools/files/scripts  ofn-interleave-layers.zip dated 2020-04-25  Unzip read the help notes. The plugin goes in your plug-ins folder.

https://youtu.be/XOnrFITyQJw  duration 3 min 20

3. Exporting the 50 layers to individual files to render into a video. Many video editors will take a sequence of numbered files, Avidemux does and the one shown in the video Openshot. I normally use command line FFmpeg but the particular command is no good in Windows.
Exporting the layers uses a script  export-layers-plus.scm  Zipped and attached. Unzip and put in your Gimp scripts folder.

https://youtu.be/h1fIZKeAq4Q  duration 3 min

So once again thanks to both of you guys!

Quote:Half size version looks like this:  https://i.imgur.com/ChyQ7tO.mp4
LOL. I was expecting to see a lot of things, but not that for sure. Electric boogaloo as they say. Big Grin

Quote:https://youtu.be/X3nCmXBfTjA  duration 4 min 30
I had to update my Gimp from 2.10.8 to 2.10.30 for the plug-in to work.

Afterwards for some reason my PC really struggled to make the 50 crab layers - it took over 2 minutes while for you it looked like it was instantaneous.

Thank you for explaining the shift click layer. That's easy to remember and I can see it being useful in the future.

Quote:see: http://sourceforge.net/projects/gimp-tools/files/scripts  ofn-interleave-layers.zip dated 2020-04-25  Unzip read the help notes. The plugin goes in your plug-ins folder.
After some struggling I've finally managed to get this plugin working! (Well, at least it shows up!) So that's where I'll leave it for today.

Quote:You have to get the animation from somewhere.
There must be some easy way to just copy a still image for all 50 layers right?


RE: How to resize an image so it's content would stay centered? - rich2005 - 05-31-2022

Quote:...There must be some easy way to just copy a still image for all 50 layers right?..

Nothing is ever easy. I think you can do this in Sony Vegas see: http://vegaspro.helpmax.net/en/how-do-i/saving-a-still-image-sequence/ also YT if you search: https://www.youtube.com/watch?v=QiutgskKghw

Otherwise, and for other users who might be interested. Try using Avidemux editor, just as a way out.
download from: https://www.videohelp.com/software/AviDemux

This example using a Windows 10 VM https://youtu.be/kMCvcFKnrtY duration 7 minutes.
Edit: Not going to redo the video but playing around with the latest version 2.8 and it is frame accurate. No need to use key-frames. set the first frame (A) and the last (B) Save Image Selection...

Video processing can be / is slow. Twenty-something years ago I made VCD video, the CD equivalent of VHS tape. 486 processor computer, run it over-night to render 50 minutes of avi. You guys have it easy these days Wink


RE: How to resize an image so it's content would stay centered? - guest273 - 06-01-2022

(05-31-2022, 10:44 AM)rich2005 Wrote: Nothing is ever easy. I think you can do this in Sony Vegas see: http://vegaspro.helpmax.net/en/how-do-i/saving-a-still-image-sequence/  also YT if  you search: https://www.youtube.com/watch?v=QiutgskKghw

Otherwise, and for other users who might be interested. Try using Avidemux editor, just as a way out.
download from: https://www.videohelp.com/software/AviDemux

This example using a Windows 10 VM  https://youtu.be/kMCvcFKnrtY  duration 7 minutes.
Edit: Not going to redo the video but playing around with the latest version 2.8 and it is frame accurate. No need to use key-frames. set the first frame (A) and the last (B) Save Image Selection...

Okay, I'm replying to not leave you guys in the dark.

So I managed to achieve the effect I wanted in Vegas Pro (with some online help) and it took like 3 minutes to set it up.

Here's a 20 second almost out of context clip of that effect which is pretty random since this is somewhere in the middle of my final video which isn't finished yet: https://www.youtube.com/watch?v=1ciK2wd4mFg as you can see the crab is both in the transition in & out. Nothing too fancy but I personally like it when other video editors put tiny details like that in their videos.

Good news is that the 1920x1080 expanded crab image was useful as otherwise during the transition the crab looked quite square. As well as recoloring it white. I can't remember if it was one of you gents who also did that for me. Big Grin

Also... where did all my buttons go? I used to have more options in that menu before I updated my Gimp two days ago...
[attachment=8038]


Quote:Video processing can be / is slow.  Twenty-something years ago I made VCD video, the CD equivalent of VHS tape. 486 processor computer, run it over-night to render 50 minutes of avi. You guys have it easy these days Wink
The longest wait that I ever had was 6 hours to render an 4 hour looped version of a song because YouTube in the year 2022 still can not afford to give mobile users the ability to loop music videos. This one makes me proper mad. This is from the category of: people in the future will have flying cars! Probably 2035 still no loop function for mobile users on YouTube...

Judging by the fact that you gents are also experienced in video making, I'm guessing that there must be some other help forum that's based around one or another video editing program that I'm not aware of? I have this bad habit of just throwing out the same question in 3-5 different forums and seeing which one will answer first. xD

Also excuse me for 'littering' this forum with my random nonsense post. You can expect me in a year or half a year popping up one random day with an another totally bizarre question.


RE: How to resize an image so it's content would stay centered? - PixLab - 06-02-2022

(06-01-2022, 09:19 PM)guest273 Wrote: Also... where did all my buttons go? I used to have more options in that menu before I updated my Gimp two days ago...

In the menu Edit ➤ Preferences a window opens, go to Interface ➤ Toolbox and un-tick Use tool groups, then click OK

[attachment=8040]