Path: number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.co
!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilin
.net!spamkiller2.gnilink.net!gnilink.net!trndny06.POSTED!3d5eba02!not-for-mail
From: Frank
Subject: Re: Looking for a Ubuntu equivalent of XP sending picture by email -
converson script...more
User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing
moment of clarity.)
Message-Id:
Newsgroups: alt.os.linux.ubuntu
References:
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 77
Date: Thu, 01 Mar 2007 01:33:20 GMT
NNTP-Posting-Host: 72.75.240.119
X-Complaints-To: abuse@verizon.net
X-Trace: trndny06 1172712800 72.75.240.119 (Wed, 28 Feb 2007 20:33:20 EST)
NNTP-Posting-Date: Wed, 28 Feb 2007 20:33:20 EST
Xref: number1.nntp.dca.giganews.com alt.os.linux.ubuntu:11230
On Thu, 01 Mar 2007 01:17:49 +0000, Frank wrote:
> On Wed, 28 Feb 2007 09:43:36 +0000, Chris wrote:
>
>> Hmmm ... someone competent, like you, probably could do that.
>> And I envy you. I wish I could.
>> That does sound the absolutely best solution.
>> I wonder if enough people would find it useful for someone like you to
>> be kind enough to publish such a script?
>
> Hey Chris,
>
> Here's a script -
>
> for f in *.[jJ][pP]*[gG]
> do convert -scale 640x480 $f ${f%%.[jJ][pP]*[gG]}_sm.jpg
> done
>
> just drop it into a file (e-mail_format_picture or
> whatever) using any editor,
>
> chmod 755 that file so it can be executed
> directly,
>
> place it in any /bin directory that's in your path (/bin
> /usr/bin /usr/local/bin /opt/bin whatever)
>
> and whenever you execute it in a directory where your JPEG images for
> mailing are located will scale all named jpg or JPG or jpeg or JPEG to no
> greater than 640 height and 480 width, renaming them whatever they were to
> start ending in _sm.jpg indicating small and ready to mail.
>
> You could add an additional piece of code to wrap this in a mailing
> command but that's overkill. Again, ImageMagick has to be on your system
> since that's where the convert function comes from.
>
> Frank
Sorry for the follow up, but as I was ready to move on to the next group I
caught your comment about "I wish I could" and realized I missed an
opportunity to explain in a simple context something that may advance your
understanding a bit:
The BASH script structure for...do...done is called a "for loop" which
executes over and over until a test is done or fails. In this simple
script the for just looks at each file that matches the example in the
directory where it's executed and loads them one at a time into the
variable f.
for f in *.[gobbledegook... with that gobbledegook being first a wild
card * that can be a picture file named anything, then the . that comes
before the file extension, and finally the valid extension which can
appear as upper or lower case j [jJ] etc. with another wild card in case
there's a e or and E (jpeg is spelled out)
do convert -scale 640x480 $f the command to limit the height and width to
that geometry of each file named whatever is stored in f (read by $f)as
input file
all that jazz that follows as the output file is just the substitution
operation where a name ($) is constructed from what's in the curly braces,
taking the name portion of the file without any extension {f%%. along with
its dot, and possessing but not using all that same lower/upper case stuff
in square brackets and replacing } that stuff with the _sm.jpg
rinse, repeat... until all files fitting that description in the directory
have been converted, at which time the script is ...
done
Note, the original files aren't altered in any way by this script.
They'll still be there named the same thing, but along with them will be
all the _sm.jpg versions ready for attachment.
Frank
--- Platinum Xpress/Win/WINServer v3.0pr5
* Origin: Omicron Theta BBS (1:261/20)
|