Vulkan-Docs/config/optimize-pdf
Jon Leech 7376fb77d1 Change log for June 23, 2019 Vulkan 1.1.112 spec update:
* Update release number to 112.

Github Issues:

  * Clarify that it is possible to use the <<memory-host, Host Memory>>
    pname:pfnReallocation callback to free memory in any case that
    pname:pfnFree could be used (public issue 973).

Internal Issues:

  * Clarify range and precision of code:OpImageQueryLod in the discussion of
    scale factor and level-of-detail operation in the
    <<textures-normalized-operations, Normalized Texel Coordinate
    Operations>> section (internal issues 926, 1719).
  * Fix framebuffer layer valid usage statements for
    slink:VkRenderPassCreateInfo, slink:VkRenderPassCreateInfo2KHR, and
    slink:VkFramebufferCreateInfo (internal issue 1670).
  * Refactor common valid usage statements for flink:vkCmdBeginQuery and
    flink:vkCmdBeginQueryIndexedEXT (internal issue 1682).
  * Prohibit the ename:ename:VK_SAMPLER_YCBCR_RANGE_ITU_NARROW range from
    being used in slink:VkSamplerYcbcrConversionCreateInfo for formats with
    a bit depth less than 8 (internal issue 1688).
  * Add missing interactions with `<<VK_EXT_host_query_reset_usage>>` in the
    <<queries, Queries>> chapter (internal issue 1692).
  * Clean up error output from the `optimize-pdf` build script on success.
  * Fix an internal link to the <<spirvenv-correctly-rounded, Correctly
    Rounded>> section in the SPIR-V appendix by adding and referring to that
    anchor.
  * Fix extension version numbers in `vk.xml` for `VK_EXT_filter_cubic` and
    `VK_IMG_filter_cubic`.
  * Specify division precision for negative numbers, and remove statement
    that trigonometric functions have undefined precision, in the
    <<spirvenv-precision-operation, Precision and Operation of SPIR-V
    Instructions>> appendix.
2019-06-23 20:30:19 -07:00

100 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Copyright (C) 2014-2016 OpenDevise Inc. and the Asciidoctor Project
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Optimizes and compresses the specified PDF using Ghostscript (gs).
#
# [NOTE]
# You need at least Ghostscript 9.10 in order for page labels defined in the
# PDF to be preserved (e.g., front matter pages numbered using roman numerals).
if [ -z $1 ]; then
echo "Please supply a PDF file to optimize"
exit 1
fi
if [ -z $GS ]; then
GS=gs
fi
FILE=$1
FILE_BASENAME=${FILE%.pdf}
FILE_OPTIMIZED=$FILE_BASENAME-optimized.pdf
FILE_PDFMARK=
if [ -f "$FILE_BASENAME.pdfmark" ]; then
FILE_PDFMARK="$FILE_BASENAME.pdfmark"
fi
DOWNSAMPLE_IMAGES=true
if [ -z $IMAGE_DPI ]; then
#IMAGE_DPI=150
IMAGE_DPI=300
fi
# /prepress defaults (see http://ghostscript.com/doc/current/Ps2pdf.htm)
# -d{Color,Gray,Mono}ImageDownsampleType=/Bicubic
# -dAutoFilter{Color,Gray}Images=true
# -dOptimize=true
# -dEmbedAllFonts=true
# -dSubsetFonts=true
# -dColorConversionStrategy=/LeaveColorUnchanged
# -dUCRandBGInfo=/Preserve
# -dCompressPages=true
#
# other unused settings
# -r72
#
# for info about pdfmarks, see http://milan.kupcevic.net/ghostscript-ps-pdf
#
# to convert to grayscale, add the following (though doesn't always work)
#
# -dProcessColorModel=/DeviceGray \
# -dColorConversionStrategy=/Gray \
ERRFILE=$FILE_BASENAME-ERRS.optimize
"$GS" -q -dNOPAUSE -dBATCH -dSAFER -dNOOUTERSAVE \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
-dPrinted=false \
-dCannotEmbedFontPolicy=/Warning \
-dDownsampleColorImages=$DOWNSAMPLE_IMAGES \
-dColorImageResolution=$IMAGE_DPI \
-dDownsampleGrayImages=$DOWNSAMPLE_IMAGES \
-dGrayImageResolution=$IMAGE_DPI \
-dDownsampleMonoImages=$DOWNSAMPLE_IMAGES \
-dMonoImageResolution=$IMAGE_DPI \
-sOutputFile="$FILE_OPTIMIZED" \
"$FILE" $FILE_PDFMARK 2> $ERRFILE
status=$?
if test $status -ne 0 ; then
echo "$0: $GS return status = $status, aborting"
elif grep -q Error $ERRFILE ; then
echo "$0: $GS succeeded but found Error in $ERRFILE (follows), aborting"
echo '---------- Errors from $GS ----------'
grep Error $ERRFILE
echo '-------------------------------------'
status=1
else
rm -f $ERRFILE
fi
exit $status