English 中文(简体)
ghostscript pdfwrite specified jpegquality
原标题:ghostscript pdfwrite specify jpeg quality

I m试图压缩多份pdf文档,这些档案基本上都是含有jpg图像的照片。 就我的产出pdf而言,我希望将图像分辨率调整到300台,我希望保持最佳质量。 使用Im的指挥官是:

gswin64c.exe -dNOPAUSE -dBATCH ^-dDownsampleColorImages=true -dColorImageResolution=300 ^-dDownsampleGrayImages=true -dGrayImageResolution=300 ^-dDownsampleMonoImages=true -dMonoImageResolution=300 ^-sDEVICE=pdfwrite -dJPEGQ=100 -sOutputFile=out.pdf in1.pdf in2.pdf

然而,看来――dJPEGQ=100对产出没有影响。 改变这一参数后,所有数值的图像都显示同样的档案和艺术品。 用这个选项——dPDFSETtingS=/printer——指挥,我没有手法,就取得了更好的结果,但这一选择也应导致300台 d。 因此,确定产出档案中jpg图像质量的正确指挥是什么?

最佳回答

解决办法是调整DCTEn 密码过滤器,并配电:

gswin64c.exe -sOutputFile=out.pdf -dNOPAUSE -dBATCH ^-sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -c "<< /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.08 /Blend 1 >> /ColorImageDownsampleType /Bicubic /ColorConversionStrategy /LeaveColorUnchanged >> setdistillerparams" -f in1.pdf

由此导致压缩文件,质量令我满意,并可根据每个人的需要加以调整。

<><>Edit>:

The .setpdfwrite case is deprecated for recent ghostscript release (> 9.50), so, 我请我在答复中删除。

问题回答

Ghostscript seems to have issues reading the /QFactor specified in the -c "..." part for some files. I have tried using this minimal command on my pdf generated by pdflatex for testing:

gs -sDEVICE=pdfwrite -sOutputFile=output.pdf 
    -dCompatibilityLevel=1.7 -dNOPAUSE -dBATCH 
    -c  << /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.15 /Blend 1 /ColorTransform 1 >> >> setdistillerparams   
    -f input.pdf

我发现,无论具体指明了什么/QFactor,产出的档案尺寸和图像质量都是一样的。 我认为,它仍在使用0.9的缺省/航道价值。

因此,我认为,具体指明JPEG质量的唯一途径是使用预先界定的PDFSETATIONS,确定某种QFactor值,并使用更多的旗帜来压倒其他环境。 缺省、图书、打印机和预先压价的评分分别为0.9、0.76、0.4和0.15。 See gs document here:

在此,我对我国防军的工作流程使用了什么。 (0.25英亩的QFactor 实际工作:

DPI=600
gs -sDEVICE=pdfwrite -sOutputFile=output.pdf 
    -dCompatibilityLevel=1.7 -dFastWebView=true 
    -dEmbedAllFonts=true -dSubsetFonts=true -dCompressFonts=true 
    -dDetectDuplicateImages=true -dDoThumbnails=false -dAutoRotatePages=/None 
    -r$DPI -dColorImageResolution=$DPI -dGrayImageResolution=$DPI -dMonoImageResolution=$DPI 
    -dDownsampleColorImages=true -dColorImageDownsampleType=/Bicubic -dColorImageDownsampleThreshold=1.0 
    -dDownsampleGrayImages=true -dGrayImageDownsampleType=/Bicubic -dGrayImageDownsampleThreshold=1.0 
    -dDownsampleMonoImages=true -dMonoImageDownsampleType=/Subsample -dMonoImageDownsampleThreshold=1.0 
    -dColorImageFilter=/DCTEncode -dGrayImageFilter=/DCTEncode -dMonoImageFilter=/CCITTFaxEncode 
    -dColorConversionStrategy=/LeaveColorUnchanged -dPassThroughJPEGImages=true 
    -dUseArtBox -dNEWPDF=true -dNOPAUSE -dBATCH -dSAFER 
    -dPDFSETTINGS=/printer 
    -c  << /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.25 /Blend 1 /ColorTransform 1 >> >> setdistillerparams   
    -f input.pdf




相关问题
Tools to generate reportanalytics feeds from google

Can you recommend any programmable tools/extensions that can be used to generate reports out of google analytics feed on th fly? Essentially some kind of pdf generator from feed, not sure though. Or ...

Asynchronous generation of PDF - error handling

We have some code that uses a third party component to generate a PDF from a URL that we pass it (the URL being a page within our application). In the code, we instantiate the PDF generator and it ...

HTML to PDF vs. Programmatically creating PDF via PHP

I have a PHP application that needs to generate some PDF invoices and PDF timesheets with nice headers/footers. Some Stackoverflow users recommend using TCPDF to create the PDF documents. In my ...

Open PDF Programmatically in One Page View

I have a 2005 Reporting Services report that I display as a PDF through the report viewer control. I would like to know how I can have the PDF be viewed in the "one page at a time mode". Right now it ...

iTextSharp : pdfPTable overlapping with other content

I am using iTextsharp to generate a PDF document from C# application. I am having a PdfPTable to display some tabular data. My problem in the table is overlapping with the other paragraph .Is there ...

(pdflib) Table of contents with dynamic page numbers

I m on pdflib 7 under php5 and I m drawing a statistical report with several sub topics over several pages. Now, I want to include a table of contents on the first page where every sub topic is ...

热门标签