POV-Ray : Newsgroups : povray.advanced-users : Get image file name from the code Server Time
5 Jul 2024 15:14:04 EDT (-0400)
  Get image file name from the code (Message 1 to 8 of 8)  
From: Zoly
Subject: Get image file name from the code
Date: 26 Aug 2007 07:37:36
Message: <46d16600$1@news.povray.org>
Hi,

Is there any way to know the final name of the image file that is being 
created from the code?

I want to preprocess a series of frames and store the radiosity information 
(save_file option) in a different file for each frame so that I can reuse 
them later in the same serie of frames at a higher quality. I would like the 
radiosity file to have the same name than the image file but with a 
diffreent extension but I can't imagine how can i get the file image name 
(my_image001.bmp, for instance).

Thanks,
Zoly


Post a reply to this message

From: Alain
Subject: Re: Get image file name from the code
Date: 26 Aug 2007 11:12:44
Message: <46d1986c@news.povray.org>
Zoly nous apporta ses lumieres en ce 2007/08/26 07:37:
> Hi,
> 
> Is there any way to know the final name of the image file that is being 
> created from the code?
> 
> I want to preprocess a series of frames and store the radiosity information 
> (save_file option) in a different file for each frame so that I can reuse 
> them later in the same serie of frames at a higher quality. I would like the 
> radiosity file to have the same name than the image file but with a 
> diffreent extension but I can't imagine how can i get the file image name 
> (my_image001.bmp, for instance).
> 
> Thanks,
> Zoly 
> 
> 
The image's name is the same as that of the scene file.
scene.pov -> scene.bmp
Unless you specificaly set it to something else.

In the case of an animation, it's:
scene.pov -> scene01.bmp, scene02.bmp, scene03.bmp,...
If your animation is up to 9 frames, it use 1 digit.
If your animation is 10 to 99 frames, it use 2 digits.
If your animation is 100 to 999 frames, it use 3 digits...
To save the radiosity data for each frame, you need to specify the naming yourself:
save_file concat("Some_name",str(frame_number,-2,0),".rad")
will create files of the format:
Some_namexx.rad

You can change the file format by using some command-line parameter: +fn set the 
output as PNG for example. You can add this to the main ini file to set it for 
all produced images: add a line with "+fn" to povray.ini. PNG is lossless and a 
LOT smaller than BMP. You can't set the output to JPG. Read the documentation 
for the supported image formats and the coresponding switches.

-- 
Alain
-------------------------------------------------
Scientology: If shit happens, see "Dianetics", p.157.


Post a reply to this message

From: Zoly
Subject: Re: Get image file name from the code
Date: 27 Aug 2007 05:15:52
Message: <46d29648$1@news.povray.org>
Thank you for your illustration about file types, compression types and 
naming conventions for frame images.

Regarding my question, I guess that the answer is: No, it is not possible to 
know the file name of the image that is being created from the SDL code.

Regards,
Zoly.

"Alain" <ele### [at] netscapenet> wrote in message 
news:46d1986c@news.povray.org...
> Zoly nous apporta ses lumieres en ce 2007/08/26 07:37:
>> Hi,
>>
>> Is there any way to know the final name of the image file that is being 
>> created from the code?
>>
>> I want to preprocess a series of frames and store the radiosity 
>> information (save_file option) in a different file for each frame so that 
>> I can reuse them later in the same serie of frames at a higher quality. I 
>> would like the radiosity file to have the same name than the image file 
>> but with a diffreent extension but I can't imagine how can i get the file 
>> image name (my_image001.bmp, for instance).
>>
>> Thanks,
>> Zoly
> The image's name is the same as that of the scene file.
> scene.pov -> scene.bmp
> Unless you specificaly set it to something else.
>
> In the case of an animation, it's:
> scene.pov -> scene01.bmp, scene02.bmp, scene03.bmp,...
> If your animation is up to 9 frames, it use 1 digit.
> If your animation is 10 to 99 frames, it use 2 digits.
> If your animation is 100 to 999 frames, it use 3 digits...
> To save the radiosity data for each frame, you need to specify the naming 
> yourself:
> save_file concat("Some_name",str(frame_number,-2,0),".rad")
> will create files of the format:
> Some_namexx.rad
>
> You can change the file format by using some command-line parameter: +fn 
> set the output as PNG for example. You can add this to the main ini file 
> to set it for all produced images: add a line with "+fn" to povray.ini. 
> PNG is lossless and a LOT smaller than BMP. You can't set the output to 
> JPG. Read the documentation for the supported image formats and the 
> coresponding switches.
>
> -- 
> Alain
> -------------------------------------------------
> Scientology: If shit happens, see "Dianetics", p.157.


Post a reply to this message

From: Alain
Subject: Re: Get image file name from the code
Date: 27 Aug 2007 05:52:52
Message: <46d29ef4@news.povray.org>
Zoly nous apporta ses lumieres en ce 2007/08/27 05:15:
> Thank you for your illustration about file types, compression types and 
> naming conventions for frame images.
> 
> Regarding my question, I guess that the answer is: No, it is not possible to 
> know the file name of the image that is being created from the SDL code.
> 
> Regards,
> Zoly.
>
> 
It IS possible to know the image's name: it's the SAME as that of the scene!

-- 
Alain
-------------------------------------------------
Church of SubGenius: BoB shits.


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Get image file name from the code
Date: 27 Aug 2007 08:50:00
Message: <web.46d2c81a21b8a3b2c150d4c10@news.povray.org>
"Zoly" <zol### [at] kroncom> wrote:
> Thank you for your illustration about file types, compression types and
> naming conventions for frame images.
>
> Regarding my question, I guess that the answer is: No, it is not possible to
> know the file name of the image that is being created from the SDL code.
>
> Regards,
> Zoly.
>

Well yes and no I suppose.

Read the docs "3.1.2.4.2  Output File Name" regarding the file name options.
 However, if you are trying to get a scene to know the name of the output
file automatically without hardcoding it, I don't think you can.

Perhaps you can explain what you want to do and a solution can be found.

-tgq


Post a reply to this message

From: Zoly
Subject: Re: Get image file name from the code
Date: 28 Aug 2007 14:44:45
Message: <46d46d1d@news.povray.org>
I just want to create a name for the radiosity info with extension .rad but 
with the same name than the image that is being created. I already did it 
but I am assuming that the output file name is not changed through command 
line options or the .ini file and also I am assuming that the number of 
frames is not greater than a certain number. Remember that name of the 
output of a frame not only epends on the frame number but also on the total 
number of frames (the number of digits).

I have been programming during 25 years and I learnt that assumimg things in 
the code is not a good practice. I just wanted to be sure that hardcoding 
the file name was the only way to do it and that there is not a constant or 
system variable that gives the name of the file.

Cheers!

Zoly.

"Trevor G Quayle" <Tin### [at] hotmailcom> wrote in message 
news:web.46d2c81a21b8a3b2c150d4c10@news.povray.org...
> "Zoly" <zol### [at] kroncom> wrote:
>> Thank you for your illustration about file types, compression types and
>> naming conventions for frame images.
>>
>> Regarding my question, I guess that the answer is: No, it is not possible 
>> to
>> know the file name of the image that is being created from the SDL code.
>>
>> Regards,
>> Zoly.
>>
>
> Well yes and no I suppose.
>
> Read the docs "3.1.2.4.2  Output File Name" regarding the file name 
> options.
> However, if you are trying to get a scene to know the name of the output
> file automatically without hardcoding it, I don't think you can.
>
> Perhaps you can explain what you want to do and a solution can be found.
>
> -tgq
>
>


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Get image file name from the code
Date: 28 Aug 2007 17:25:13
Message: <46d492b9$1@news.povray.org>
> I have been programming during 25 years and I learnt that assumimg things in 
> the code is not a good practice. I just wanted to be sure that hardcoding 
> the file name was the only way to do it and that there is not a constant or 
> system variable that gives the name of the file.

I suppose there is no way to do that in POVRay itself, but you can
call it from the command line to get external control over the render
and file name. You can even pass parameters to the scene file, although
this does not seem to work for string parameters. You can get around
that by writing the string into a file.

For example, to create a web page button for a given caption I used:

@echo off
echo "%1" > caption.txt
CALL render_image 0
move button.png buttons\%1_normal.png
CALL render_image 1
move button.png buttons\%1_highlighted.png
CALL render_image 2
move button.png buttons\%1_pressed.png

where render_image.bat was just

pvengine -D +a0.2 +w100 +h20 +FN +UA /EXIT button.pov Declare=STATE=%1

and button.pov reading caption.txt, with "STATE" set from command line.

And yes, it's a bit annoying that each invocation pops up the GUI,
makes it impossible to run this in the background, although MegaPOV
might not have this issue ;)


Post a reply to this message

From: Tim Attwood
Subject: Re: Get image file name from the code
Date: 28 Aug 2007 21:02:33
Message: <46d4c5a9$1@news.povray.org>
>I just want to create a name for the radiosity info with extension .rad but 
>with the same name than the image that is being created. I already did it 
>but I am assuming that the output file name is not changed through command 
>line options or the .ini file and also I am assuming that the number of 
>frames is not greater than a certain number. Remember that name of the 
>output of a frame not only epends on the frame number but also on the total 
>number of frames (the number of digits).
>
> I have been programming during 25 years and I learnt that assumimg things 
> in the code is not a good practice. I just wanted to be sure that 
> hardcoding the file name was the only way to do it and that there is not a 
> constant or system variable that gives the name of the file.

You can access the frame number with the frame_number system variable.
With a little bit of string manipulation you can stick the frame number onto
a hard coded name.

#declare final_radiosity = off;
#declare rname = concat("radiosity_data",str(frame_number,0,0),".dat");

global_settings {
   // settings
   #if (final_radiosity)
      radiosity {
        load_file rname
         // radiosity settings
      }
   #else
      radiosity {
         // radiosity settings
        save_file rname
      }
   #end
}

If you don't have many moving objects and are just moving the camera
around then you don't need to recalculate the all the radiosity data for
every frame... it's OK to just use load_file and save_file with a single
file, you load the file, let it calculate the "holes" in the data, then save 
the
updated file for the next frame.

#declare final_radiosity = on;

global_settings {
   // settings
   #if (final_radiosity)
      radiosity {
        load_file "radiosity_data.dat"
         // radiosity settings
        save_file "radiosity_data.dat"
      }
   #else
       // no radiosity for previews
   #end
}


Post a reply to this message

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