Uncategorized

How to resize product photos in batch (Center, White background with Aspect ratio)?

Today I had to resize large no of photos for an e-commerce website. Maybe it is the same reason why you read this article :).

Images were downloaded from the internet, therefore they were in various sizes varying from 650px to 5000px. Here are the requirements I had when I started this job.

  1. Final image size should be 500 x 500px.
  2. If the original image is larger it should be resized, with respect to the aspect ratio.
  3. If the image width and height differ, the lower side should be filled with white background.
  4. Original image should be in the Center of the Final image.

Most especially I am not a fan of wasting my time on repetitive works so AUTOMATION was the most important requirement:).

I tried many solutions and finally found a convenient method that can address all of my above requirements. It was with the Mogrify tool comes with the ImageMagic package.

This is a Linux tool but it’s very simple so please don’t run away :).

Installing ImageMagick

I am using Debian derivative OS for this example. If you have any other OS, please use the respective installation command.

sudo apt-get update
sudo apt-get install imagemagick

Processing images
Note: In my situation, all images were in jpg format but if you have images in various formats please convert all of them to jpg before proceeding.
Upload all of your photos to a folder in the Linux box and open that folder from the CLI.

cd /image_folder
mogrify -resize 500×500 -extent 500×500 -gravity center -background white *.jpg

That’s it! :). Download your uploaded images and they should be in the required format by now.

You can do much more things with this amazing tool. Please check the official documentation of mogrify to learn more.

Hope this helped!

Recent Posts

How do I create an engaging and informative online quiz or assessment?

Creating an engaging and informative online quiz or assessment can be a powerful tool for… Read More

1 year ago

What are the most effective methods for managing and reducing work-related stress in the hospitality industry?

Work-related stress is a common issue in the hospitality industry, where employees often face long… Read More

1 year ago

How can I improve my assertiveness and communication skills in a leadership position?

In a leadership position, assertiveness and effective communication skills are crucial for success. Being able… Read More

1 year ago

What are the key elements of a successful employee recognition and rewards program?

Employee recognition and rewards programs play a crucial role in motivating and engaging employees, as… Read More

1 year ago

How do I effectively manage and respond to customer feedback and reviews?

Customer feedback and online reviews play a crucial role in shaping a company's reputation and… Read More

1 year ago

What are the best strategies for effective time management as a stay-at-home parent?

Effective time management is crucial for stay-at-home parents who juggle multiple responsibilities on a daily… Read More

1 year ago