Search code examples
python-2.7powershellsubprocessirfanview

python subprocess call to irfanview fails


I'm attempting to get Irfanview to extract some multipage images for me. As you can't batch do that operation within Irfanview I'm trying to use Pythons subprocess.call() to do the commandline work for me.

I've got the command in powershell working fine with no issues. But when I try the exact same command via subprocess.call() Irfanview tells me I've got an "unsupported save type !"

PS command:

i_view32.exe .\multiPage.tif /extract=(".\,tif")

Python code:

cmd = r'i_view32.exe .\multiPage.tif /extract=(".\,tif")'
subprocess.call(cmd, shell=True)

I've tried with no shell too. Also I tried giving it fully qualified names. No difference.

Any ideas?

Cheers,

James


Solution

  • Ahh. I've found the problem. Turns out in PS I need to give the extract folder path as a string whereas via Python I don't.

    So in Py instead of

    i_view32.exe .\multiPage.tif /extract=(".\,tif")
    

    It needed to be

    i_view32.exe .\multiPage.tif /extract=(.\,tif)
    

    Thats actually the same way that the Irfanview manual asks for it. No idea why PS demanded the string bit.