Bug 699780 - Importing EPS file with CMYK colors into scribus fails
Summary: Importing EPS file with CMYK colors into scribus fails
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Regression (show other bugs)
Version: 9.24
Hardware: PC Linux
: P4 normal
Assignee: Default assignee
QA Contact: Bug traffic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-17 11:16 UTC by David Kaspar [Dee'Kej]
Modified: 2018-09-17 14:19 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
reproducer script (274 bytes, application/x-shellscript)
2018-09-17 11:16 UTC, David Kaspar [Dee'Kej]
Details
redacted2.eps (23.53 KB, image/x-eps)
2018-09-17 11:17 UTC, David Kaspar [Dee'Kej]
Details
import.prolog (32.70 KB, text/x-matlab)
2018-09-17 11:23 UTC, David Kaspar [Dee'Kej]
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Kaspar [Dee'Kej] 2018-09-17 11:16:19 UTC
Created attachment 15639 [details]
reproducer script

Hello guys,

this is the recent report we have received in Fedora. When user tries to import EPS file with CMYK colors into scribus, the underlying ghostscript call fails.

This started to happen after user has upgraded to version 9.24. Before it the 9.23 was working for him. I have also tried the 9.25 version, but the result is the same.

I'm attaching all the necessary files for you to reproduce this.

Reproducer:
-----------
#!/bin/bash

mkdir -p /tmp/gs

gs -q -dNOPAUSE -dNODISPLAY -dBATCH -dDELAYBIND -g1236x1336 -r288 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -c 0 0 translate -sTraceFile=/tmp/gs/ps.out -sExportFiles=/tmp/gs/redacted ./import.prolog ./redacted2.eps -c flush cfile closefile quit


Command line output:
--------------------
GPL Ghostscript 9.24: Unrecoverable error, exit code 1
ngval--   100   1.0   1.0   DeviceCMYK   1.3
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2014   1   3   %oparray_pop   2013   1   3   %oparray_pop   --nostringval--   1997   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %loop_continue   --nostringval--
Dictionary stack:
   --dict:980/1684(ro)(G)--   --dict:0/20(G)--   --dict:179/200(L)--   --dict:160/300(L)--
Current allocation mode is local
Current file position is 24304


Result file:
------------
gs
gr
gs
gr
gs
gs
fill-winding
n
co 0.8 0.0 1.0 0.1


Additional info (from user):
----------------------------
- The same import problem exists with EPS exported by scribus.

- The same import problem exists with a test build of scribus 1.4.7 (which apparantly fixes an incompatibility between scribus and gs 1.22) and a test build of ghostscript 9.25 (which contains more fixes to the SAFER/DELAYBIND issues).

- With gostscript 9.23-1, scribus 1.4.6 imports all these EPS happily (the test case above, as well as the exports by scribus 1.4.6 and 1.4.7).
Comment 1 David Kaspar [Dee'Kej] 2018-09-17 11:17:29 UTC
Created attachment 15640 [details]
redacted2.eps

File needed for the reproducer.
Comment 2 David Kaspar [Dee'Kej] 2018-09-17 11:23:23 UTC
Created attachment 15641 [details]
import.prolog

Additional file needed for the reproducer.
Comment 3 Ken Sharp 2018-09-17 12:37:38 UTC
The file import.prolog contains two uses of the non-standard operator '.currentopacityalpha':

/writecurrentcmykcolor
{
	currentcmykcolor	% -> c m y k
	(co )print
	3 index i_str cvs print
	( ) print
	2 index i_str cvs print
	( ) print
	1 index i_str cvs print
	( ) print
	i_str cvs print
	( ) print
	pop pop pop
	.currentopacityalpha	% a
	i_str cvs print
	(\n) print
} bind def


/writecurrentrgbcolor
{
	currentrgbcolor	% -> r g b
	(corgb )print
	2 index i_str cvs print
	( ) print
	1 index i_str cvs print
	( ) print
	i_str cvs print
	( ) print
	pop pop
	.currentopacityalpha	% a
	i_str cvs print
	(\n) print
} bind def

This operator was removed from systemdict in either 9.22 or 9.23 (I forget exactly which), but due to a programming error remained available if -dDELAYBIND was set. This error was fixed in the 9.25 release, with the result that this usage failed.

The file is already run with -dDELAYBIND in order to capture other non-standard (PDF related) operators so the simple solution is to do the same for this non-standard PostScript operator.

Moving the definition of these two procedures into the section executed before .bindnow results in working code for me.

I'm marking this as 'invalid' only because I don't have a better way to close it, the only other options would be worksforme or wontfix, neither of which feels like a better resolution description.

The removal of non-standard PostScript is likely to continue.
Comment 4 David Kaspar [Dee'Kej] 2018-09-17 12:55:43 UTC
This is the comment we got from the OP:
---------------------------------------
I suspect that scribus' import.prolog and the new safer gs are at odds.

Given that scribus "just" released their final version for the 1.4 branch (1.4.7) we'd probably have to patch downstream. The scribus 1.5 uses a different importer (poppler based).

Indeed: 1.5.4 from copr luya/scribus imports all these EPS just fine whether my ghostscript is at or 9.24-1 or 9.23-1 (which is not used by scribus 1.5.x).
Comment 5 M.J.G. 2018-09-17 13:20:07 UTC
I moved those two defs right before the ".bindnow".

With that prolog, the EPS imports work partly with gs 9.24 - there is no error, but the imported EPS has all colors set to "none" (shapes are there, but invisible).

I'm no PS programmer, so any hints are appreciated.
Comment 6 Ken Sharp 2018-09-17 13:32:25 UTC
(In reply to M.J.G. from comment #5)
> I moved those two defs right before the ".bindnow".
> 
> With that prolog, the EPS imports work partly with gs 9.24 - there is no
> error, but the imported EPS has all colors set to "none" (shapes are there,
> but invisible).
> 
> I'm no PS programmer, so any hints are appreciated.

Try this:

currentdict /doimage {
	currentdict i_image
	//doimage exec
} .forceput
end
/.currentopacityalpha {//.currentopacityalpha} bind def
setglobal
.bindnow

That is, add the definition of /.currentopacityalpha just after the 'end' and before the 'setglobal'.
Comment 7 M.J.G. 2018-09-17 14:15:01 UTC
(In reply to Ken Sharp from comment #6)
> (In reply to M.J.G. from comment #5)
> > I moved those two defs right before the ".bindnow".
> > 
> > With that prolog, the EPS imports work partly with gs 9.24 - there is no
> > error, but the imported EPS has all colors set to "none" (shapes are there,
> > but invisible).
> > 
> > I'm no PS programmer, so any hints are appreciated.
> 
> Try this:
> 
> currentdict /doimage {
> 	currentdict i_image
> 	//doimage exec
> } .forceput
> end
> /.currentopacityalpha {//.currentopacityalpha} bind def
> setglobal
> .bindnow
> 
> That is, add the definition of /.currentopacityalpha just after the 'end'
> and before the 'setglobal'.

Cool, that did it!

I'll prepare a hotfix for scribus in Fedora and will try to upstream this with scribus.
Comment 8 Ken Sharp 2018-09-17 14:19:00 UTC
(In reply to M.J.G. from comment #7)

> > That is, add the definition of /.currentopacityalpha just after the 'end'
> > and before the 'setglobal'.
> 
> Cool, that did it!

Aha, good to know that works.

 
> I'll prepare a hotfix for scribus in Fedora and will try to upstream this
> with scribus.

Great thanks for that!