How to convert eps files to Adobe Illustrator version 10 EPS via python

40 Views Asked by At

i am looking for python code that converts eps files to Adobe Illustrator version 10. can you help?

import subprocess
import os

def convert_to_ai10(input_eps, output_ai10_eps):
    # Full path to the Ghostscript executable (adjust the path as needed)
    ghostscript_path = r'C:\Program Files\gs\gs9.54.0\bin\gswin64c.exe'

    # Full path to the input EPS file
    full_input_eps = os.path.abspath(input_eps)

    command = [
        ghostscript_path,
        '-sDEVICE=eps2write',  # Hedef cihaz EPS
        '-dEPSCrop',           # Crop to bounding box
        '-o', output_ai10_eps, # Hedef AI 10 uyumlu EPS dosyası adı
        full_input_eps         # Full path to the input EPS file
    ]

    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, error = process.communicate()

    print("Output:", output.decode('utf-8'))
    print("Error:", error.decode('utf-8'))

input_eps_file = 'a.eps'
output_ai10_eps_file = 'output_ai10.eps'

convert_to_ai10(input_eps_file, output_ai10_eps_file)

wrote this code chatgpt but it never works. can you help?

0

There are 0 best solutions below