Resizing of images is done to make image visualization perfect to use for the desired purpose while ensuring that they must not affect the downloading of the content. Usually, resizing images temper the pixel quality of the Images and lower their resolution. Linux initiated some effective ways to resize images without losing their quality. Linux resizes image and Linux resize image command line are some preferred ways on the internet derived by Linux to help the user to resize the images lacking their picture resolution.

Part 1. How to Use Linux Resize Images with Command Line

Very often we look for some effective tool or method to resize images before uploading them or editing them with our content. Here, Linux resizes image with the command line is an effective way to resize such images for better use without distorting picture quality and visual impacts.

Step 1: Install the tool ImageMagick from the system repository on Ubuntu/Debian

sudo apt-get update

sudo apt-get install ImageMagick -y

Step 2: To get the width and height we will use the below command then.

identify -format %wx%h image.jpg

Step 3: After the command process a resolution will be shown on the screen.

3690X2120

Step 4: Now convert the image size to adjust the resolution preferred by the user by the following command line. For Ex:-

convert image.jpg -resize 600x400\> image.jpg

Step 5: Give another command to ensure the process is successfully done.

identify -format %wx%h image.jpg

*If the command is successfully executed then the resolution will be as given below.

600x321

All done!

Part 2. How to Resize Image on Linux Using Imagemagick

If a user is willing to convert the size of batch images then follow the given steps to precede the commands carefully. Here, resizing the images on Linux using Imagemagick effectively helps the user to do the desired changes to the images without distorting their original quality.

Step 1: First user need to create the following script as directed below-

mkdir -p ~/scripts

nano ~/scripts/batch-image-resize.sh

Step 2: Now paste the Script below while changing the “Folder”, “Width”, and “Height” variables. Here the Folder is the correct path for the image folder, Width is the MAX width, and the Height is the MAX height user wants to resize the images to. Unfortunately, this will overwrite all the images so if you want the original images as well then create a backup for them before doing the changes.

#!/usr/bin/env bash

# Purpose: batch image resizer

# Source: https://guides.wp-bullet.com

# Author: Mike

# absolute path to image folder

FOLDER=/var/www/wp-bullet.com/wp-content/uploads

# max width

WIDTH=540

# max height

HEIGHT=300

#resize png or jpg to either height or width, keeps proportions using imagemagick

#find ${FOLDER} -iname '*.jpg' -o -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;

#resize png to either height or width, keeps proportions using imagemagick

#find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;

#resize jpg only to either height or width, keeps proportions using imagemagick

find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;

# alternative

#mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png –verbose

Step 3: ctrl+X, Y and to SAVE & EXIT>

Step 4: To confirm the size of image folder has been changed give the following command.

du -sh foldername

Step 5:Wait to check the OUTPUT size.

220MB (*possibly)

Step 6: the Screen will keep running the batch commands even if the SSH command has been terminated given by the user.

Step 7: To install a fresh screen session allow the following command and ensure by tapping or on the “Intro” screen.

sudo apt-get install screen

screen

Step 8: Now Execute the Script by following command line.

bash ~/scripts/batch-image-resize.sh

Step 9: Now detach the screen by pressing Ctrl+A and D simultaneously.

Here user can check the jpegoptim process once by giving the top command again.

Step 10: To attach the screen give the following command

screen -r

Step 11: To confirm the folder size is changed using the given command.

du -sh foldername

186MB

*Little improvement will be noticed here.

This is the complete process to resize the batch image without any loss.

Part 3. Easy and Free Online Tool to Resize Image on Windows/Mac/Phone

Wondershare Online UniConverter is the most preferred easy and free “Online Tool” that helps users to resize the image through simple steps without affecting its original image quality. Also, it is compatible with most Windows/macOS and efficient enough to later support many formats like jpeg, BMP, png, tiff, etc. The tool has great convenience for users by allowing them to apply effects, cropping, adding or removing watermarks, and a lot more additional desired functions within the tool. Let’s go through the steps:

[没有发现file]

Hence all the methods described above perform best to resize the image or batch images through the Linux command line with ImageMagick. Also, UniConverter the online tool mentioned is a brilliant tool to resize images even in batches without much technical efforts that widely makes it an effective tool. Users can deliberately go for any method as per their requirements to adjust the image to their convenience to use it further.

If you find this article satisfactory please notify us through your feedback. We are humble to respond and positively revert with the best solutions. Thanks for reading!!

田中 菜月
田中 菜月 Oct 17, 24
Share article:

ai-headshot
AI video enhancer