Conversion PDF to PS

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Conversion PDF to PS

Post by elisegev »

I have a PDF file with a pattern. When I use ImageMagick to convert the PDF file to PS, it adds a black border for each item of the pattern. When I use Ghostscript's pds2ps for the same task, I get a correct conversion. The file is available for upload.

I have another PDF file with a pattern. It has a similar problem. But in this case each item in the pattern gets a black background when I use ImageMagick. pdf2ps does not generate this black background. The file is available for upload.

What is wrong here with ImageMagick? I know that it uses either pdf2ps or pdf2eps to get a temporary ps (or eps) file. This points to some bad parameters in delegates.xml. I have tried to use an alternative file, but was not successful in doing so.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Conversion PDF to PS

Post by magick »

Post a URL to your Postscript file(s). We need to reproduce the problem before we can comment.
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

magick wrote:Post a URL to your Postscript file(s). We need to reproduce the problem before we can comment.
I have two examples:

ftp://ftp.ptc.com//users/anonymous/outgoing/B-Case.ai
ftp://ftp.ptc.com//users/anonymous/outgoing/C-Case.ai

The files will be there for three days.

Thanks.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Conversion PDF to PS

Post by magick »

Add +antialias to your command line:
  • convert +antialias B-Case.ai B-Case.png
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Conversion PDF to PS

Post by Drarakel »

An alternative is to change the output device for Ghostscript. I don't know why pnmraw and pngalpha fail here, but with bmpsep8, it works - including antialiasing.

You could use that:

Code: Select all

gswin32c -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=bmpsep8 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -sOUTPUTFILE=temporary.bmp B-Case.ai
convert temporary.bmp -channel RGB +combine B-Case-300dpi.png
(If you're on Unix, it's of course not 'gswin32c', but 'gs'.)

The other possibility is to edit the IM delegates.xml file for these examples. In the line '<delegate decode="ps:color"...', you might change '-sDEVICE=pnmraw' to '-sDEVICE=bmpsep8'.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Conversion PDF to PS

Post by magick »

Ok, try this:
  • convert -colorspace cmyk B-Case.ai B-Case.png
We will be able to automatically detect the CMYK colorspace when we expand on support for the XMP profile in the future.
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

[quote="Drarakel"]An alternative is to change the output device for Ghostscript. I don't know why pnmraw and pngalpha fail here, but with bmpsep8, it works - including antialiasing.

This suggestion removes all colors from the result PNG file.

Ghostscript is used here because ImageMagick does not handle PDF files directly, but it is transparent to the user.
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

magick wrote:Ok, try this:
  • convert -colorspace cmyk B-Case.ai B-Case.png
We will be able to automatically detect the CMYK colorspace when we expand on support for the XMP profile in the future.
This suggestion works for B-Case.ai, but not for C-Case.ai. Do you know why?
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Conversion PDF to PS

Post by Drarakel »

magick wrote:Ok, try this:
  • convert -colorspace cmyk B-Case.ai B-Case.png
OK, that's quicker. :D
But the source files doesn't look like real CMYK - the K channel is empty. With pamcmyk32 or tiff32nc, one basically gets CMY here - which is the same as RGB, just negated - right?
By the way: Do you have any documentation of the pamcmyk32 device? I think it generally produces the same images than tiff32nc - is that correct? (I usually get tiny differences, but probably only due to different rounding or something like that.)
elisegev wrote:This suggestion removes all colors from the result PNG file.
?
With my two methods, or with magick's, I always get the correct result - for B-Case.ai and C-Case.ai.
B-Case-300dpi.png
C-Case-300dpi.png (Link deleted)
(This is with IM v6.6.2-5 Q16 and GS 8.71.)
Last edited by Drarakel on 2010-09-25T23:28:27-07:00, edited 1 time in total.
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

Drarakel wrote:
magick wrote:Ok, try this:
  • convert -colorspace cmyk B-Case.ai B-Case.png

With my two methods, or with magick's, I always get the correct result - for B-Case.ai and C-Case.ai.
B-Case-300dpi.png
C-Case-300dpi.png
(This is with IM v6.6.2-5 Q16 and GS 8.71.)
I can reproduce your result only by changing the density of the conversion (i.e., -density ). Without the density directive, the borders are visible in the PNG file.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Conversion PDF to PS

Post by Drarakel »

Well, but this:
C-Case2.png (with any of the above methods, at the default 72dpi)
is still better than this:
C-Case1.png (with "convert C-Case.ai C-Case1.png")
- isnt it? :wink:
And I don't see how the colors could be missing.

If you want an even better result at 72dpi, then use a 'supersampling' approach (which is better anyway because Ghostscript sometimes 'forgets' antialiasing for some elements). So, first read in at a multiple of the desired density value, then resample:
convert -colorspace cmyk -density 288 C-Case.ai -resample 72 C-Case.png
Result here: C-Case-72_r.png

I think, C-Case.ai is not exactly the same case as B-Case.ai. With B-Case.ai, some GS devices really failed - they lose all the transparency within the objects if antialiasing is turned on. This is bad, I never saw such a case with the current Ghostscript.
With C-Case.ai however it's not so bad. There's no transparency that could get lost in the final image (apart from the white stripe at the lower edge). At most, there are 'only' some.. connection lines visible. The latter is not so unusual with some PDFs - I sometimes get this in Adobe, too. (But here, I can adjust it with some options.)
If you think the behaviour of the GS devices should be fixed, then you'll probably have to ask the people from Ghostscript.

Edit: Links deleted
Last edited by Drarakel on 2010-09-25T23:29:23-07:00, edited 1 time in total.
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

magick wrote:
  • convert -colorspace cmyk B-Case.ai[0] B-Case.png
Does anyone know why selecting the first page of the file (see above) will remove the colors from the PNG and leave it in gray-scale?
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Conversion PDF to PS

Post by Drarakel »

For me, "convert -colorspace cmyk B-Case.ai[0] B-Case.png" gives the same exact image as "convert -colorspace cmyk B-Case.ai B-Case.png".
I'm using the current versions of ImageMagick and Ghostscript (IM 6.6.2-7 Q16, GS 8.71) - on Windows XP.
What are your versions?
elisegev
Posts: 50
Joined: 2005-09-28T07:47:13-07:00
Contact:

Re: Conversion PDF to PS

Post by elisegev »

Drarakel wrote:For me, "convert -colorspace cmyk B-Case.ai[0] B-Case.png" gives the same exact image as "convert -colorspace cmyk B-Case.ai B-Case.png".
I'm using the current versions of ImageMagick and Ghostscript (IM 6.6.2-7 Q16, GS 8.71) - on Windows XP.
What are your versions?
I was using IM 6.5.3. The issue is resolved with IM6.6.2. (I have both) Thanks for the input.
Post Reply