有没有简单的方法可以转换pdf文件中的图像?

发布于 2024-11-02 13:06:14 字数 606 浏览 1 评论 0原文

我有几本书是我绝对必须读的;它们是一套 PDF 文件形式的微积分教科书。问题是这些pdf文件中的图形和图像都是png,这显然是我的kindle不支持的。无论如何,我可以将这些图像批量转换为 jpeg 或 pdf 文件中的任何其他格式。我已经尝试了一切,从将 pdf 转换为其他格式(方程格式不允许它工作),到从 pdf 文件中提取图像并进行转换。我真的需要知道是否有任何程序可以用来帮助我,或者如果可能的话,有一种方法可以“打开”pdf 容器,并将 png 图像切换为 jpeg 图像并替换 png 文件扩展名与 jpg。任何帮助将不胜感激。 这些书是:

http://tutorial.math.lamar.edu/pdf/CalcI /CalcI_Complete.pdf

http://tutorial.math.lamar.edu /pdf/CalcII/CalcII_Complete.pdf

I have a few books that I absolutely MUST be reading; they are a set of calculus textbooks as PDF files. The problem is that the graphs and images in these pdf file are all png, which is apparently not supported by my kindle. Is there anyway I can convert these images as a batch into jpeg or any other format inside the pdf file. I have tried everything from converting the pdf to other formats (equation formatting didn't let it work), to extracting the images from the pdf file and getting them converted. I just really need to know if there is any program I can use to help me or if maybe, there is a way I could 'open' the pdf container, and switch out the png images for the jpeg images and replace the png file extensions with jpg. Any help would be greatly appreciated.
The books are:

http://tutorial.math.lamar.edu/pdf/CalcI/CalcI_Complete.pdf

http://tutorial.math.lamar.edu/pdf/CalcII/CalcII_Complete.pdf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独陪着我 2024-11-09 13:06:14

有一些代码可以使用 GhostScript 来做到这一点(见下文)。

这解决了所有损坏的图像对我来说很好的问题。

如果您碰巧是少数使用 Windows 7/10 64 位的 Kindle 用户之一,您可以尝试以下与正确的 dll 捆绑在一起的版本。 https://github.com/zifnab87/kindleanpub 分叉自 https://github.com/hmemcpy/kindleanpub。所有这些都可以适应

#!/bin/sh

# https://github.com/hmemcpy/kindleanpub
# Licensed under the 3-clause BSD license, see LICENSE
#
# Copyright (c) 2018, Igal Tabachnik
# All rights reserved.

# Fixes garbled image rendering from LeanPub PDFs on older Kindle devices (e.g. Kindle DX),
# by recompressing the images using JPEG with highest quality.
# The resulting PDF will be smaller, and will render correctly on Kindle devices.

# Original code by Alfred Klomp, http://www.alfredklomp.com/programming/shrinkpdf/

fix() {
    echo "Converting $IFILE > $OFILE"

    # Converting using high quality, color preserving, 300 dpi imgs
    # see https://stackoverflow.com/questions/40849325/ghostscript-pdfwrite-specify-jpeg-quality

    gswin64.exe \
        -sOutputFile="$2" \
        -q -dNOPAUSE -dBATCH -dSAFER \
        -sDEVICE=pdfwrite \
        -dPDFSETTINGS=/prepress \
        -c ".setpdfwrite << /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.08 /Blend 1 >> /ColorImageDownsampleType /Bicubic /ColorConversionStrategy /LeaveColorUnchanged >> setdistillerparams" \
        -f "$1"
}

usage() {
    echo "Reduces PDF filesize by lossy recompressing images to JPEG with Ghostscript."
    echo "Fixes rendering issues with Leanpub PDFs on older Kindle devices."
    echo "  Usage: $1 infile [outfile]"
}

IFILE="$1"

# Need an input file:
if [ -z "$IFILE" ]; then
    usage "$0"
    exit 1
fi

# Output filename defaults to "inputfile-fixed.pdf" unless given:
if [ ! -z "$2" ]; then
    OFILE="$2"
else
    OFILE="${IFILE%.pdf}-fixed.pdf"
fi

fix "$IFILE" "$OFILE" || exit $?

原作者的旧/新版本的 Linux/Macos/Windows 示例:
之前
之后

There is code that can do that using GhostScript (see below).

This fixed the issue for all the broken images fine for me.

If you happen to be one of the few Kindle users with Windows 7/10 64-bit you can try a version of the below bundled with the correct dlls. https://github.com/zifnab87/kindleanpub forked from https://github.com/hmemcpy/kindleanpub. All those can be adapted to older/newer versions of Linux/Macos/Windows

#!/bin/sh

# https://github.com/hmemcpy/kindleanpub
# Licensed under the 3-clause BSD license, see LICENSE
#
# Copyright (c) 2018, Igal Tabachnik
# All rights reserved.

# Fixes garbled image rendering from LeanPub PDFs on older Kindle devices (e.g. Kindle DX),
# by recompressing the images using JPEG with highest quality.
# The resulting PDF will be smaller, and will render correctly on Kindle devices.

# Original code by Alfred Klomp, http://www.alfredklomp.com/programming/shrinkpdf/

fix() {
    echo "Converting $IFILE > $OFILE"

    # Converting using high quality, color preserving, 300 dpi imgs
    # see https://stackoverflow.com/questions/40849325/ghostscript-pdfwrite-specify-jpeg-quality

    gswin64.exe \
        -sOutputFile="$2" \
        -q -dNOPAUSE -dBATCH -dSAFER \
        -sDEVICE=pdfwrite \
        -dPDFSETTINGS=/prepress \
        -c ".setpdfwrite << /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.08 /Blend 1 >> /ColorImageDownsampleType /Bicubic /ColorConversionStrategy /LeaveColorUnchanged >> setdistillerparams" \
        -f "$1"
}

usage() {
    echo "Reduces PDF filesize by lossy recompressing images to JPEG with Ghostscript."
    echo "Fixes rendering issues with Leanpub PDFs on older Kindle devices."
    echo "  Usage: $1 infile [outfile]"
}

IFILE="$1"

# Need an input file:
if [ -z "$IFILE" ]; then
    usage "$0"
    exit 1
fi

# Output filename defaults to "inputfile-fixed.pdf" unless given:
if [ ! -z "$2" ]; then
    OFILE="$2"
else
    OFILE="${IFILE%.pdf}-fixed.pdf"
fi

fix "$IFILE" "$OFILE" || exit $?

Example from the original authors:
Before
After

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文