Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Resizing several images

Community Beginner ,
Feb 21, 2023 Feb 21, 2023

Hello! Do someone know if it is possible to resize multiple images with a script even through they have different sizes?

TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 21, 2023 Feb 21, 2023

If the goal is a standard size, File > Automate > Fit Image is what you want for this. It can be used in actions, a script is not necessary.

 

It will work on both portrait and landscape, resizing the longest side. It can either enlarge if applicable, or not.

Translate
Adobe
Community Expert ,
Feb 21, 2023 Feb 21, 2023

Yes, it is possible. But you need to define the criteria. How will the final size be determined?

ABAMBO | Hard- and Software Engineer | Photographer
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 21, 2023 Feb 21, 2023

If the goal is a standard size, File > Automate > Fit Image is what you want for this. It can be used in actions, a script is not necessary.

 

It will work on both portrait and landscape, resizing the longest side. It can either enlarge if applicable, or not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2023 Feb 22, 2023

Thank you very much! It seems to work well!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2024 Nov 22, 2024

I need to process a bunch of images and based on which dimension is larger, the width or the height, I need to resize the larger dimension to 800 pixels and have the other dimension auto-calculate to some number.  How is this achieved?  I looked at the File...Automate....Fit Image, and I see the contrain within boxes.  If I specify 80o pixles in both boxes, will this process only set the larger dimension to 800?  I guess I can give it a try while I wait for your response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2024 Nov 22, 2024

I tried creating an action to Fit the Image within 800 x 800 pixels and then get the canvas size to 800 x 800 pixels and then save as PNG.  When I look at the output folder, the images are not being saved as 800 x 800.  I suspect the canvas size is not working.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2024 Nov 22, 2024
quote

I tried creating an action to Fit the Image within 800 x 800 pixels and then get the canvas size to 800 x 800 pixels and then save as PNG.  When I look at the output folder, the images are not being saved as 800 x 800.  I suspect the canvas size is not working.


By @DDmUSA


When set to 800x800px, the longest edge will be resized to 800px, with the shortest edge proportionally smaller.

 

What size is the original? What is the size after fit image?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2025 Mar 24, 2025
LATEST

 

1. Python Solution (PIL - Pillow)

You can use the Pillow (PIL) library to resize multiple images in a folder, regardless of their original sizes.

Example: Resize all images to 500x500 pixels

 

python
from PIL import Image import os input_folder = "images/" # Folder containing images output_folder = "resized_images/" # Output folder # Create output directory if it doesn't exist os.makedirs(output_folder, exist_ok=True) # Loop through all images in the input folder for filename in os.listdir(input_folder): if filename.endswith((".jpg", ".jpeg", ".png", ".bmp", ".gif")): img_path = os.path.join(input_folder, filename) img = Image.open(img_path) # Resize the image while maintaining aspect ratio img_resized = img.resize((500, 500), Image.ANTIALIAS) # Save the resized image img_resized.save(os.path.join(output_folder, filename)) print("Batch image resizing completed!")

 

✔ This script resizes all images in the images/ folder and saves them to resized_images/.


2. Python Solution (OpenCV)

If you prefer OpenCV, use the following script:

 

python
import cv2 import os input_folder = "images/" output_folder = "resized_images/" os.makedirs(output_folder, exist_ok=True) for filename in os.listdir(input_folder): if filename.endswith((".jpg", ".jpeg", ".png")): img_path = os.path.join(input_folder, filename) img = cv2.imread(img_path) # Resize image while keeping aspect ratio img_resized = cv2.resize(img, (500, 500)) cv2.imwrite(os.path.join(output_folder, filename), img_resized) print("Images resized successfully!")

 

 

3. Using ImageMagick (Command Line)

If you prefer a command-line approach, ImageMagick can resize all images in a folder:

 

bash
magick mogrify -path resized_images -resize 500x500 images/*.jpg

✔ This command resizes all .jpg images in the images/ folder and saves them to resized_images/.


Which One Should You Use?

  • :white_heavy_check_mark: Python (PIL or OpenCV) – Best for automation in scripts or web applications.

  • :white_heavy_check_mark: ImageMagick – Fastest for bulk resizing via command line

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines