However, Thunar has a function called Custom Actions, where you can add a command to the Context Menu to perform tasks on files.
A Note:
There are probably other ways to do this, and the script at the end of this post is only slightly modified from one that Cesare Riva posted some years ago online somewhere.
The main changes are:
There are more size options for convenience (originally only 3)
The script now produces a resized png AND a jpg if you resize a png image
The script works on a single selected image, or it will work on multiple selected images.
It is fairly quick, depending on the size of the images.
It keeps the Originals unchanged.
IMPORTANT:
You will need imagemagick (for the convert command) and zenity (to create a GUI for the shell script). These should already be in MINT, but if the script fails, try:
sudo apt install imagemagick
sudo apt install zenity
STEP 1 :-
In Thunar choose Edit > Configure Custome Actions
A Dialog window will open
Choose the + at Top Right
Fill in the fields thus:
Name: RESIZE Image
Description: Resize Image
Command: /home/your-user-name/.config/Thunar/custom_actions/picture_resize.sh %N
Keyboard Shortcut: (I left this Empty)
[ ] Use startup notification: (I left this Empty
Icon: (I left this Empty)
NEXT STEP 2 :-
Open fhe Directory: /home/your-user-name/.config/Thunar/custom_actions
Create a new file called "picture_resize.sh"
Open it and paste everything between the **** lines at the botom of this file,
then make the file EXECUTABLE.
Once that is done, right click on a jpeg or png file and you 'should' have a menu item that says:
RESIZE Image
Click that and you 'should' be able to choose a percentage to resize to.
50% will be about half the original size,
35% will be smaller,
75% will be bigger (about 3/4 the original size)
The images will be in a new folder called 'resized' inside the directory where you are working.
You can easily resize the images in the 'resized' folder to make them progressively smaller. They will be in a new 'resized' folder, inside the 'resized' folder.
#########################################
NEXT STEP 3 :-
Ok, now the code Copy and paste the stuff in the code box:
Code: Select all
#!/bin/bash
# Title : Thunar Custom Action to resize a picture
# Author : Cesare Riva
# Version : 1.0
# Date : 17-03-2016
DEST="./resized"
WIDTH=140
HEIGHT=450
QUALITY=75
# check required software
CHECK=("convert" "zenity")
for i in "${CHECK[@]}"
do
if ! command -v $i >/dev/null 2>&1 ; then
echo "Error: '$i' not found (install the appropriate package)" 1>&2
exit 1
fi
done
resize=$(zenity --width=$WIDTH --height=$HEIGHT --list \
--text "Choose resize level" --radiolist --column "%" --column "Resize"\
FALSE 15 FALSE 20 FALSE 25 FALSE 35 FALSE 45 TRUE 50 FALSE 60 FALSE 75 FALSE 90);
# check if "Cancel" button
if ! [[ $resize ]];
then
exit 1
fi
mkdir -p $DEST
for file
do
if [ ! -e $file ]
then
continue
fi
to_name="$DEST/"$(echo $file | cut -f1 -d.)".jpg"
convert -resize $resize% -quality $QUALITY "${file}" "${to_name}"
to_name="$DEST/"$(echo $file | cut -f1 -d.)".png"
convert -resize $resize% -quality $QUALITY "${file}" "${to_name}"
done
exit 0