|
How the code samples (below) are presented - and other notes :
Each of these nautilus-script code samples is presented as an HTML
embedded plain-text 'object' so that you can scroll the text,
vertically or horizontally.
Note that the batch ('multi' named) image processing scripts
can handle one file as well as multiple files.
Generally, in the scripts, I use double-# (##) to
indicate a true comment.
That is, it is not an executable statement and should never be
de-commented.
I use single-# (#) to indicate an executable statement that
has been commented. Typically this is because I might want
to decomment the statement when doing testing of the script
in a terminal window. Generally, the statement should be re-commented
--- or a neighboring statement should be commented ---
when finished testing.
I do not try to make one-liner scripts, nor do I try for the
ultimate in processing efficiency. (But I am aware of several things to
avoid that would make scripts run slow as molasses.) I try to make the scripts
readable (to me). At the same time, they execute quite rapidly,
even on a directory containing over a hundred files. These
scripts can be MAJOR time savers.
In the batch code samples, you will see that I may be using
the Linux/Unix variable
$@
to 'pick up' the list of selected file names. If this proves to be
a problem (for example, with embedded spaces in some filenames),
I may have to resort to using a nautilus variable:
- NAUTILUS_SCRIPT_SELECTED_URIS or
- NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
This is a sign that these code samples are NOT the
'be all and end all'. You (and I) will probably have to
edit them somewhat to handle particular issues.
The image-processing scripts below are presented roughly in
the order in which I use them:
-
a converting script for converting '.png' or '.gif' files (like screen
captures or images from the web) to '.jpg' --- script name starts with '00'
-
renaming scripts (several) for JPG files from my digital camera
--- the several script names start with '01'
-
I do the cropping and gamma-correction manually, usually with
'mtpaint'. The script that starts up 'mtPaint', on a set of selected files,
starts with the '02' prefix.
-
batch renaming of image files (jpg --- and even png or gif)
to contain X-Y pixel size in the names --- script name
starts with '03'
-
batch down-sizing scripts for image files, putting the
new-sized files into a (new) subdirectory, or putting the original
files into a subdirectory --- the (two) script names start with '04' ---
a Y-size is prompted for, using zenity
-
batch renaming script, that changes an MMMxNNN size
in the filename to a new, actual XXXxYYY size --- script prefix '05'
-
batch thumbnailing script, which prompts for Y-size
using zenity --- script prefix '06'
-
several animated GIF scripts --- prefix 'ani'
-
some colorizing scripts --- prefix 'color'
-
several seamless tile scripts --- prefix 'tile'
Navigation :
Use the table-of-contents (above) to go directly to the desired
image-processing code listing.
OR simply scroll down this page to spot samples of interest.
Alternatively,
use the 'Find text' option of your web browser to look for keywords
on this page. For example, when looking for examples of scripts
using the 'convert' or 'identify' command, use 'convert' or 'identify'
--- or when looking for a script involving 'jpg' or 'png' or 'gif' files,
use keyword 'jpg' or 'png' or 'gif'.
Shell considerations :
Most of these samples are intended to run with the Bourne or the Korn
shells (command interpreters), as well as with the Bash command
interpreter.
Most of these samples employ Linux/Unix commands (and their parameters)
available to all three interpreters, so the scripts will generally run
in any of these three interpreters.
In fact, the Korn and Bash interpreters are offshoots of the Bourne
command interpreter.
Warnings :
Although I have used these scripts, I have used them,
for the most part,
on directories of files with no spaces (blanks) in the filenames.
The scripts may not be tested thoroughly enough for every
application environment.
Use at your own risk.
This may sound too dire.
The scripts are generally quite safe. If they are meant change a file, they
will, in most cases,
- put the change in a new file
- simply rename the file (If the renaming is not what was wanted, just rename.)
- or fail, not doing anything to the original file.
Examine the code, to erase doubt.
The code is presented here mostly for my own personal
use --- as a reference (for example, from different computers,
at home or away) and as a means of organized archival and backup.
I may use portions of the scripts for working code fragments
to be applied in other scripts.
If other people use these scripts, they should
test them on test data before using in a 'serious' mode.
|