You are not logged in.
So I made these to use specifically as right-click context-menu options when I click on an image file in PCmanFM, haven't used Thunar much but i'm sure it has a way to add such things too. Just a super-fast way to alter a given image with just a couple clicks rather than open Gimp. Hopefully they are useful for somebody, I sell unwanted items from time to time online, and just wanted something quick to resize pics.
rot - rotate image
#!/bin/sh
rotbox=$(yad --fixed --window-icon=edit-redo --form --title="Rotate Image" --field="Rotate:":CB --width=300 --text-align=center --text="Select rotation (clockwise, in degrees)" '90!180!270')
rot=$(echo $rotbox | awk 'BEGIN {FS="|" } { print $1 }')
convert "$1" -strip -rotate "$rot" -set filename:copy '%t-rotated.%e' '%[filename:copy]'
# This is free software with NO WARRANTY. Use at your own risk!
# Depends: yad, imagemagick
# DESCRIPTION:
# This script makes a copy of an image file (JPG, BMP, PNG), rotates the copy to
# selection entered in yad dialog (90, 180 or 270 degrees clockwise), adds "rotated" to
# the original filename, and outputs the copy into the same directory as the original.
# It is intended to be used with a .desktop file for activation in PcmanFM to offer a "Rotate Image"
# option when you right-click an image file, but can also be used in terminal: rot [img file]
shrink2 - resize image -note: this is a "smart" resize in that it doesn't change the aspect ratio of the image regardless
of whatever dimensions you apply in the text-entry, i.e. if you input "800x600" on a 1600x900 image, it will output a
800x450 image and that proper size will be reflected in the name of the new image.
#!/bin/sh
sizebox=$(yad --fixed --window-icon=image --form --title="Resize Image" --field="Resize to:" --width=400 --text-align=center --text="Enter new size (W x H in pixels, i.e. 800x600, 1024x768 etc.)")
size=$(echo $sizebox | awk 'BEGIN {FS="|" } { print $1 }')
convert "$1" -resize "$size" -set filename:copy '%t-%wx%h' '%[filename:copy].jpg'
# This is free software with NO WARRANTY. Use at your own risk!
# Depends: yad, imagemagick
# DESCRIPTION:
# This script makes a copy of an image file (JPG, BMP, PNG), resizes the copy to whatever
# dimensions are entered, converts it to a JPEG, adds the new dimensions to the original
# filename, and outputs the copy into the same directory as the original. It is intended to
# be used with a .desktop file for activation in PcmanFM to offer a "Resize Image"
# option when you right-click an image file, but can also be used in terminal: shrink2 [img file]
Last edited by greenjeans (2025-02-24 18:54:38)
Offline
Nice
Here's a version of the rotate script using dialog(1) instead of yad for those who prefer shell interfaces:
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-or-later
rot=$(dialog \
--backtitle "Rotataroo" \
--menu "Select rotation (clockwise, in degrees)" \
10 50 3 90 "" 180 "" 270 "" \
3>&2 2>&1 1>&3)
convert "$1" -strip -rotate "$rot" -set filename:copy '%t-rotated.%e' '%[filename:copy]'
To run the script use this in the Exec line:
x-terminal-emulator -e /path/to/dialog/script %f
Offline
Jpeg should be able to rotate lossless-y, so maybe worth making a special case (jpegtran should be the utility), not sure if imagemagick can do that. p.s. Not sure how exactly jpegtran works, but jpeg rotation should be also possible changing exif data.
Just saying
Offline
Jpeg should be able to rotate lossless-y, so maybe worth making a special case (jpegtran should be the utility), not sure if imagemagick can do that. p.s. Not sure how exactly jpegtran works, but jpeg rotation should be also possible changing exif data.
Just saying
Thanks for that, will check it out! I believe that's how the the Mate image viewer rotates/saves, by changing exif data, that's an even more minimal and elegant solution, but since I already had imagemagick on board for re-sizing and was familiar with it's use I just went with it.
To be clear, I am very much an amateur still at these things, so take anything I post with a grain of salt.
I also made myself another extension to right-click view exif data, using another tiny script and libimage-exiftool-perl but now am wondering if there's another simpler way, that library was pretty sizeable to do just one kinda novelty function.
@HOAS very cool, but just reminded me I still haven't gone back and made a couple of long lines of code readable via backslash-ing new lines, lol, i've gotten lazy in my old age.
Offline
exinfo: view exif data right-click script, just real basic, libimage-exifview-perl and yad:
#!/bin/sh
# This script when combined with a .desktop file,
# is to give you a "view exif info" option for a given image
# when you right click on an image in the file manager.
# Depends: libimage-exiftool-perl, yad
exiftool -a -u -g1 "$1" | yad --text-info --title="Exif data for $1" --window-icon=preview-file --maximized --image=preview-file --margins=7 --button=gtk-close:0
And the .desktop I use:
[Desktop Entry]
Type=Action
Name=View exif data
Comment=View an images exif data
Icon=preview-file
Profiles=exifview;
[X-Action-Profile exifview]
Exec=exinfo %f
MimeTypes=image/bmp;image/jpeg;image/png;
Last edited by greenjeans (2025-02-24 18:46:11)
Offline
This one's just a .desktop entry to click on an image and set for wallpaper, using nitrogen on openbox, I don't change wallpaper a lot, but when I do it's usually some arbitrary image I found somewhere or made, so not sized specifically or made for this machine.
So instead of just having Nitrogen apply it, I copy the image to it's main directory first and then open Nitrogen because I usually have to change one of the settings anyway, stretch, center etc. So that's why I do it this way.
[Desktop Entry]
Type=Action
Name=Set As Wallpaper
Comment=Copy image and open wallpaper settings
Icon=preferences-desktop-wallpaper
Profiles=profile-zero;
[X-Action-Profile profile-zero]
MimeTypes=image/jpeg;image/bmp;image/gif;image/png;image/svg+xml;
Exec=sh -c "cp %f /usr/share/images/Wallpapers/ && nitrogen"
Offline