Sie sind nicht angemeldet.

mham

Anfänger

  • »mham« ist der Autor dieses Themas

Beiträge: 28

Wohnort: Stockholm, Sweden

  • Nachricht senden

1

Donnerstag, 10. September 2009, 14:13

script for Transform of all images in a folder

Is there a batch script for ktransform that I can apply to a folder with 100 panorama images and it goes through them one by one and makes cube faces for all of them?

Can anyone good at scripting help?

I'm using Windows Vista & windows XP.


Thanks,
mahmood

2

Donnerstag, 10. September 2009, 22:28

Hi mham,

First, to say that I have really little knowledge about msdos command... *wacko*
I was playing on your request and what I finally got is the following bat code:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off

IF %1 == "" GOTO ERROR
IF NOT EXIST %1 GOTO ERROR

FOR %%V in (%*) do "%~dp0\ktransform" cube6 %%V %%V

GOTO DONE

:ERROR
echo ERROR - drop spherical panorama image to process...
pause

:DONE


The problem with this code is that there is no control of the output format (Tiff or Jpeg).... If your inputs are jpg files then the output will be jpg... If your inputs are tiff files then the output will be tiff... This is because, in this code, the output file argument for Ktransform is the same as the input file argument...
I do not know how to do a different way.

I hope this can help anyway.
Salut.

3

Donnerstag, 10. September 2009, 23:11

I am no expert either, but I believe this will achieve the same thing in .bat





@echo off

IF %1 == "" GOTO ERROR
IF NOT EXIST %1 GOTO ERROR

for %%i in (%*) do (
"%~dp0\ktransform" cube6 %%i "%%~dpni.tif"


)
GOTO DONE

:ERROR
echo ERROR - drop spherical panorama images to create 6 cubes each

:DONE

pause

Once you create a .bat file, you would have to drag your spherical images(as many as you want {I don't know if there may be a limit possibly based on your computer??}) onto the icon and it would create the six cubes in the same folder as the source image. This may prove to be more images than you want in one folder though. If you wanted to change the output format, simply change it in the code.

4

Donnerstag, 10. September 2009, 23:16

The problem with this code is that there is no control of the output format (Tiff or Jpeg).... If your inputs are jpg files then the output will be jpg... If your inputs are tiff files then the output will be tiff... This is because, in this code, the output file argument for Ktransform is the same as the input file argument...
I do not know how to do a different way.
Hi,

thanks for your code

with this would be the code to set a user defined extension and set the format with it:

Quellcode

1
FOR %%V in (%*) do "%~dp0\ktransform" cube6 %%V %%~dpnV.jpg


when a '~' is used after the '%' there the following options possible:
d = drive
p = path
n = name

as example:

Quellcode

1
2
3
4
5
%%V = c:\images\image.tif
%%~nV = image
%%~pnV = \images\image
%%~dpnV = c:\images\image
%%~dpnV.jpg = c:\images\image.jpg


more informations about it when you enter

Quellcode

1
help for 

in the command line,

best regards,
Klaus

5

Donnerstag, 10. September 2009, 23:23

Hi,

Thank you Klaus for your detailed explanation. *thumbup*
Thank you jarredja too. *thumbup*
I can say I have learned something more today. *rolleyes*

Thanks a lot.

6

Donnerstag, 10. September 2009, 23:29

Michel,

My code was simply the

sphere to cube multires code

with the multires part removed. It is straight from the Klaus's tools. *g*

mham

Anfänger

  • »mham« ist der Autor dieses Themas

Beiträge: 28

Wohnort: Stockholm, Sweden

  • Nachricht senden

7

Freitag, 11. September 2009, 07:42

Many many thanks to all who contributed, Jarredja, michel and Klaus. *thumbsup*
This will ease the transform about 100 times.

I suppose if I want to have jpeg quality 95 instead of default and also optimize the jpeg I can change the code to the following?

FOR %%V in (%*) do "%~dp0\ktransform" cube6 %%V %%~dpnV.jpg -jpegoptimize -jpegquality=95 *question*

Also to take it another step further, from Klaus's comment it seems I could put the resulting cube faces in a separate folder, say in "myCubes" folder (and not in the same folder as source images).
I have tried several ways but the cube faces always appear in the same folder as the source image.
How and where in the code can that be done? *question*

Many thanks again for this great help *thumbup*
Mahmood

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »mham« (11. September 2009, 09:19)


8

Freitag, 11. September 2009, 17:41

Hi mham,

Zitat

I suppose if I want to have jpeg quality 95 instead of default and also optimize the jpeg I can change the code to the following?

FOR %%V in (%*) do "%~dp0\ktransform" cube6 %%V %%~dpnV.jpg -jpegoptimize -jpegquality=95 *question*

Yes, you can add all the Ktransform arguments you will need for getting the result you need.
All the possible Ktransform arguments can be found here:
http://krpano.com/tools/ktransform/

Zitat

Also to take it another step further, from Klaus's comment it seems I could put the resulting cube faces in a separate folder, say in "myCubes" folder (and not in the same folder as source images).

Yes, this is possible too.
You can use "%%~dpV\myCubes_folder\%%~nV.jpg" as follow:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off

IF %1 == "" GOTO ERROR
IF NOT EXIST %1 GOTO ERROR

FOR %%V in (%*) do "%~dp0\ktransform"  cube6  %%V  "%%~dpV\myCubes_folder\%%~nV.jpg"  -jpegoptimize  -jpegquality=95

GOTO DONE

:ERROR
echo ERROR - drop spherical panorama image to process...
pause

:DONE

Doing in this way, your resulting cubes images will be located in a new folder called myCubes_folder into the same folder as your input images.


Or, you can use "C:\path_to_myCubes_folder\%%~nV.jpg" as follow:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off

IF %1 == "" GOTO ERROR
IF NOT EXIST %1 GOTO ERROR

FOR %%V in (%*) do "%~dp0\ktransform"  cube6  %%V  "C:\path_to_myCubes_folder\%%~nV.jpg"  -jpegoptimize  -jpegquality=95

GOTO DONE

:ERROR
echo ERROR - drop spherical panorama image to process...
pause

:DONE

Doing in this way, your resulting cubes images will be located into C:\path_to_myCubes_folder .

I hope this can help.

Salut.

mham

Anfänger

  • »mham« ist der Autor dieses Themas

Beiträge: 28

Wohnort: Stockholm, Sweden

  • Nachricht senden

9

Freitag, 11. September 2009, 23:38

Thank you michel,
It works like a charm.


Regards,
Mahmood