Recently, I wrote Matlab code that does some processing, plots the results and saves the plots as compressed JPEGs. When I run it on a cluster as part of a batch job I got the following error: "Problem calling GhostScript. System returned error".

Apparently Matlab releases prior to R2007a suffer from a bug to do with printing compressed JPEGs. Here is how to reproduce the above error. First, run Matlab as follows:

matlab -nodisplay

Or alternatively like so:

matlab -nodesktop -nosplash

The unset DISPLAY command simulates the non-interactive conditions that exist when you run a Matlab script from batch jobs using for example bash commands such as:

matlab -nodesktop -nosplash < job.m 2>&1 |tee ".log"
matlab -nodisplay < job.m 2>&1 |tee ".log"

Once Matlab starts, type in the following.

>> figure
>> print -djpeg70 'figure.jpg'

Running the above commands from Matlab release prior to R2007a produces the following errors.

??? Error using ==> graphics/private/ghostscript
Error using ==> graphics/private/ghostscript
Problem calling GhostScript. System returned error

To get around this problem you could a) update to Matlab R2007a or newer, b) disable JPEG compression as shown below,

>> figure
>> print -djpeg 'figure.jpg'

or c) use a different image format, such as PNG, if appropriate.

>> figure
>> print -dpng 'figure.png'

  • What is your reaction?
  • powered by Verysign
  • like
  • unmoved
  • amused
  • excited
  • angry
  • sad
TENDINTA  |  From history: EEE-PC 701 (long overdue) - review
Zona de mobile
34 articole
In context

  • Comment
  • powered by Verysign

Nici un comentariu inca. Fii primul!