Redimensionner rapidement une image depuis Nemo

Développement, ,

Je pense que c’est pareil pour tout le monde, mais moi j’ai souvent besoin de réduire une image avant de l’envoyer par mail ou autre. Et autant vous dire que lancer un logiciel uniquement pour ça, c’est une vrai perte de temps ;)

La solution, comme souvent pour ces petites actions, réside dans une bonne commande bash.
Mais pour y avoir accès facilement depuis votre gestionnaire de fichier Nemo, le mieux est d’utiliser une action !

Mise en place

Voici l’action que j’ai créé pour redimensionner une ou plusieurs images :

user@ubuntu:~$ vi .local/share/nemo/actions/resize-picture.nemo_action
[Nemo Action]
Active=true
Name=Resize to 1024
Exec=mogrify -resize 1024x1024 -path /home/user/images-resized/ %F
Icon-Name=document-export
Selection=NotNone
Extensions=jpg;png;

Même si le plus important est la commande en elle même (ligne 5), regardez les lignes 7 et 8 qui permettent d’indiquer qu’on ne veut voir cette action que si :

  • Selection=NotNone un ou plusieurs fichiers est sélectionné,
  • Extensions=jpg;png; le fichier a l’extension JPG ou PNG.

Aller plus loin

Voici l’exemple complet d’une action proposée par Nemo :

[Nemo Action]
# Use this entry? Largely for troubleshooting.
# Lack of this field assumes true
Active=false
 
# The name to show in the menu, locale supported with standard desktop spec.
# Use %N as an (optional) token to display the simple filename in the label.
# If multiple are selected, then the arbitrary first selected name will be used.
# Token is inactive for selection type of Multiple, None and Any (it will be treated literally)
# **** REQUIRED ****
Name=Test Custom Action applied to %N
 
# Tool tip, locale supported (Appears in the status bar)
# %N can be used as with the Name field, same rules apply
Comment=This is a test for Nemo actions.  Action will be applied to %N
 
# What to run.  Enclose in < > to run an executable that resides in the actions folder.
# Use %U as a token where to insert a URL list, use %F as a token to insert a file list
# **** REQUIRED ****
#Exec=gedit %F
Exec=<myaction.py -r -g %F>
 
# Icon name to use in the menu - must be a theme icon name
Icon-Name=folder
 
# Gtk Stock ID to use for the icon.  Note if both Icon-name and Stock-Id are
# defined, the Stock-Id takes precedence.
#Stock-Id=gtk-cdrom
 
# What type selection: [S]ingle, [M]ultiple, Any, NotNone, None (background click), or
# a number representing how many files must be selected to display.
# Defaults to Single if this field is missing
Selection=S
 
# What extensions to display on - this is an array, end with a semicolon
# Use "dir" for directory selection and "none" for no extension
# Use "any" by itself, semi-colon-terminated, for any file type
# Extensions are NOT case sensitive.  jpg will match JPG, jPg, jpg, etc..
# **** REQUIRED ****
Extensions=any;

Laisser un commentaire