Bug 695016 - Gradient eps file to pdf
Summary: Gradient eps file to pdf
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.05
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-04 20:25 UTC by vipula.redcomponent
Modified: 2014-08-17 11:56 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
This is a file I use. (207.54 KB, application/postscript)
2014-02-04 20:25 UTC, vipula.redcomponent
Details
The reaql test file (202.05 KB, application/postscript)
2014-02-10 00:36 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vipula.redcomponent 2014-02-04 20:25:25 UTC
Created attachment 10670 [details]
This is a file I use.

Hey there,

I have sticker site, where I want user to upload sticker text and I then need to send to production, Myproblem is I have gradient eps file Which get blackout in outline mode. Here is Eps www.social.gunjan.intern.redweb.dk/myeps.eps

Now let me describe my process, I resize my eps using below command,

-dBATCH -dNOPAUSE -dEPSFitPage -sOutputFile=/home/tasol/Desktop/rahul/output.eps -sDEVICE=ps2write -c '<< /PageSize [150 150]>> setpagedevice' -f /home/tasol/Desktop/myeps.eps

Once it resize my eps, I create temp PS file and I run eps inside my ps file, And now last step, I run this temp file to create pdf and eps files, I generate both files with pdfwriter. When I view my gradient eps file into outline mode it shows me black part which is covered with gradient.

Other eps files works like charm.

I am using Ubuntu 12.04 with ghostscript 9.05
Comment 1 Ken Sharp 2014-02-08 01:26:06 UTC
OK several pointw:

1) The file you have uploaded here is the output of ps2write. This file works perfectly well and also works with the command line you give. This isn't useful, in order to investigate the problem I need the original source file, in this case that would appear to be the file you refer to as myeps.eps.

2) The ps2write device doesn't emit Encapsulated PostScript (EPS), it emits full blown PostScript. Changing the file extension to .eps doesn't alter this.

3) The ps2write device is not simply 'resizing' your EPS file. The EPS is completely interpreted, converted to graphics primitives, and passed to the ps2write device which creates a brand new file by converting those graphics primitives back to PostScript. 

Its important to understand this because although Ghostscript is a level 3 interpreter the ps2write device only outputs level 2 (hence ps*2*write). Any level 3 constructs in the input will not be preserved. In this case your input file uses shading patterns which are a level 3 feature, after passing through ps2write these will have been rendered to images. This increases the file size and reduces the ability to scale the objects, they are no longer vector primitives.

4) This whole business in unnecessary, the whole point of EPS files is that they are intended to be included in a parent PostScript document. As a result the comments include the size of the graphic, the including application is supposed to use this to scale and position the included graphic as required. So there is no need to 'resize the EPS' at all, you should simply follow the documented procedure for including an EPS file (see the Adobe EPSF specification) and when you 'run the eps inside my ps file' you should set the CTM appropriately first.
Comment 2 Ken Sharp 2014-02-10 00:36:49 UTC
Created attachment 10682 [details]
The reaql test file

The actual original test file, retrieved from the Stack Overflow question where this bug originated. The preview has been removed to reduce the size.
Comment 3 Ken Sharp 2014-02-10 00:37:48 UTC
commit d59e1feb9545b399027907cb2d1a6855c524e0b4 resolves this for me.
Comment 4 vipula.redcomponent 2014-02-10 01:11:53 UTC
4) I do the same, my purpose is to fix my whole eps file with provided dimension, if I only provide dimension via bounding box it returns good file without washing my eps image, but then problem is, bounding box crop my eps by provided dimension instead of resizing it,

so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 

Do you have any better idea to resize my eps instead of cropping? 

I need to resize my eps by entered dimension by user, then I need to include it in ps parent file.
Comment 5 Ken Sharp 2014-02-10 01:15:48 UTC
(In reply to comment #4)
> 4) I do the same, my purpose is to fix my whole eps file with provided
> dimension, if I only provide dimension via bounding box it returns good file
> without washing my eps image, but then problem is, bounding box crop my eps
> by provided dimension instead of resizing it,
> 
> so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 
> 
> Do you have any better idea to resize my eps instead of cropping? 

Yes, use the scale operator to set teh CTM before you include the EPS file.
Comment 6 vipula.redcomponent 2014-02-10 01:41:30 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > 4) I do the same, my purpose is to fix my whole eps file with provided
> > dimension, if I only provide dimension via bounding box it returns good file
> > without washing my eps image, but then problem is, bounding box crop my eps
> > by provided dimension instead of resizing it,
> > 
> > so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 
> > 
> > Do you have any better idea to resize my eps instead of cropping? 
> 
> Yes, use the scale operator to set teh CTM before you include the EPS file.

>>>> Sorry, but I am new to this things can you show me example, how to do that, or provide me link for ref. Thank you SO much for you patience
Comment 7 Ken Sharp 2014-02-10 01:51:42 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > 4) I do the same, my purpose is to fix my whole eps file with provided
> > > dimension, if I only provide dimension via bounding box it returns good file
> > > without washing my eps image, but then problem is, bounding box crop my eps
> > > by provided dimension instead of resizing it,
> > > 
> > > so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 
> > > 
> > > Do you have any better idea to resize my eps instead of cropping? 
> > 
> > Yes, use the scale operator to set teh CTM before you include the EPS file.
> 
> >>>> Sorry, but I am new to this things can you show me example, how to do that, or provide me link for ref. Thank you SO much for you patience

https://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf

See in particular page 12 'Default Coordinate System Transformation'.

Also the PostScript Language Reference Manual is an essential reference for working with PostScript:

http://www.adobe.com/products/postscript/pdfs/PLRM.pdf
Comment 8 vipula.redcomponent 2014-02-10 02:11:39 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > 4) I do the same, my purpose is to fix my whole eps file with provided
> > dimension, if I only provide dimension via bounding box it returns good file
> > without washing my eps image, but then problem is, bounding box crop my eps
> > by provided dimension instead of resizing it,
> > 
> > so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 
> > 
> > Do you have any better idea to resize my eps instead of cropping? 
> 
> Yes, use the scale operator to set teh CTM before you include the EPS file.

>> Sorry, but I am new to this things can you show me example, how to do that, or provide me link for ref. Thank you SO much for you patience 

Yes I have done something like 

%%BeginDocument: danske.eps
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 $imageWidth $imageHeight
(" . $epsFileLocation . ") run
%%EndDocument
\nEndEPSF

Where $imageWidth = width entered by user
$imageHeight = height entered by user
$epsFileLocation = orignal wide file(Which should be resize by width and height)
Comment 9 Ken Sharp 2014-02-10 02:21:48 UTC
(In reply to comment #8)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > 4) I do the same, my purpose is to fix my whole eps file with provided
> > > dimension, if I only provide dimension via bounding box it returns good file
> > > without washing my eps image, but then problem is, bounding box crop my eps
> > > by provided dimension instead of resizing it,
> > > 
> > > so what I do is, I resize dimension by using ps2write with -dEPSFitPage, 
> > > 
> > > Do you have any better idea to resize my eps instead of cropping? 
> > 
> > Yes, use the scale operator to set teh CTM before you include the EPS file.
> 
> >> Sorry, but I am new to this things can you show me example, how to do that, or provide me link for ref. Thank you SO much for you patience 
> 
> Yes I have done something like 
> 
> %%BeginDocument: danske.eps
> %!PS-Adobe-3.0 EPSF-3.0
> %%BoundingBox: 0 0 $imageWidth $imageHeight
> (" . $epsFileLocation . ") run
> %%EndDocument
> \nEndEPSF
> 
> Where $imageWidth = width entered by user
> $imageHeight = height entered by user
> $epsFileLocation = orignal wide file(Which should be resize by width and
> height)

Changing comment in the EPS file is essentially going to do nothing, or get you the wrong answer. You need to use some combination of the translate, scale and rotate operators to set the CTM as required *before* you 'run' the EPS file. In fact you shouldn't execute 'run' you should create a PostScript program which includes the EPS file totally within it.

This is not a general forum giving education on PostScript programming, please do not ask further questions here.
Comment 10 vipula.redcomponent 2014-02-10 03:59:49 UTC
Sorry, but last one,

I am doing it exactly you said, But my main point is same how should I resize eps, well when I open eps file as text file and do some changes nothing works upto my expectation, can is there any place we can talk like skype or something, Thank you so much for your reply.
Comment 11 vipula.redcomponent 2014-02-10 23:17:00 UTC
Okay further more, If I use epswrite as device and set -dLanguageLevel=3 shouldn't it work?
Comment 12 Ken Sharp 2014-02-11 00:18:53 UTC
(In reply to comment #11)
> Okay further more, If I use epswrite as device and set -dLanguageLevel=3
> shouldn't it work?

No. epswrite is based on pswrite (which is deprecated and will be removed),pswrite *only* emits level 1 PostScript, so the result will be worse.

Please stop posting to this bug.