Re: eps to jpg conversion - which program?

2008-11-09 Thread Polytropon
On Sat, 8 Nov 2008 23:36:32 -0800, Jeremy Chadwick [EMAIL PROTECTED] wrote:
 Also, what guarantee do you have that all the filenames that match that
 wildcard lack spaces in them?  Your [ and convert commands will botch
 badly in that case.  See below.

This is completely correct. If files are present as foo.EPS,
the Windows style of file naming, or foo.Eps in a mixed form,
the *.eps wouldn't catch it.

As you mentioned, it's good to assume the worst case. Not only
spaces, as well special characters. Now *that's* the real fun. :-)

[EMAIL PROTECTED] sent me | Copy [5] of C:\My Files\AV with ö and ß.Eps

Another mentionable comment would be: Why do you call the variable
just $f? Give it a better descriptive name. In this small example,
it won't lead into significant problems if you don't do it, but I've
seen shellscripts using $f, $f1, $f2, $g, $h, $y all over the file,
and it was hard to find out which values they should hold.



 style-rant
 What people often forget while writing sh scripts is that spawning
 external utilities slows down the script greatly, and destroys system
 resources.  You might think My machine has 923484390GB of RAM, and has
 6500 processors; why do I care? -- step back for a moment and think
 about older/smaller boxes, or even more importantly, embedded machines
 (very little memory, very little CPU).

Hey, that's how software development helps hardware development,
or at least software development in Redmond. :-)

  Hardware ressources   ++
Overall usage speed =  = const.
  Software requirements ++

q.e.d.


 Also think about situations where fork() will fail due to resource
 limits or existing system resource exhaustion; what then?  I see this
 regularly in perl scripts; people relying on `xxx` for no good reason.
 I ask them, Why are you doing this?  Can you not use native-perl-code
 instead, and avoid wasting resources and excessive risk?, and they
 often have no idea what I'm talking about.  And whenever I see `ssh
 [EMAIL PROTECTED] command` in perl scripts, I cry.

Ooow! Is this for real? If it is, it's a reason to hit someone's
head with the keyboard. :-)



 That in mind, don't let your scripting mimic that of perl bastards who
 *intentionally* write obfuscated code just to show off (often citing
 its faster as the reason, choosing to intentionally ignore that perl
 is a compiled language).  For complex pieces of sh that are hard to
 visually parse: try to keep it simple, and take the time to write
 decent/legible comments above the hairy part of the script.

Indentation, comments and descriptive identifiers help a lot.
If you read FreeBSD's (scripting) sources, you'll see that they
are of high quality.



 Also remember that double-quoting filenames or variables that are used
 as filenames is a VERY good idea.  Filenames with spaces are quite
 common these days.  It's best to assume the worst, but not be *too*
 over-zealous.

Especially when you're intending to use a piece of software,
even if it's just a three line shell script, more than just one
time, or if you want to share it with others.




-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-08 Thread Jonathan McKeown
On Friday 07 November 2008 21:19, Polytropon wrote:
 On Fri, 07 Nov 2008 13:36:51 +0100, Laszlo Nagy [EMAIL PROTECTED] 
wrote:

 A batch solution is simple:

   #!/bin/sh
   for f in *eps; do
   convert ${f} `basename ${f} .eps`.jpg
   done

You can also save yourself repeated calls to basename by using

for f in *eps; do
convert ${f%.eps}.jpg
done

Look under parameter expansion in the manpage for sh(1) (or bash(1) if you 
have bash installed). As far as I can tell csh/tcsh doesn't support this 
useful feature.

Essentially, a Bourne-type shell with parameter expansion expands 
${variable#prefix} or ${variable%suffix} to $variable with the prefix or 
suffix, respectively, removed.

Jonathan
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-08 Thread Polytropon
On Sat, 8 Nov 2008 12:12:46 +0200, Jonathan McKeown [EMAIL PROTECTED] wrote:
 You can also save yourself repeated calls to basename by using
 
 for f in *eps; do
 convert ${f%.eps}.jpg
 done
 
 Look under parameter expansion in the manpage for sh(1) (or bash(1) if you 
 have bash installed).

Yes, that's a very good hint, I will use this in the future.
Note that $f as first parameter is missing (source for convert).



 As far as I can tell csh/tcsh doesn't support this 
 useful feature.

Well, I prefer the C Shell (instead of BASH) as primary dialog shell,
but for scripting, I always stay with the good old Bourne Shell,
simply because it's the standard scripting shell for UNIX, and it's
compatible to most Linusi, too (where /bin/sh@ - /bin/bash,
but NB ! -f /bin/bash in FreeBSD).



 Essentially, a Bourne-type shell with parameter expansion expands 
 ${variable#prefix} or ${variable%suffix} to $variable with the prefix or 
 suffix, respectively, removed.

So this would be more efficient:

#!/bin/sh
for f in *eps; do
[ ! -f ${f%.eps}.jpg ]  convert $f ${f%.eps}.jpg
done



-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-08 Thread Jeremy Chadwick
On Sun, Nov 09, 2008 at 07:25:49AM +0100, Polytropon wrote:
 On Sat, 8 Nov 2008 12:12:46 +0200, Jonathan McKeown [EMAIL PROTECTED] wrote:
  Essentially, a Bourne-type shell with parameter expansion expands 
  ${variable#prefix} or ${variable%suffix} to $variable with the prefix or 
  suffix, respectively, removed.
 
 So this would be more efficient:
 
   #!/bin/sh
   for f in *eps; do
   [ ! -f ${f%.eps}.jpg ]  convert $f ${f%.eps}.jpg
   done

Significantly.

Also, what guarantee do you have that all the filenames that match that
wildcard lack spaces in them?  Your [ and convert commands will botch
badly in that case.  See below.

style-rant
What people often forget while writing sh scripts is that spawning
external utilities slows down the script greatly, and destroys system
resources.  You might think My machine has 923484390GB of RAM, and has
6500 processors; why do I care? -- step back for a moment and think
about older/smaller boxes, or even more importantly, embedded machines
(very little memory, very little CPU).

Also think about situations where fork() will fail due to resource
limits or existing system resource exhaustion; what then?  I see this
regularly in perl scripts; people relying on `xxx` for no good reason.
I ask them, Why are you doing this?  Can you not use native-perl-code
instead, and avoid wasting resources and excessive risk?, and they
often have no idea what I'm talking about.  And whenever I see `ssh
[EMAIL PROTECTED] command` in perl scripts, I cry.

That in mind, don't let your scripting mimic that of perl bastards who
*intentionally* write obfuscated code just to show off (often citing
its faster as the reason, choosing to intentionally ignore that perl
is a compiled language).  For complex pieces of sh that are hard to
visually parse: try to keep it simple, and take the time to write
decent/legible comments above the hairy part of the script.

Also remember that double-quoting filenames or variables that are used
as filenames is a VERY good idea.  Filenames with spaces are quite
common these days.  It's best to assume the worst, but not be *too*
over-zealous.

And don't forget about set noglob when appropriate!
/style-rant

-- 
| Jeremy Chadwickjdc at parodius.com |
| Parodius Networking   http://www.parodius.com/ |
| UNIX Systems Administrator  Mountain View, CA, USA |
| Making life hard for others since 1977.  PGP: 4BD6C0CB |

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-07 Thread Manolis Kiagias

Laszlo Nagy wrote:


 Hi,

I need to convert eps files into jpeg files in batch mode. Gimp works 
perfectly, except that I cannot use an X display. I tried eps2png with 
no success:



%file test.eps
test.eps: DOS EPS Binary File Postscript starts at byte 30 length 
566887 TIFF starts at byte 566917 length 4741

%eps2png -jpg -width 1000 -verbose -output test.jpg test.eps
Producing jpg (jpeg) image.
Not EPS file: test.eps, skipped

What port should I use to convert EPS into JPG? I would like to use a 
program that shares the same library with Gimp, because we know that 
Gimp works great for this task.


Thanks,

  Laszlo



How about using 'convert' from graphics/ImageMagick?

It would be as simple as

convert myfile.eps  myfile.jpg

and there are myriads of options to fiddle if you wish. I've been using 
it with great success for quite some time now.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-07 Thread Timm Wimmers
Laszlo Nagy schrieb:

 I need to convert eps files into jpeg files in batch mode. Gimp works
 perfectly, except that I cannot use an X display. I tried eps2png with
 no success:
 
 
 %file test.eps
 test.eps: DOS EPS Binary File Postscript starts at byte 30 length 566887
 TIFF starts at byte 566917 length 4741
 %eps2png -jpg -width 1000 -verbose -output test.jpg test.eps
 Producing jpg (jpeg) image.
 Not EPS file: test.eps, skipped
 
 What port should I use to convert EPS into JPG? I would like to use a
 program that shares the same library with Gimp, because we know that
 Gimp works great for this task.

Take a look on GhostScript, a PostScript interpreter.

-- 
Timm


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


eps to jpg conversion - which program?

2008-11-07 Thread Laszlo Nagy


 Hi,

I need to convert eps files into jpeg files in batch mode. Gimp works 
perfectly, except that I cannot use an X display. I tried eps2png with 
no success:



%file test.eps
test.eps: DOS EPS Binary File Postscript starts at byte 30 length 566887 
TIFF starts at byte 566917 length 4741

%eps2png -jpg -width 1000 -verbose -output test.jpg test.eps
Producing jpg (jpeg) image.
Not EPS file: test.eps, skipped

What port should I use to convert EPS into JPG? I would like to use a 
program that shares the same library with Gimp, because we know that 
Gimp works great for this task.


Thanks,

  Laszlo

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: eps to jpg conversion - which program?

2008-11-07 Thread Polytropon
On Fri, 07 Nov 2008 13:36:51 +0100, Laszlo Nagy [EMAIL PROTECTED] wrote:
 
   Hi,
 
 I need to convert eps files into jpeg files in batch mode. Gimp works 
 perfectly, except that I cannot use an X display. I tried eps2png with 
 no success:

You can use the convert command from ImageMagick:

convert eps-file jpg-file

A batch solution is simple:

#!/bin/sh
for f in *eps; do
convert ${f} `basename ${f} .eps`.jpg
done

You can add

[ ! -f `basename ${f} .eps`.jpg ]  

infront of the convert command to avoid repeated conversions.



-- 
Polytropon
From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]