Discussion:
Newbie: Ghostscript Question
(too old to reply)
Jens Harkon
2004-02-27 20:19:33 UTC
Permalink
Hello,

I will use ghostscript to convert my postscript files (with many colour
pictures) to pdf files. I have test some options but I have a problem.

I use this:

1.) All in one line
gswin32c -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite
-sOutputFile=Pic_A.pdf -f PicColor1.ps

2.) All in one line
gswin32c -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite
-sOutputFile=Pic_B.pdf -c " << /ColorImageDict << /QFactor 0.1 /Blend 1
/ColorTransform 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> >>
setdistillerparams " -f PicColor1.ps

3.) All in one line
gswin32c -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite
-sOutputFile=Pic_C.pdf -c " << /ColorImageDict << /QFactor 1.3 /Blend 1
/ColorTransform 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >> >>
setdistillerparams " -f PicColor1.ps

All pictures have the same size. In my opinion the picture Pic_B.pdf
should have the smallest size and Pic_C.pdf should have the biggest size.

What is wrong? Can anybody help me? How should I use the qfactor
parameter to compress the pictures in the postscript file?

By Jens
Russell Lang
2004-02-28 01:36:12 UTC
Permalink
Post by Jens Harkon
Hello,
All pictures have the same size. In my opinion the picture Pic_B.pdf
should have the smallest size and Pic_C.pdf should have the biggest size.
What is wrong? Can anybody help me? How should I use the qfactor
parameter to compress the pictures in the postscript file?
Another variation is to use -dPDFSETTINGS=/screen or /ebook
This will resample images which will help with producing a smaller file.
Jens Harkon
2004-02-28 07:52:57 UTC
Permalink
Hello Russell,
Post by Russell Lang
Post by Jens Harkon
All pictures have the same size. In my opinion the picture Pic_B.pdf
should have the smallest size and Pic_C.pdf should have the biggest size.
What is wrong? Can anybody help me? How should I use the qfactor
parameter to compress the pictures in the postscript file?
Another variation is to use -dPDFSETTINGS=/screen or /ebook
This will resample images which will help with producing a smaller file.
at first many thanks for the fast answer. Now it works fine and I get
smaller files. But what is wrong with my setting? Why has the quality
factor no effects for me?

Jens
Russell Lang
2004-02-28 11:06:40 UTC
Permalink
Post by Jens Harkon
Hello Russell,
Post by Russell Lang
Post by Jens Harkon
All pictures have the same size. In my opinion the picture Pic_B.pdf
should have the smallest size and Pic_C.pdf should have the biggest size.
What is wrong? Can anybody help me? How should I use the qfactor
parameter to compress the pictures in the postscript file?
Another variation is to use -dPDFSETTINGS=/screen or /ebook
This will resample images which will help with producing a smaller file.
at first many thanks for the fast answer. Now it works fine and I get
smaller files. But what is wrong with my setting? Why has the quality
factor no effects for me?
I've never used ColorImageDict before, so I've no idea if it even works.

Are you sure that the images are being compressed with JPEG?
By default with /AutoFilterColorImages=true, Ghostscript will choose
between FlateEncode and DCTEncode according to which it things is best.
You can force it to use JPEG only.

The ps2pdf command line for ghostscript also includes an
extra .setpdfwrite command. This adds a save which can
affect the output PDF file.
Jens Harkon
2004-02-29 07:45:04 UTC
Permalink
Hello Russell,

many thanks for the fast answer. Now all works from the commandline and
I can set different quality parameters. But now I have a other problem.

If I use the following parameter in my visual basic program, ghostscript
ignore it:

-c << /ColorImageDict <</QFactor 1.2 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams

or
-c << /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams

What can be the reason that this line works from the commandline but not
in my vb program? All other things works in my program. I can use the
parameters Zip-compression or LZW-compression. But for the
jpeg-compression I get always the same results.

I use this vb-code.
http://www.cs.wisc.edu/~ghost/doc/gsapi.htm

and here is the complete parameter list:
-dNOPAUSE
-dSAFER
-dBATCH
-sOutputFile=PicColorCompr1.pdf
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.3
-dEncodeColorImages=true
-dAutoFilterColorImages=false
-dColorImageFilter=/DCTEncode
-c << /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams
-dDownsampleColorImages=false
-f
PicColor.ps
-c quit


I hope you can help me.
Best regards,

Jens
Russell Lang
2004-02-29 10:39:28 UTC
Permalink
Post by Jens Harkon
many thanks for the fast answer. Now all works from the commandline and
I can set different quality parameters. But now I have a other problem.
If I use the following parameter in my visual basic program, ghostscript
-c << /ColorImageDict <</QFactor 1.2 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams
or
-c << /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams
What can be the reason that this line works from the commandline but not
in my vb program? All other things works in my program. I can use the
parameters Zip-compression or LZW-compression. But for the
jpeg-compression I get always the same results.
I use this vb-code.
http://www.cs.wisc.edu/~ghost/doc/gsapi.htm
-dNOPAUSE
-dSAFER
-dBATCH
-sOutputFile=PicColorCompr1.pdf
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.3
-dEncodeColorImages=true
-dAutoFilterColorImages=false
-dColorImageFilter=/DCTEncode
-c << /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams
-dDownsampleColorImages=false
-f
PicColor.ps
-c quit
I'd replace the last part with

-dDownsampleColorImages=false
-c "<< /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams"
-f
-PicColor.ps

Putting quotes around the PS code often helps prefent stuff from
being mangled. Also, the -dDownsampleColorImages=false
would have been treated as PostScript code and thrown an
error if I understand things correctly. The -c quit is redundant
because you use -dBATCH.
Jens Harkon
2004-02-29 13:09:22 UTC
Permalink
Hello Russell,

thanks for your answer.

Now I have change my parameters in visual basic to this:

-dNOPAUSE
-dSAFER
-dBATCH
-sOutputFile=PicColorCompr1.pdf
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.3
-dEncodeColorImages=true
-dAutoFilterColorImages=false
-dColorImageFilter=/DCTEncode
-c "<< /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams"
-f
PicColor.ps

But all the pdf files have the same size if I change the QFactor. Also I
think it is the line with
-c "<< /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams"

But what can I do? If I use it in the commandline - all is ok.
Have you other hints for me? If you like I can send you a test-vb-source
(vb5 or vb6).

Best regards,

Jens
Russell Lang
2004-03-02 21:12:53 UTC
Permalink
Post by Jens Harkon
-dNOPAUSE
-dSAFER
-dBATCH
-sOutputFile=PicColorCompr1.pdf
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.3
-dEncodeColorImages=true
-dAutoFilterColorImages=false
-dColorImageFilter=/DCTEncode
-c "<< /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams"
-f
PicColor.ps
But all the pdf files have the same size if I change the QFactor. Also I
think it is the line with
-c "<< /ColorImageDict <</QFactor 0.1 /Blend 1 /HSample [2 1 1 2]
/VSample [2 1 1 2]>> >> setdistillerparams"
But what can I do? If I use it in the commandline - all is ok.
Have you other hints for me? If you like I can send you a test-vb-source
(vb5 or vb6).
I can reproduce this using GSview, but didn't manage to figure
out what was causing it. Please email me the test VB source (6 or .NET).
Frank Heindörfer
2004-03-03 08:37:00 UTC
Permalink
Hello Russell,

I know this problem. Please test this in a vb source code or in gsview.

AddParams "-c"
AddParams ".setpdfwrite << /ColorImageDict <</QFactor 0.7 /Blend 1
/HSample [2 1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams"

Then it works in vb. :-)

But I have an other problem. I found out that there is a difference
between ghostscript and itext to handle the security.

If I activate 128 bit encryption and disallow printing and allow
printing in low resolution I get the following results:

itext: allow printing in low resolution
Ghostscript: disallow printing

What is correct? I haven't acrobat distiller to check the right
settings. Can you help me?

Best regards,

Frank
http://www.sourceforge.net/projects/pdfcreator

PS: And sorry for my bad english.
Russell Lang
2004-03-03 11:40:36 UTC
Permalink
Post by Frank Heindörfer
I know this problem. Please test this in a vb source code or in gsview.
AddParams "-c"
AddParams ".setpdfwrite << /ColorImageDict <</QFactor 0.7 /Blend 1
/HSample [2 1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams"
I had already tried .setpdfwrite and didn't get it to work.
Post by Frank Heindörfer
But I have an other problem. I found out that there is a difference
between ghostscript and itext to handle the security.
If I activate 128 bit encryption and disallow printing and allow
itext: allow printing in low resolution
Ghostscript: disallow printing
What is correct? I haven't acrobat distiller to check the right
settings. Can you help me?
This sounds a bit backwards. I would have said you enable printing,
but disable high resolution printing. That would be permissions flag
is -4 (base) - 2048 (hires print) = -dPermission=-2052
Using this with GS ps2pdf134 gives a PDF file that Acrobat
reports as allowing printing, but only at 150dpi.
Frank Heindörfer
2004-03-03 14:06:01 UTC
Permalink
Hello Russell,
Post by Russell Lang
Post by Frank Heindörfer
AddParams "-c"
AddParams ".setpdfwrite << /ColorImageDict <</QFactor 0.7 /Blend 1
/HSample [2 1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams"
I had already tried .setpdfwrite and didn't get it to work.
Here is my complete parameter list. It works fine with gswin32c and vb:
-q
-dNOPAUSE
-dSAFER
-dBATCH
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.4
-r600x600
-dProcessColorModel=/DeviceCMYK
-dAutoRotatePages=/PageByPage
-dCompressPages=false
-dEmbedAllFonts=true
-dSubsetFonts=true
-dMaxSubsetPct=100
-dConvertCMYKImagesToRGB=true
-sOutputFile=Test.pdf
-dEncodeColorImages=true
-dAutoFilterColorImages=false
-dColorImageFilter=/DCTEncode
-c
.setpdfwrite << /ColorImageDict <</QFactor 30.0 /Blend 1 /HSample [2 1 1
2] /VSample [2 1 1 2]>> >> setdistillerparams
-dDownsampleColorImages=false
-dEncodeGrayImages=false
-dEncodeMonoImages=false
-f
Test1.ps

The paramater "-C" in one line and the parameter with ".setpdfwrite ..."
in one line.
Post by Russell Lang
This sounds a bit backwards. I would have said you enable printing,
but disable high resolution printing. That would be permissions flag
is -4 (base) - 2048 (hires print) = -dPermission=-2052
Using this with GS ps2pdf134 gives a PDF file that Acrobat
reports as allowing printing, but only at 150dpi.
I think so. But then have itext a problem.
I have check the newest version with the same result. If I disallow
printing and allow low resolution printing I can printing in low resolution.

If you like I can send you an example script to check this.
If you like I can send an example in visual basic 6 for compressing
color pictures in postscript files.

Bye

Frank
http://www.sourceforge.net/projects/pdfcreator
Russell Lang
2004-03-04 10:55:53 UTC
Permalink
Post by Frank Heindörfer
Post by Russell Lang
Post by Frank Heindörfer
AddParams "-c"
AddParams ".setpdfwrite << /ColorImageDict <</QFactor 0.7 /Blend 1
/HSample [2 1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams"
I had already tried .setpdfwrite and didn't get it to work.
My problem with GSview was that I wasn't bothering to
set "-dAutoFilterColorImages=false" and without this
it seems to ignore the ColorImageDict.
Post by Frank Heindörfer
-c
.setpdfwrite << /ColorImageDict <</QFactor 30.0 /Blend 1 /HSample [2 1 1
2] /VSample [2 1 1 2]>> >> setdistillerparams
-dDownsampleColorImages=false
-dEncodeGrayImages=false
-dEncodeMonoImages=false
-f
Test1.ps
The paramater "-c" in one line and the parameter with ".setpdfwrite ..."
in one line.
If done as an argument in the call to the GS DLL, then the -c must be in a
separate argument. Within an "@arguments" file, they can be on the
same line. If Jens was putting them in the argument list, that would
explain his problem.
Post by Frank Heindörfer
Post by Russell Lang
This sounds a bit backwards. I would have said you enable printing,
but disable high resolution printing. That would be permissions flag
is -4 (base) - 2048 (hires print) = -dPermission=-2052
Using this with GS ps2pdf134 gives a PDF file that Acrobat
reports as allowing printing, but only at 150dpi.
I think so. But then have itext a problem.
I have check the newest version with the same result. If I disallow
printing and allow low resolution printing I can printing in low resolution.
Those settings don't make sense.
You can't disallow printing AND allow low resolution printing.
They are the same field (bit 3). As I read it:
If bit3=1 and bit12=1 then allow high resolution printing.
If bit3=1 and bit12=0 then allow low resolution only printing.
If bit3=0 (irrespective of bit12) then disable printing.
Frank Heindörfer
2004-03-04 12:57:44 UTC
Permalink
Post by Russell Lang
Post by Frank Heindörfer
Post by Russell Lang
Post by Frank Heindörfer
AddParams "-c"
AddParams ".setpdfwrite << /ColorImageDict <</QFactor 0.7 /Blend 1
/HSample [2 1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams"
I had already tried .setpdfwrite and didn't get it to work.
My problem with GSview was that I wasn't bothering to
set "-dAutoFilterColorImages=false" and without this
it seems to ignore the ColorImageDict.
Post by Frank Heindörfer
-c
.setpdfwrite << /ColorImageDict <</QFactor 30.0 /Blend 1 /HSample [2 1 1
2] /VSample [2 1 1 2]>> >> setdistillerparams
Sorry, but how can I set this in gsview? I add this line to the
optionsline, but it doesn't work.
-c .setpdfwrite << /ColorImageDict <</QFactor 30.0 /Blend 1 /HSample [2
1 1 2] /VSample [2 1 1 2]>> >> setdistillerparams
Post by Russell Lang
Post by Frank Heindörfer
Post by Russell Lang
This sounds a bit backwards. I would have said you enable printing,
but disable high resolution printing. That would be permissions flag
is -4 (base) - 2048 (hires print) = -dPermission=-2052
Using this with GS ps2pdf134 gives a PDF file that Acrobat
reports as allowing printing, but only at 150dpi.
I think so. But then have itext a problem.
I have check the newest version with the same result. If I disallow
printing and allow low resolution printing I can printing in low
resolution.
Those settings don't make sense.
You can't disallow printing AND allow low resolution printing.
If bit3=1 and bit12=1 then allow high resolution printing.
If bit3=1 and bit12=0 then allow low resolution only printing.
If bit3=0 (irrespective of bit12) then disable printing.
I agree with you.

Bye

Frank
http://www.sourceforge.net/projects/pdfcreator

Loading...