2

I am creating a paint-like app in Python and I am saving the canvas using Ghostscript with subprocess inside python. The script works fine and I get the desired output, but If there is any blank space in the destination, Ghostscript breaks at that point and returns an error. eg :

destination = "/Volumes/Personal/Personal Works/myImage"
convertCode = "gs -dSAFER -dNOPAUSE -dBATCH -r300 -g1000x1000 -sDEVICE=pngalpha -sOutputFile=" + destination + ".png " + tempFile
subprocess.call(convertCode, shell=True)

This returns an

Error: /undefinedfilename in (Works/Untitled.png)

this clearly shows the Ghostscript breaks due to the space in the destination name. Destination with no space in the middle has no problem. How to solve this problem.

Ranga RS
  • 142
  • 9
  • @PatrickHaugh it works :D it's called short name it seems. A quick way to find the pattern for the respective os will be to drag and drop the folder in terminal. Thank you for the fast response :) – Ranga RS Oct 29 '17 at 18:59
  • Just put quotes "" around the path and filename. I've no idea how to escape a " in Python but it allows you to use the real path without having to hash it. – KenS Oct 29 '17 at 19:57

0 Answers0