Skip to content

Instantly share code, notes, and snippets.

@Extraltodeus
Last active January 22, 2016 01:02
Show Gist options
  • Save Extraltodeus/862accd7b4b2006f9a71 to your computer and use it in GitHub Desktop.
Save Extraltodeus/862accd7b4b2006f9a71 to your computer and use it in GitHub Desktop.
This script was made for triple monitor users, to automatically cut a picture in 3 equal parts, with good proportions
As far as I know you can put the .desktop file in ~/.local/share/kservices5/ServiceMenus/ if you're on Plasma 5
Don't forget to edit the commented lines if you want it to work as you wish.
The right-click function does not seem to work when there is a space in the path. Yet.
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,image/*
Actions=Setwallpaper;
X-KDE-AuthorizeAction=shell_access
[Desktop Action Setwallpaper]
Exec=sh #PATH TO WHERE YOU PUT THE SCRIPT
Icon=#PATH TO AN ICON YOU LIKE
Name[fr]=Couper en trois
Name[en_GB]=Cut in three
#!/bin/bash
#This script requires imagemagick
image="$*"
fichier=${image##*/}
home=~
#modify the line below to set the height of your screen
hauteurmax=1080
#modify the line below to set the width of your screen
largeurmax=5760
#set the path of destination :
imagepath=$home"/Images/Triplemonitor/Coupé/"
gauche=left-
droite=right-
centre=center-
haut=topscreen-
big=big
hauteur=$(identify -format "%h" $image)
largeur=$(identify -format "%w" $image)
entrop=$(($hauteur-$hauteurmax))
entropx=$(($largeur-$largeurmax))
hauteur2=$(($entrop/2))
largeur2=$(($entropx/2))
tiers=$(($largeurmax/3))
tiersx2=$(($tiers*2))
#copy original image in destination folder
cp $image $imagepath$big$fichier
#Global cut $hauteurmax x $largeurmax
mogrify -crop +0-$hauteur2 $imagepath$big$fichier
mogrify -crop +0+$hauteur2 $imagepath$big$fichier
mogrify -crop -$largeur2+0 $imagepath$big$fichier
mogrify -crop +$largeur2+0 $imagepath$big$fichier
#Copies for center, left and right
cp $imagepath$big$fichier $imagepath$centre$fichier
cp $imagepath$centre$fichier $imagepath$gauche$fichier
cp $imagepath$centre$fichier $imagepath$droite$fichier
#Horizontal cuts for central part
mogrify -crop +$tiers-0 $imagepath$centre$fichier
mogrify -crop -$tiers-0 $imagepath$centre$fichier
#Vertical cuts for side parts
mogrify -crop -$tiersx2-0 $imagepath$gauche$fichier
mogrify -crop +$tiersx2-0 $imagepath$droite$fichier
#Comment the following line if you want to keep the max res file
rm $imagepath$big$fichier
#!/bin/bash
#Version for 4 screens. 3 aligned and one on the top of the central one.
#This script requires imagemagick
image="$*"
fichier=${image##*/}
home=~
#modify the line below to set the height of your screen
hauteurmax=2160
#modify the line below to set the width of your screen
largeurmax=5760
#set the path of destination :
imagepath=$home"/Images/Triplemonitor/Coupé/"
gauche=left-
droite=right-
centre=center-
haut=topscreen-
big=big
hauteur=$(identify -format "%h" $image)
largeur=$(identify -format "%w" $image)
entrop=$(($hauteur-$hauteurmax))
entropx=$(($largeur-$largeurmax))
hauteur2=$(($entrop/2))
largeur2=$(($entropx/2))
tiers=$(($largeurmax/3))
tiersx2=$(($tiers*2))
hauteurdiv2=$(($hauteurmax/2))
#copy original image in destination folder
cp $image $imagepath$big$fichier
#Global cut $hauteurmax x $largeurmax
mogrify -crop +0-$hauteur2 $imagepath$big$fichier
mogrify -crop +0+$hauteur2 $imagepath$big$fichier
mogrify -crop -$largeur2+0 $imagepath$big$fichier
mogrify -crop +$largeur2+0 $imagepath$big$fichier
#Copy for top and bottom
cp $imagepath$big$fichier $imagepath$haut$fichier
cp $imagepath$big$fichier $imagepath$centre$fichier
#Cut top and bottom in half
mogrify -crop -0-$hauteurdiv2 $imagepath$haut$fichier
mogrify -crop -0+$hauteurdiv2 $imagepath$centre$fichier
#Add copies to cut (left, right)
cp $imagepath$centre$fichier $imagepath$gauche$fichier
cp $imagepath$centre$fichier $imagepath$droite$fichier
#Horizontal cuts for central and top parts
mogrify -crop +$tiers-0 $imagepath$centre$fichier
mogrify -crop +$tiers-0 $imagepath$haut$fichier
mogrify -crop -$tiers-0 $imagepath$centre$fichier
mogrify -crop -$tiers-0 $imagepath$haut$fichier
#Vertical cuts for side parts
mogrify -crop -$tiersx2-0 $imagepath$gauche$fichier
mogrify -crop +$tiersx2-0 $imagepath$droite$fichier
#Comment the following line if you want to keep the max res file
rm $imagepath$big$fichier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment