Right-click to Resize / Rotate Your Photo Images in Ubuntu 22.04

Need to resize or rotate your photo images? You don’t have to use any image editors. Your Linux file manager may have a plugin to do the job.

NOTE: This tutorial is tested and works in Ubuntu, Fedora Workstation & other Linux with GNOME Desktop, Ubuntu MATE, Linux Mint, XUbuntu, Linux Lite and other Linux with XFCE4.

Enable Resize/Rotate menu option in Nautilus

GNOME, the default desktop in Ubuntu, Fedora Workstation, has an extension for its ‘Nautilus’ file manager to do the job.

1. First, click on top-left “Activities” to open overview, search for and open a terminal window:

Open terminal

2. When terminal opens, run one of the commands below to install the extension:

  • For Ubuntu, Debian, use command:
    sudo apt install nautilus-image-converter
  • And for Fedora, run:
    sudo dnf install nautilus-image-converter
  • Arch and Manjaro Linux can install it via:
    sudo pacman -S nautilus-image-converter

3. After installed the packages, restart the file manager by running command:

nautilus -q

4. Finally, open ‘Files’. Select a photo image or hold Ctrl (or Shift) to select multiple images. Then use the right-click menu options to open the convert dialog.

In popup dialog, you may either rotate in 90, 180, 270 clockwise or custom angle degrees. Or resize in percentage or custom resolution.

Enable Resize/Rotate Context Menu in Nemo

For Linux Mint Cinnamon or Ubuntu with Nemo file manager, press Ctrl+Alt+T on keyboard to open terminal.

Then run command to install the plugin:

sudo apt install nemo-image-converter

After that quit the file manage via command:

nemo -q

Finally, right-click on your photo images and use the new options to resize or rotate them.

Enable Resize/Rotate Context Menu in Caja

Similarly, Ubuntu MATE, Linux Mint MATE has the plugin for its Caja file manager.

First, press Ctrl+Alt+T on keyboard to open terminal. Then run command to install the package:

sudo apt install caja-image-converter

After restart the file manage via the command below, you’ll see the new menu options when right-clicking on your photos:

caja -q

Enable Resize/Rotate Custom Actions in Thunar

XFCE desktop’s Thunar file manager, which is default in XUbuntu, Linux Lite, Kali Linux, does NOT have similar plugin. However, it supports custom actions to run scripts to do the job.

1. Create scripts for resizing images

First, search for and open terminal from system start menu. When it opens, first run commands to install the command line tools for converting process.

sudo apt install imagemagick zenity

Then, create “.local/bin” directory in case it does not exist. It will be included in your $PATH variable once created.

mkdir -p ~/.local/bin

Then, create and edit the script for resize image:

mousepad ~/.local/bin/resize-image.sh

When the file opens, paste the lines below and save it (via XFCE forum):

#!/bin/bash

# paths, constants, etc.
PICPATH="$1"
TOTALPICS="$((($# - 1)))"
STEP="$(((100 / $TOTALPICS)))"
PROGR=0
MINSIZE=12
MAXSIZE=2048

# Check if ImageMagick commands are found
for command in convert identify
do
    if [ ! $(which $command) ]
    then
        zenity --error --text "Could not find \"$command\" application.\n
Make sure ImageMagick is installed and \"$command\" is executable."
        exit 1
    fi
done


# Enter new width (12px-2048px) and check it - aspect ratio will be maintained...
SIZE=""
while [ -z "$SIZE" ]; do
    SIZE="$(zenity --entry --title="Picture Resize" --text="Enter maximum width...")"

    # exit if cancel pressed
    [[ $? != 0 ]] && exit 0

    # check range
    if [[ $SIZE -lt $MINSIZE ]] || [[ $SIZE -gt $MAXSIZE ]]; then
        zenity --error --text="$SIZE"px" is outside the accepted range: 12px - 2048px!"
        SIZE=""
    fi
done

# convert pics
while (( $# )); do
    convert "$PICPATH/$1" -resize "$SIZE" -quality 95 -interlace line "$SIZE"px"-$1"
    ((PROGR+=$STEP))
    echo $PROGR
    shift
   
#show progress bar
done | zenity --progress --title="Picture Resize" --text="working..." --percentage=0 --auto-close

# check return value and print message depending on it
[[ $? == 0 ]] && zenity --info --title="Picture Resize" --text="All done!" || zenity -
       -error --text="Canceled!"

After saving the file, add executable permission by running command:

chmod u+x ~/.local/bin/resize-image.sh

2. Create scripts for rotating images

Also in a terminal window, run command to create the script for rotating image:

mousepad ~/.local/bin/rotate-image.sh

When file opens, paste the lines below and save it (via: github.com/SalineOS).

#!/bin/bash
# Licensed under the GNU General Public License Version 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
####################################################################################################
## Authored by Anthony Nordquist of the SalineOS project. http://www.salineos.com/  [email protected] 
## Copyright 2011,2012 Anthony Nordquist 

## Load translations

LanguageLess="$(echo "$LANG" | awk -F '.' '{print $1}')"

if [ -f /etc/thunar-image-scripts/Translations/$LanguageLess ]; then
 . /etc/thunar-image-scripts/Translations/$LanguageLess
else
 . /etc/thunar-image-scripts/Translations/en_US
fi

## Set arrays for yad options
Title=( "--title=Resize Image(s)" )
WindowIcon=( "--window-icon=image-x-generic" )
Icon=( "--image=image-x-generic" )

Rotation=$(yad "${Title[@]}" "${WindowIcon[@]}" --height=225 --list --no-headers --column="$SELECTONE" --text="$ROTATETEXT" 90 180 270)

ret="$?"

Rotation=$(echo "$Rotation" | awk -F '|' '{print $1}')

if [ "$ret" = "1" ]; then
 exit 0
elif [ "$ret" = "252" ]; then
 exit 0
elif [ "$Rotation" = "" ]; then
 yad "${Title[@]}" --window-icon="error" --image="error" --width="350" --wrap --text="$NODEGREES\n" --button=$"gtk-quit:1"
 exit 0
fi

progressbar () {
tail -f /usr/bin/rotate-image-ca |  yad "${Title[@]}" "${WindowIcon[@]}" "${Icon[@]}" --width="350" --no-buttons --progress --pulsate --auto-close --text="$@"
}

progressbar "$ROTATEIMAGES $Rotation degrees $NOW\n" &

for i in "$@"; do
 convert "./$i" -rotate $Rotation "./$i"
done

sleep 5

TailPID=$(pgrep -f "tail -f /usr/bin/rotate-image-ca")

kill $TailPID

notify-send -u normal -i image-x-generic -t 25000 "
$ROTATECOMPLETE"

exit

Also, add executable permission after created it:

chmod u+x ~/.local/bin/rotate-image.sh

3. Add custom actions for the scripts

Now, open Thunar file manager, and go to “Edit -> Configure custom actions“.

In the pop-up dialog, click “+” to add a new action and type in:

  • Name: Resize Images
  • Command: resize-image.sh %d %N
  • Select “Image Files” under Appearance Conditions tab.
  • Others are optional.

And create another one via:

  • Name: Rotate Images
  • Command: rotate-image.sh %N
  • Select “Image Files” under Appearance Conditions tab.
  • Others are optional.

4. Verify the menu options

NOTE: You need to Log Out and back in, if '~/.local/bin' was not exist, to refresh $PATH variable

Finally, right-click on one or a selection of photo images. You’ll see the new options. For resizing, type your desired image width ranging from 12 to 2048, it will convert the height according to original ratio, and output another files.

For rotating, it provides 90, 180, and 270 clockwise options. And, the script will override the original images with rotated ones. So, make a backup of original images if required.

See the how to via YouTube Video

Summary

In short, Gnome, MATE, and Cinnamon desktops’ file managers have their own plugin to do resizing and rotating images. Just install the package, and restart file manager will do the trick.

For XFCE, the Thunar file manager has custom actions for running scripts to achieve the function. Though you have to write your own, search on web, or use the scripts in this tutorial. Sadly for KDE Dolphin, the services as far as I know are quite outdated.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.