Question

I got an postscript file from a NCL script whit the mpDataBaseVersion = "HighRes" (high resolution map). and I got ImageMagick 6.2.8 run in RHEL 5.6 i386.

when I ran convert high-resolution.ps test.png, I got:

Error: /undefinedresult in --ashow--

Operand stack:
   0   0   ( )

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--

Dictionary stack:
   --dict:1171/1684(ro)(G)--   --dict:0/20(G)--   --dict:143/200(L)--

Current allocation mode is local
Current file position is 629039

but the same postscript convert without error in RHEL 3 i386 with ImageMagick 5.5.6, how come?

I googled for a while, but I still have no idea for that undefinedresult in ashow error.
and what was the execution stack means?


[UPDATE]

Thanks, @Fred and @Ken !
I restructured my problem below:

I have a big PostScript file (9.3 MB): high_resolution.ps

PC A:

  • Red Hat Enterprise Linux ES release 3 (Taroon Update 3) i386
  • Convert Version: ImageMagick 5.5.6 04/01/03 Q16
  • Ghostscript Version: GNU Ghostscript 7.05 (2002-04-22)

PC B:

  • Red Hat Enterprise Linux Server release 5.6 (Tikanga) i386
  • Convert Version: ImageMagick 6.2.8 05/07/12 Q16
  • Ghostscript Version: GPL Ghostscript 8.70 (2009-07-31)

convert high_resolution.ps high_resolution.png works in PC A, but not in PC B.

the error was above.
and I check the Ghostscript changelog, I got nothing about that (maybe I just missed it ?)

A lots of appreciation! 謝謝!

Was it helpful?

Solution

Almost certainly you are using different versions of Ghostscript (which ImageMagick uses to deal with PostScript). What version of Ghostscript do you have installed on each ?

Undefinedresult means what it says, the result of an operation is undefined (this is usually caused by a divide-by-zero). The execution stack tells you what was on the execution stack at the point the interpreter encountered the error. Unless you understand Postscript (and to be honest, the Ghostscript interpreter) it doesn't tell you anything meaningful.

I can't say any more without seeing the file which causes the error. Remember, PostScript is a programming language, so error messages are just a starting point.

UPDATE

I've retrieved the file and I can confirm that I get the error when running it through a current version of Ghostscript. Adobe Acrobat Distiller gives a very similar error (undefinedresult with setcachedevice) so its practically certain that the file is illegal. I'll say more when I've had a chance to determine why.

On a side note, both these versions of Ghostscript are very elderly, the current version is 9.07

[Update 2]

The offending line is very near the beginning of the file :

/Helvetica 0 Fs 0 0 ( ) As Gr

Because PostScript is a programming language, this fragment uses some procedures defined in the program. What it does is find a font called 'Helvetica', scale it to a size of 0 then show the string ' ' adjusting the width of each glyph by 0.

Several parts of that are clearly nonsense; scaling a font to 0 will make it useless, at best a glyph will mark 1 pixel. showing a string using an operator to adjust the width of each glyph by 0 is clearly pointless. Smarter software wouldn't produce such a PostScript program, but the producer clearly isn't very smart about producing PostScript as can be seen from the rather simple prolog to the file.

Basically the problem is exactly what GS said, the x and y widths are adjusted by using a matrix, and the result of applying the matrix multiplication to a font size of 0 is genuinely undefined.

Your best bet is probably to go back to the original application and remove whatever is causing the text ' ' to be emitted.

If for some reason this is impossible, you can take advantage of the fact that PostScript is a programming language, you can redefine the /ashow operator yourself and have it do nothing if the font size is 0, eg:

/old_ashow /ashow load def /ashow {currentfont /FontMatrix get aload pop pstack 0 1 4 {pop add} for 0 eq {pop pop pop}{old_ashow}ifelse} bind def

Normally I would suggest putting this in a new file and running it through Ghostscript in advance of the file you want to process (eg 'gs mod.ps high_resolution.ps') but because you are using ImagMagick you can't do that. So if you want to do this you will need to modify the high_resolution.ps file and put this at the top of the file. Whenever you modify PostScript files you must be careful to use an editor which can handle binary, and does not alter CR/LF line endings.

Please note that I don't recommend this, it would be better to fix the original file or script producing this PostScript program so that you can use it in other places (eg printing). As it stands it is producing illegal PostScript.

As to why the error does not occur with an (exteremely) old version of Ghostscript; this is almost certainly an oversight. The Adobe Postscript Language Reference Manual lists the possible errors for each operator, but not all the possible circumstances under which an error is raised. Clearly this error condition was added after the release of 7.05, almost certainly when the problem was brought to the developers attention.

OTHER TIPS

The ashow displays text with added extra space to a character. The stack 0 0 tells the system to add zero extra space to the characters. The ( ) is the text to be displayed, which appears to be a single space, but without seeing the actual file in binary it could also be an none displayable character.

If the character is a special character which is not defined, such as a tab character or null, an undefinedresult would make sense. Having a single only a 1 character string might also not make sense.

As already mentioned, what version of ghostscript and seeing the actual file would be helpful.The postmortem dump isn't especially useful, but the execution stack appears like there is a more complex context the error is coming out of.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top