Page 1 of 1

Conversion PDF to PS

Posted: 2010-06-16T07:16:20-07:00
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.

Re: Conversion PDF to PS

Posted: 2010-06-16T07:18:30-07:00
by magick
Post a URL to your Postscript file(s). We need to reproduce the problem before we can comment.

Re: Conversion PDF to PS

Posted: 2010-06-21T07:43:35-07:00
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.

Re: Conversion PDF to PS

Posted: 2010-06-21T09:37:47-07:00
by magick
Add +antialias to your command line:
  • convert +antialias B-Case.ai B-Case.png

Re: Conversion PDF to PS

Posted: 2010-06-21T11:55:10-07:00
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'.

Re: Conversion PDF to PS

Posted: 2010-06-21T12:14:09-07:00
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.

Re: Conversion PDF to PS

Posted: 2010-06-21T12:19:04-07:00
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.

Re: Conversion PDF to PS

Posted: 2010-06-21T12:27:22-07:00
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?

Re: Conversion PDF to PS

Posted: 2010-06-21T13:30:39-07:00
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.)

Re: Conversion PDF to PS

Posted: 2010-06-21T14:22:34-07:00
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.

Re: Conversion PDF to PS

Posted: 2010-06-21T17:06:03-07:00
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

Re: Conversion PDF to PS

Posted: 2010-06-24T11:39:35-07:00
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?

Re: Conversion PDF to PS

Posted: 2010-06-24T11:54:07-07:00
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?

Re: Conversion PDF to PS

Posted: 2010-06-24T12:11:34-07:00
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.