Converting tiff file to tx file through maketx utility

This is tne format of maketx.exe command

maketx -v -u --oiio --checknan --filter lanczos3 inputFile.tiff -o fileOut.tx

I can successfully convert my tiff files to tx files by running it on cmd.exe

But when I call this command through subprocess.Popen() like this

subprocess.Popen(["maketx.exe", "-v -u --oiio --checknan --filter lanczos3", "inputFile.tiff", "-o", "fileOut.tx"])

It gives me this error

Invalid option " -v -u --oiio --checknan --filter lanczos3"
am I missing something or I’m using subprocess wrong way?

In the Python subprocess Popen documentation it states:

If args is a string, the interpretation is platform-dependent and described below. See the shell and executable arguments for additional differences from the default behavior. Unless otherwise stated, it is recommended to pass args as a sequence.

Considering you are using an exe I assume you are on Windows, which further states:

A string surrounded by double quotation marks is interpreted as a single argument, regardless of white space contained within. A quoted string can be embedded in an argument.

So to me it looks like that invalid statement is being interpreted as a single argument, but those are multiple args, so you should convert it to a sequence like the others.

https://docs.python.org/2/library/subprocess.html


https://docs.python.org/2/library/subprocess.html#converting-argument-sequence

1 Like

Yeah, my guess is that @sev nailed it. Try something like this:

subprocess.Popen(["maketx.exe", "-v",  "-u",  "--oiio", "--checknan", "--filter", "lanczos3", "inputFile.tiff", "-o", "fileOut.tx"])
1 Like

Yes! It worked! Thanks