Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizing images into squares
#1
Hello everyone,

I was fiddling around with BIMP (Batch Image Manipulation Plugin) and I ran into a problem I couldn't solve.
I have a large amount of images that I want to make square.
Example: if an image is 500x700, it should be resized to 700x700, without stretching the image, and while keeping the image centered.

Anyone any idea how I can fix my problem?

Thanks in advance!

Cheers,
Frenk
Reply
#2
(02-09-2019, 03:28 PM)IAmFrenk Wrote: Hello everyone,

I was fiddling around with BIMP (Batch Image Manipulation Plugin) and I ran into a problem I couldn't solve.
I have a large amount of images that I want to make square.
Example: if an image is 500x700, it should be resized to 700x700, without stretching the image, and while keeping the image centered.

Assuming you ran into problems because of a mixture of Portrait and Landscape aspect ratio images.

You can do this in BIMP but needs two operations because BIMP does not permit a duplicate resize.

You will be overwriting files so make sure you use copies (or be very confident in your own ability)

First Resize to fixed width with padding, but include a gimp operation 'zealouscrop' with the out folder set same as images.

   

Apply this and the images are all the same width but various heights.

Do not leave BIMP, go and edit the procedures. Remove zealous crop. Edit Resize for a fixed Height with padding.

   

Apply BIMP and that gets you all a defined width and height with appropriate padding depending on aspect.

Does not make sense? A short video demo, duration 2- 1/2 minutes.





direct link https://youtu.be/kTp-rbYQsQg
Reply
#3
Hi rich2005,

First off, thank you for taking the time to write such a detailed explanation.
But sadly your answer does not seem solve my problem. I think I wasn't clear enough explaining the situation.
I have around 2000 images with different sizes. For example: one image can be 400x200, while another image is 25x50.
I am looking for a way to make all these images square. Going with the example: the first image should become 400x400, and the other image should become 50x50.

If you or anyone else has any idea how to solve this please let me know.

Cheers,
Frenk
Reply
#4
A bit of a struggle for me. Nothing I can see using BIMP and nothing using the usual GUI batch utilities such as XNViewMP.

So down to ImageMagick, which is a command line utility see: http://www.imagemagick.org and the Windows Installer download is way down bottom of this page https://www.imagemagick.org/script/download.php

This is the code to run in a terminal, copy and paste into notepad

Code:
for /r %x in (*.jpg) do magick "%x" -gravity Center -background White -extent "%[fx:max(w,h)]x%[fx:max(w,h)]" "%x_square.jpg"

and if you are not used to using Windows Command terminal some hints here:





Direct link https://youtu.be/qkdup-cReiA  duration 2 minutes

Not much I can do about the naming convention, maybe some Windows expert can advise or use one of the several Windows renaming utilities.

-----

EDIT: I did not think that the magick command could overwrite existing files, but it does. You could try the slightly amended command

Code:
for /r %x in (*.jpg) do magick "%x" -gravity Center -background White -extent "%[fx:max(w,h)]x%[fx:max(w,h)]" "%x"

That will keep the same file names.
Dangerous. Same as BIMP, work with copies or you might lose the originals.
Reply
#5
Hi rich2005,

Thanks a lot for your answer, this is exactly what I was looking for!

For anyone planning to use this; note that all the folders inside of the folder where you run the command get used as well.
Also know that you can type 'transparent' instead of 'White', which is what I used.

Once again thanks rich2005!

Cheers,
Frenk
Reply
#6
Oh my!  If only i had found this tip a few days ago ... 

I was wondering, is there a simple way to change the "square" command to get 5:4 aspect ratio images?

TIA
Reply
#7
(02-05-2021, 01:18 PM)salssal Wrote: ...I was wondering, is there a simple way to change the "square" command to get 5:4 aspect ratio images?

There is no "square" command.  That was just a part of the output  file name.   Can you clarify some things

What version of Gimp are you using. Your profile says Gimp 2.6 but that is very old. Gimp Help -> About gives the version 

Do you want to keep the image the same and add borders to adjust the image to a 5:4 ratio ?

Do you want to "squeeze" the image to force a 5:4 ratio ?

Is this for a large number of images in a batch mode ?

The more information you give, the more probable you will get a solution. Typical image would help.
Reply
#8
Yup - must ready the code carefully!

I use 2.67 on this machine but 2.10 elsewhere.

It's a batch of files, i don't have an example as it's a potential favour for a friend - i mentioned i had saved myself days using the batch 'square and add padding' solution in this thread to countless image files, with the bonus of converting random .png to .jpg - and they asked if it was feasible to use the same tool to optimise their pictures to list craft creations on Etsy which i understand likes a 5:4 aspect.  Most of her files are portrait or square-ish, she says, varying sizes.  Same task - to pad with borders, not crop.

Vague logic says to run the squaring then (somehow, help needed) extend the width by 1.25?

Cheers.
Reply


Forum Jump: