Python Forum
attempting to run gimp-console from python in windows 10
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
attempting to run gimp-console from python in windows 10
#1
Hi all,
I'm trying to run gimp-console 2.8 via the subprocess.check_output command but it doesn't seem to work. I get "error [WinError 2] The system cannot find the file specified". If I use subprocess.Popen it's fine but obviously I don't want multiple console windows! Does anyone have an idea what I'm doing wrong?
Reply
#2
Please post your code in code tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
import os, sys
from os import listdir
from os.path import isfile, join
import PIL
from PIL import Image
from PIL import ImageOps
import subprocess
import time
import argparse

def main():

    #size = 184, 138
    #size2 = 216, 120
    #	Usage: 	--size [filesize] --path [imgpath]
    #	Handle command line arguments for the script
    parser = argparse.ArgumentParser(description='Convert image files to file size and 15 colours for SGDK.')
    parser.add_argument('--size', help='Target size of images...')
    parser.add_argument('--path', help='Path of images convert...')

    if len(sys.argv)==1:
            parser.print_help()
            sys.exit(1)

    #	Parse arguments into namespace object to reference later in the script
    global args
    args = parser.parse_args()

    size = args.size
    print(size)
    path = args.path
    print(path)
  
    resizedOutputPath = path + "\\Resized\\"
    inputPath = path + "\\"
    outputPath = path + "\\Gimped\\"
    outputPath2 = outputPath.replace("\\", "\\\\")
    outputPath3 = outputPath.replace("\\", "\\\\")

    try:
        if not os.path.exists(resizedOutputPath):
            os.makedirs(resizedOutputPath)
    except IOError as e:
        print(e)

    try:
        if not os.path.exists(outputPath):
            os.makedirs(outputPath)
    except IOError as e:
        print(e)
             
    files = [f for f in listdir(path) if isfile(join(path, f))]
        
    for filename in files:
        print('Processing File: ' + filename)
        try:
            basewidth = 216
            img = Image.open(inputPath + filename)
            wpercent = (basewidth / float(img.size[0]))
            hsize = int((float(img.size[1]) * float(wpercent)))
            img = img.resize((basewidth, hsize), PIL.Image.ANTIALIAS)
            img = img.crop((0, 1, 216, 121))
            img.save(resizedOutputPath + filename)
            img.close()
            cmd = "gimp-console-2.8.exe -i -b \"(let* ( (image (car (file-png-load 0 \\" + "\"" + outputPath2 + filename + "\\\" \\\"" + outputPath2 + filename + "\\\")))(drawable (car (gimp-image-get-active-layer image))))(gimp-convert-rgb image) (gimp-image-convert-indexed image 0 0 16 0 1 \\\"\\\") (file-png-save 1 image drawable " + "\\\"" + outputPath3 + filename + "\\\" \\\"" + outputPath3 + filename + "\\\" 0 0 0 0 0 0 1) (gimp-quit 0))\""
            print(cmd)
            print(subprocess.check_output([cmd]))
        except IOError as e:
            print(e)
                 
if __name__ == "__main__":
    main()
Reply
#4
Any help would be gratefully received
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  In Console,Python anna17 0 135 Mar-23-2024, 08:24 PM
Last Post: anna17
  Attempting to read keyboard outside of console Jimmy998 5 1,288 Nov-25-2022, 08:17 PM
Last Post: Larz60+
  Python Flask Realtime system printout (console) ffmpeg jttolleson 3 2,862 Apr-18-2022, 06:39 PM
Last Post: jttolleson
Bug beginner attempting to make chatbot MonikaDreemur 1 1,080 Feb-02-2022, 10:24 PM
Last Post: BashBedlam
  Python library for win32 console commands eldiener 3 3,384 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Newbie to Python (Attempting to install DJango on a VPS) jarjar95 0 1,506 May-04-2021, 03:51 PM
Last Post: jarjar95
  Problem: Restart kernel onPydev console when trying to install a python package poppy2020 1 7,568 Nov-25-2020, 06:13 PM
Last Post: Larz60+
  to call via console a python-programm Liki 9 3,139 Nov-22-2020, 01:10 AM
Last Post: bowlofred
  Super Urgent, work related. Gimp Python tsurubaso 5 2,878 Oct-19-2020, 08:18 AM
Last Post: tsurubaso
  List index out of range error when attempting to make a basic shift code djwilson0495 4 2,938 Aug-16-2020, 08:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020