Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 9th, 2013  |  syntax: Python  |  size: 0.96 KB  |  views: 91  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python
  2.  
  3. import os
  4. from gimpfu import *
  5.  
  6. def batch_convert(img, layer, inputFolder, outputFolder):
  7.         # Iterate the folder
  8.         for file in os.listdir(inputFolder):
  9.                 try:
  10.                         # Build the full file paths.
  11.                         inputPath = inputFolder + "\\" + file
  12.                         outputPath = outputFolder + "\\" + file
  13.                        
  14.                         # Open the file if is a DDS image.
  15.                         image = pdb.file_dds_load(inputPath, inputPath, 0, 0)
  16.                         pdb.file_dds_save(image, drawable, outputPath, outputPath, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1)
  17.                        
  18.                 except Exception as err:
  19.                         gimp.message("Unexpected error: " + str(err))
  20.  
  21. register(
  22.     "python_fu_test_batch_convert",
  23.     "Batch Convert",
  24.     "Converts DDS to DTX5 W Mipmaps",
  25.     "JT",
  26.     "Open source (BSD 3-clause license)",
  27.     "2013",
  28.     "<Image>/Filters/Test/Batch DDS",
  29.     "*",
  30.     [
  31.         (PF_DIRNAME, "inputFolder", "Input directory", ""),
  32.         (PF_DIRNAME, "outputFolder", "Output directory", "")
  33.     ],
  34.     [],
  35.     batch_convert)
  36.  
  37. main()