Pdf to jpg converter linux

Конвертирование pdf в формат jpg в Linux

Хотя PDF является широко используемым форматом документов и поддерживается множеством приложений, в некоторых случаях может потребоваться конвертировать его в другие форматы, например в jpg, чтобы вставить в презентацию. Приведенное ниже руководство поможет вам преобразовать файл формата PDF в jpg/jpeg в операционной системе Linux.

Самый простой способ конвертирования — воспользоваться ImageMagick.

Обратите внимание, что если input.pdf — это многостраничный pdf-файл, то вышеприведенная команда создаст ровно столько изображений, сколько страниц имеется в pdf-файле (т.е. output-0.jpg, output-1.jpg, output-2.jpg и т.д).

Для конвертирования в jpg с заданным уровнем компрессии, используется команда вида:

Опция «-quality» задает уровень компрессии изображения. Для формата JPG диапазон уровней компрессии ранжируется от 1 (лучшая компрессия и худшее качество) до 100 (лучшее качество и худшая компрессия).

Конвертирование pdf в jpg шириной 500px:

Конвертирование первой страницы pdf-файла в jpg:

Конвертирование нескольких pdf-файлов в формат jpg в пакетном режиме:

Если вы думаете, что конвертирование займет слишком много оперативной памяти и приведет к замедлению работы системы, вы можете проверить количество доступных ресурсов и ограничить их использование:

В приведенной выше команде ImageMagic/convert опирается на Ghostscript для интерпретации файлов PDF. Вы можете использовать Ghostscript напрямую для конвертации pdf в jpg следующим образом:

Приведенная выше команда генерирует серию файлов (image1.jpg, image2.jpg. image5.jpg) для первых пяти страниц входящего файла pdf. Уровень компрессии JPG составляет 100, разрешение (ширина) изображения 500px.

Источник

Конвертирование jpg в pdf в Linux

Формат jpg несомненно является самым популярным графическим форматом в интернете, однако в некоторых случаях удобнее использовать pdf, так как он может включать как растровую, так и векторную графику. Поэтому качество печати изображений jpg зависит только от их разрешения и степени сжатия, в то время как векторные pdf-файлы можно печатать любого размера. Кроме того, pdf-файлы с текстовым слоем поддерживают поиск по содержимому и могут содержать больше метаданных, чем jpg.
В Linux для конвертирования jpg в pdf вы можете использовать ImageMagic или GhostScript.

Конвертирование jpg в pdf с помощью ImageMagick

Для начала установите ImageMagick.

В пакет ImageMagick входит утилита convert, которая позволяет конвертировать jpg в pdf. Эта команда масштабирует изображение таким образом, чтобы оно соответствовало размеру страницы. Конвертирование осуществляется с помощью команды:

Если вы хотите конвертировать несколько изображений jpg в один pdf-файл (с несколькими страницами), это делается с помощью команды:

Утилита convert также поддерживает различные операции редактирования изображения перед его конвертированием в формат pdf.

С помощью опции «-page» команды convert можно задать размер страницы. Если размер больше, чем размер исходного изображения, оно будет размещено в левом нижнем углу страницы.

Можно также задать размер изображения:

Изменить размер изображения:

Конвертирование jpg в pdf с помощью Ghostscript

Сначала установите ghostscript.

Для конвертирования используется команда gs вида:

Конвертирование нескольких изображений jpg в один файл pdf осуществляется с помощью команды:

Источник

How to convert a PDF into JPG with command line in Linux? [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 10 months ago .

What are fast and reliable ways for converting a PDF into a (single) JPEG using the command line on Linux?

4 Answers 4

You can try ImageMagick’s convert utility.

On Ubuntu, you can install it with this command:

Use convert like this:

. But I usually prefer just temporarily renaming the file when I come across this error.

Читайте также:  Windows disk check error

For the life of me, over the last 5 years, I cannot get imagemagick to work consistently (if at all) for me, and I don’t know why people continually recommend it again and again. I just googled how to convert a PDF to a JPEG today, found this answer, and tried convert , and it doesn’t work at all for me:

Then, I remembered there was another tool I use and wrote about, so I googled «linux convert pdf to jpg Gabriel Staples», clicked the first hit, and scrolled down to my answer. Here’s what works perfectly for me. This is the basic command format:

The -jpeg sets the output image format to JPG, -r 300 sets the output image resolution to 300 DPI, and the word output will be the prefix to all pages of images, which will be numbered and placed into your current directory you are working in. A better way, in my opinion, however, is to use mkdir -p images first to create an «images» directory, then set the output to images/pg so that all output images will be placed cleanly into the images dir you just created, with the file prefix pg in front of each of their numbers.

Therefore, here are my favorite commands:

1MB-sized files per pg] Output in .jpg format at 300 DPI:

2MB-sized files per pg] Output in .jpg format at highest quality (least compression) and still at 300 DPI:

If you need more resolution, you can try 600 DPI:

See the references below for more details and options.

References:

Keywords: ubuntu linux convert pdf to images; pdf to jpeg; ptdf to tiff; pdf2images; pdf2tiff; pdftoppm; pdftoimages; pdftotiff; pdftopng; pdf2png

Источник

How to Convert PDF to JPG on Linux

Margarete Cotty

2021-08-25 19:51:28 • Filed to: Knowledge of PDF • Proven solutions

Converting PDF to JPG in Linux requires tools that are different from most standard Windows and even Mac software. To convert PDF to JPG in Linux, you can use some powerful command-line (Terminal) utilities that most Windows users aren’t even aware of. For example, a Linux PDF to JPG conversion can be done by using either a command-line tool like pdftoppm or with GIMP, which has a graphical interface. In the example below, we’ll show you how to use the command-line option to convert PDF to JPG in Ubuntu using pdftoppm, which is part of the poppler-utils suite of tools for Linux users.

How to Convert PDF to JPG on Linux (with Ubuntu as an example)

The steps are fairly straightforward to convert PDF to JPG in Linux Ubuntu so you don’t need any extensive experience. However, it does help if you’ve worked with command-line utilities before. In addition, the installation command is slightly different for various Linux distros or distributions. This example shows you the Ubuntu command for installation and conversion.

  • 1. Open a Terminal window in your Ubuntu desktop and run this command without quotes: «sudo apt install poppler-utils». Hit «Enter» to run the command.
  • 2. Once the poppler-tools applications are installed, use this command followed by Enter (again, no quotes): «pdftoppm -jpeg document.pdf document» The command essentially tells the app to convert the file called «document.pdf» into a file called «document.jpg» You can also change it to «-png» if you prefer that as your output file. Please note that you should use the full form — jpeg — instead of just jpg.

That’s how to convert PDF to JPG in Linux running Ubuntu. If you’re a Windows or Mac user, you can use an application called PDFelement. This versatile PDF editor and conversion tool contains all the features you will ever need to process a PDF file.

How to Convert PDF to JPG on Windows and Mac

PDFelement is a professional PDF editor with basic and advanced features for creating PDFs, editing PDFs, converting to and from PDF, protecting PDFs, signing and filling PDF forms, annotating PDF files, performing OCR, batch-processing PDFs, and many such PDF tasks. Here’s a quick run-through of key features:

  • Create PDFs from 300+ other file types. You can also combine several source files of different types to make a single, large PDF file. This gives users a lot of flexibility because they can convert their entire document repository into a PDF archive that can be stored, searched, and edited.
  • Edit PDFs by changing any existing content, adding elements, or removing them. Some PDF editors will only allow you to overwrite content but this program gives you full freedom to change anything about the existing content, including static parts like footers, etc.
  • Convert PDFs to a host of other formats including JPG and other image types, Office files, HTML5, Text, ePub, etc. The conversion engine is super-fast and highly accurate, so all the original formatting, font attributes, alignment, etc. are perfectly maintained in the output file after conversion.
  • Protect PDF files with strong file encryption (password-based) and advanced permission levels for editing, printing, copying, viewing, etc. It provides security and flexibility, making it easy to manage access levels for different users who need to work with the same shared document.
  • Fill and sign PDF forms, create interactive forms, convert from other form types, extract data, perform automatic form field recognition, import and export data, etc. Form management is made easy and convenient when you have PDFelement at your service. Even complex forms with different types of form elements can be easily managed with this application.
  • Advanced processes like batch processing and OCR are available. Any image-based PDF that has been generated from a scanner can be converted with OCR into an editable or searchable (indexable) format. You can also directly use text recognition when scanning physical documents.
Читайте также:  Майнинг bitcoin для windows

Now, let’s look at the methods for how to convert PDF to JPG on Windows and how to convert PDF to JPG on Mac.

  • Step 1. Use the «Open File» option in the welcome page. Dragging and dropping the file also works.
  • Step 2. Choose «To Image» as the conversion option under the «Convert» tab. This will take you to the «Save As» page in Explorer, where you can specify the output file type «Image Files(*.JPG)» and the output folder for the converted file.
  • Step 3. When you’re ready to start the conversion, simply hit «Save» and wait for the conversion and file-saving to be complete.

It’s that simple! Not only can you convert PDF to JPG this way, but as you saw, PDFelement offers numerous other conversion options. The next section shows you how to convert PDF to JPG in Mac using PDFelement for Mac.

The macOS version of PDFelement is designed to suit the platform, so there are noticeable differences between this and the Windows version, which is designed for a better Windows experience. Here are the steps to go through:

  • Step 1. For macOS, the same method can be used to open the file as in the Windows version described above. Click the «Open File» option or use the «File в†’ Open» menu to import the PDF into the software.
  • Step 2. Next, click on «File в†’ Export To в†’ Image в†’ JPEG (.jpg)». This will open a new Finder window with a «Save» button. Choose the target folder to save the converted file and hit «Save» when ready.

Источник

How to convert PDF to image?

I have requirement of converting PDF pages to images. There is a background image with some text in my file, and when I save it as an image only the background image gets saved.

Читайте также:  Отключение usb устройства windows 10

Is there any software available for the same so that complete page can be converted to an image?

12 Answers 12

You can use pdftoppm to convert a PDF to a PNG:

This will output each page in the PDF using the format outputname-01.png , with 01 being the index of the page.

Converting a single page or a range of pages of the PDF

Change to the page number. It’s indexed at 1, so -f 1 would be the first page.

If you’d like to work on a range of pages, you can also specify a number for the flag -l (last page), so having -f 1 -l 30 would specify the pages from 1 to 30.

Specifying the converted image’s resolution

The default resolution for this command is 150 DPI. Increasing it will result in both a larger file size and more detail.

To increase the resolution of the converted PDF, add the options -rx and -ry . For example:

Using a terminal where the PDF is located:

For the full document:

For a single page:

PNG, JPG or (virtually) any other image format can be chosen.

-density xxx will set the DPI to xxx (common are 150 and 300).

-quality xxx will set the compression to xxx for PNG, JPG and MIFF file formates (100 means no compression).

[666] will convert only the 667th page to PNG (zero-based numbering so [0] is the 1st page).

All other options (such as trimming, grayscale, etc.) can be viewed on the website of Image Magic.

IIRC GIMP is capable of using PDFs, i.e. converting them into images. So if you want to edit the images right away — GIMP is your friend.

The currently accepted answer does the job but results in an output which is larger in size and suffers from quality loss.

The method in the answer given here results in an output which is comparable in size to the input and doesn’t suffer from quality loss.

TLDR — Use pdfimages : pdfimages -j input.pdf output

Quoting the linked answer:

It’s not clear what you mean by «quality loss». That could mean a lot of different things. Could you post some samples to illustrate? Perhaps cut the same section out of the poor quality and good quality versions (as a PNG to avoid further quality loss).

Perhaps you need to use -density to do the conversion at a higher dpi:

(You can prepend -units PixelsPerInch or -units PixelsPerCentimeter if necessary. My copy defaults to ppi.)

Update: As you pointed out, gscan2pdf (the way you’re using it) is just a wrapper for pdfimages (from poppler). pdfimages does not do the same thing that convert does when given a PDF as input.

convert takes the PDF, renders it at some resolution, and uses the resulting bitmap as the source image.

pdfimages looks through the PDF for embedded bitmap images and exports each one to a file. It simply ignores any text or vector drawing commands in the PDF.

As a result, if what you have is a PDF that’s just a wrapper around a series of bitmaps, pdfimages will do a much better job of extracting them, because it gets you the raw data at its original size. You probably also want to use the -j option to pdfimages , because a PDF can contain raw JPEG data. By default, pdfimages converts everything to PNM format, and converting JPEG > PPM > JPEG is a lossy process.

You may or may not need to follow that with a convert to .jpg step (depending on what bitmap format the PDF was using).

I tried this command on a PDF that I had made myself from a sequence of JPEG images. The extracted JPEGs were byte-for-byte identical to the source images. You can’t get higher quality than that.

Источник

Оцените статью