POV-Ray : Newsgroups : povray.unix : bash: povray INPUT_PNG.png MY_INI.ini Server Time
22 Dec 2024 04:02:30 EST (-0500)
  bash: povray INPUT_PNG.png MY_INI.ini (Message 1 to 8 of 8)  
From: gregjohn
Subject: bash: povray INPUT_PNG.png MY_INI.ini
Date: 30 May 2007 13:40:01
Message: <web.465db6613dbc0ce940d56c170@news.povray.org>
I am interested in running through bash a series of invocations of povray.
I would like to be able to use povray to "process" a series of PNG's.
Perhaps this is impossible; perhaps I need to have a unique INI for each
PNG where that PNG were declared as a variable; perhaps bash can do this in
a really slick way.

In other words, I'm currently doing:
i) For every PNG I am working with, create a different povray  file where
the PNG is referenced and used.  The stack of povray files are identical
save a bitmap input filename.
ii) Run every one of them one at a time in a Windows version of povray.

This is an inefficient approach.

Any tips on how bash in linux (or even the Windows version) could do this
more efficiently?


Post a reply to this message

From: Nicolas Calimet
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 30 May 2007 14:43:13
Message: <465dc5c1@news.povray.org>
Not sure what you're trying to do exactly, but let's see:

> i) For every PNG I am working with, create a different povray  file where
> the PNG is referenced and used.

	You might have a unique scene.pov file that uses an imgfile variable
which is initialized at the command-line:
http://povray.org/documentation/view/3.6.1/220/

	Thus, for your bunch of PNG image files, do e.g.:

#!/bin/sh
for file in `ls *.png`; do
   povray scene.pov [options] Declare=imgfile=$file
done

	- NC


Post a reply to this message

From: gregjohn
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 30 May 2007 15:00:01
Message: <web.465dc9989c2d5fa540d56c170@news.povray.org>
Nicolas Calimet <pov### [at] freefr> wrote:
>  You might have a unique scene.pov file that uses an imgfile variable
> which is initialized at the command-line:
> http://povray.org/documentation/view/3.6.1/220/
>

That is great news.  I hadn't RTFM well enough to realize you could declare
variables at the command-line.  Bash is one of the great treats of linux.


Post a reply to this message

From: Christoph Hormann
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 31 May 2007 02:37:19
Message: <465e6d1f$1@news.povray.org>
Nicolas Calimet schrieb:
> 
> #!/bin/sh
> for file in `ls *.png`; do

i think better would be

for file in *.png ; do

since ls is not guaranteed to only print the file names AFAIK.

>   povray scene.pov [options] Declare=imgfile=$file

I think this only works for floats.

Simple solution:

for file in *.png ; do
   cp $file temp.png
   povray -iscene.pov [options] \
   -o`echo "$file" | sed 's?png$?render.png?'`
done

where scene.pov always uses temp.png

-- Christoph


Post a reply to this message

From: Nicolas Calimet
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 31 May 2007 06:17:39
Message: <465ea0c3$1@news.povray.org>
> i think better would be
> for file in *.png ; do
> since ls is not guaranteed to only print the file names AFAIK.

	Yep.

> I think this only works for floats.

	That's indeed what the docs seem to imply (IMO it would be quite sad
if there's such a limitation).  Actually I never tried using anything but
a constant for this command-line option.

	- NC


Post a reply to this message

From: gregjohn
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 31 May 2007 14:25:02
Message: <web.465f11db9c2d5fa540d56c170@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> Simple solution:
>
> for file in *.png ; do
>    cp $file temp.png
>    povray -iscene.pov [options]
>    -o`echo "$file" | sed 's?png$?render.png?'`
> done
>
> where scene.pov always uses temp.png
>
> -- Christoph


Thanks.  But to make sure I understand what's happening there, could you
briefly explain line by line, especially the [options] part? I'm trying to
figure out what kind of iscene.pov I would have to set up beforehand.


Post a reply to this message

From: Christoph Hormann
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 31 May 2007 15:35:03
Message: <f3n7pp$htp$1@chho.imagico.de>
gregjohn wrote:
> 
> Thanks.  But to make sure I understand what's happening there, could you
> briefly explain line by line, especially the [options] part? I'm trying to
> figure out what kind of iscene.pov I would have to set up beforehand.

well - i won't give a whole shell scripting tutorial here but the "for 
file in *.png ; do" together with the "done" is a loop setting variable 
'file' to each of '*.png'.

cp $file temp.png

should be obvious.

povray -iscene.pov [options] -o...

is simply meant to render scene.pov (which is supposed to use image file 
temp.png somewhere of course) with additional options of your choice 
into image file ... which is the output of

echo "$file" | sed 's?png$?render.png?'

which replaces the ending 'png' in the file name with 'render.png' so 
image.png results in image.render.png (the '$' in the sed command 
matches the string end so only a trailing 'png' is replaced).

Christoph

-- 
Views of the Earth: http://earth.imagico.de/
Images, include files, tutorials: http://www.imagico.de/
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: Nicolas Calimet
Subject: Re: bash: povray INPUT_PNG.png MY_INI.ini
Date: 31 May 2007 15:49:44
Message: <465f26d8$1@news.povray.org>
>   povray -iscene.pov [options] \
>   -o`echo "$file" | sed 's?png$?render.png?'`

	... which might better be:

povray scene.pov [options] -o${file%%png}render.png

	:-)

	- NC


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.