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

  • 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:

    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.

  • 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.

  • 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:

    Code
    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:

    Code
    %%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

    Code
    help for


    in the command line,

    best regards,
    Klaus

  • 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

    Edited 3 times, last by mham (September 11, 2009 at 9:19 AM).

  • Hi mham,

    Quote

    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:
    https://krpano.com/tools/ktransform/

    Quote

    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:


    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:


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

    I hope this can help.

    Salut.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!