Issue converting from EPS to PNG when called from Web application server

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: helmut, XnTriq, xnview

Ajax83
Posts: 4
Joined: Fri Mar 21, 2025 12:20 pm

Issue converting from EPS to PNG when called from Web application server

Post by Ajax83 »

Hi I need some help,

I have a .bat file (C:\Tools\testConversion.bat), which has the two NConvert commands I am using:

C:\Tools\nconvert.exe -overwrite -out png c:\images\*.eps
C:\Tools\nconvert.exe -overwrite -resize 25%% 25%% -out png c:\images\*.tif

When I run the .bat file from command line both NConvert commands work as expected and produce a .png file foreach eps and tiff file found in the c:\images directory. This tells me the eps image files are good.

However, when I call this .bat script from an web application server using java code,
1. eps conversion fails: The NConvert command to convert eps images to png fails and reports the message: Error: Don't know how to read this picture (<inputfile.eps>).

2. tif image files conversion are successful

Since the tiff image conversion works, it tells me that there are no problems with permissions, paths or environment variables.
But I don’t know why eps image conversion fails.

My web application server is Wildfly, hosting my java web application. The java code to call the script is:

// command to run
String cmd = "cmd.exe /c \"C:\\Tools\\testConversion.bat\"" ;
// setup env
String[] env = {"Path=C:\\WINDOWS\\system32;C:\\WINDOWS;"};
// call script
Runtime.getRuntime().exec(cmd, env);

Wildfly, nconvert, my script testConversion.bat and all the image files are all on my local machine, and the eps conversion still fails.

I’m at a loss trying to find out why the eps conversion works from command line and not when called from the WildFly application server and the tiff conversion does work in both cases.

The following are NConvert version information:

** NCONVERT v7.192 (c) 1991-2024 Pierre-E Gougelet (Aug 26 2024/11:00:16) **
Version for Windows 7/8/10/11 x64 (All rights reserved)

Thank you
cday
XnThusiast
Posts: 4356
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Issue converting from EPS to PNG when called from Web application server

Post by cday »

Well above my pay grade, but could it possibly relate to access to Ghostscript, which xnview software uses to rasterize PDF, PS and AI files, when run the second way??
Ajax83
Posts: 4
Joined: Fri Mar 21, 2025 12:20 pm

Re: Issue converting from EPS to PNG when called from Web application server

Post by Ajax83 »

cday wrote: Fri Mar 21, 2025 5:29 pm Well above my pay grade, but could it possibly relate to access to Ghostscript, which xnview software uses to rasterize PDF, PS and AI files, when run the second way??
according to the nconvert file Formats.txt, eps does not need a plugin. This is my understanding.
cday
XnThusiast
Posts: 4356
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Issue converting from EPS to PNG when called from Web application server

Post by cday »

Ghostscript is not a plugin in the normal sense, but is required by xnview software to rasterize certain file formats so that they can be viewed.

You might test whether you can open PDF files, which also require Ghostscript to be installed and accessible.

Note that when Ghostscript is used, files are opened at 72 DPI unless the -dpi switch is used to set a different, normally higher, value.

As your code runs when run as a .bat file but not when run using your alternative code, when .tif files are read but not EPS files, my suggestion was that possibly that code was for some reason unable to access Ghostscript.
Ajax83
Posts: 4
Joined: Fri Mar 21, 2025 12:20 pm

Re: Issue converting from EPS to PNG when called from Web application server

Post by Ajax83 »

Thank you for your reply and help. The issue here is, I don’t have Ghostscript installed on my local machine and when I run the .bat file from command line I’m able to convert the eps files to png. It’s when called from an application serve, I receive the message: Error: Don't know how to read this picture (<inputfile.eps>).
cday
XnThusiast
Posts: 4356
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Issue converting from EPS to PNG when called from Web application server

Post by cday »

Ajax83 wrote: Sat Mar 22, 2025 12:52 pm The issue here is, I don’t have Ghostscript installed on my local machine and when I run the .bat file from command line I’m able to convert the eps files to png. It’s when called from an application serve, I receive the message: Error: Don't know how to read this picture (<inputfile.eps>).
This is the xnview wiki file which states the requirement for Ghostscript to open EPS files, written I believe by forum guru XnTriq. I can't at the moment add anything to my previous posts, and as I said my experience does not extend to your alternative way of running your code. But there must be an explanation for what you are seeing!
Ajax83
Posts: 4
Joined: Fri Mar 21, 2025 12:20 pm

Re: Issue converting from EPS to PNG when called from Web application server

Post by Ajax83 »

Hi cday,

We installed Ghostscript and added it to the system path. When we call the .bat file from our web application server using java code, NConvert now produces a .png file foreach eps file found in the c:\images directory. Your suggestion works!

We are still curious why when called from command line we were able to convert .eps files to .png files prior to installing Ghostscript.

Once again thank you for all your help.
cday
XnThusiast
Posts: 4356
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Issue converting from EPS to PNG when called from Web application server

Post by cday »

Ajax83 wrote: Tue Mar 25, 2025 2:15 pm We installed Ghostscript and added it to the system path. When we call the .bat file from our web application server using java code, NConvert now produces a .png file foreach eps file found in the c:\images directory. Your suggestion works!

We are still curious why when called from command line we were able to convert .eps files to .png files prior to installing Ghostscript.
Well above my pay grade! :wink:

XnTriq?
cday
XnThusiast
Posts: 4356
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Issue converting from EPS to PNG when called from Web application server

Post by cday »

Ajax83 wrote: Tue Mar 25, 2025 2:15 pm We are still curious why when called from command line we were able to convert .eps files to .png files prior to installing Ghostscript.
Could you possibly have had Ghostscript installed without realising it, try typing 'ghostscript - help' at the command prompt.

Ghostscript must, as no doubt mentioned in the wiki, be the same bit depth as the application that calls it, and both 32-bit and 64-bit versions can if needed be installed on Windows 64-bit.