Convert 600dpi pdf to 150dpi pdf #3983
Replies: 9 comments 5 replies
-
You are usig PDF as a wrapper for a raster image. The raster image was scanned at 600 dpi, but the PDF itself is only 72 dpi. You can verify this with "magick yourfile.pdf -verbose info:" As you have discovered, using "-density" before reading the PDF affects the size, ie how many pixels you get. If you use 72 dpi, there will be no change. But you want to reduce by a factor of 600/150=4 linearly. So 72/4 = 18. Use "-density 18". |
Beta Was this translation helpful? Give feedback.
-
I don't know what you are trying to do, so advice is difficult. PDF files can contain multiple images, each with different densities (dpi). And the overall PDF has its own density. For this reason and others, PDFs are not a convenient format for image processing. When there is one raster image per PDF, the PDF wrapper is entirely pointless. It just adds a layer of complexity, and has no benefit. When I scan documents, I always save images in raster image files, never as PDF files. ImageMagick is not concerned with raster images that are inside PDF wrappers. Instead, IM is concerned with PDF pages. When IM reads a PDF, it converts each page to a raster image. It doesn't matter if the page happens to contain text or vector data or multiple raster images, IM will create a single raster image from that page. When I receive a PDF file and I want the raster images it contains, I extract the images with "pdfimages", a common tool. I don't use IM to rasterize the pages because I care about the embedded raster images, not about the pages. Similarly, I don't create PDF files that contain just raster images, because there is no point. |
Beta Was this translation helpful? Give feedback.
-
Interesting.
Not targeted for editing What I have achieved: What I want to achieve: So, how I can batch convert a high dpi pdf in which every page is a raster image with same scan parameter, into a lower resolution. Method1: Method2:
This can do the job, then it needs some programming/scripting to batch it. However, I was surprised to compare
Except if I miss understood, this extracts the original images and won't compress. Why would IM do a lesser job? Thanks |
Beta Was this translation helpful? Give feedback.
-
I do not suggest reading the PDFs with IM. If you do that, then Ghostscript (as the delegate of IM) will resample the raster images. Resampling will give worse quality than simply extracting the raster images.
Don't be surprised. pdftoppm is a similar program to pdfimages, from the same Poppler family. I suggest you extract the raster images with pdfimages (or pdftoppm, if you prefer). Then resize each image with "magick in.ext -resize 25% out.ext". The output can be a PDF if you want. To assemble them into a single PDF, and you have enough memory for all the inputs you can "magick in*.ext -resize 25% out.pdf".
IM doesn't do a lesser job. It does a different job. IM rasterizes PDF pages. That isn't the task you want. The task you want is to extract raster images from PDF files. |
Beta Was this translation helpful? Give feedback.
-
hi everyone, magick convert -density 300 "d:\PDFFolder and i get a good result for black and white pdfs, but when i need to convert colour pdf, file size increases many times. but when i convert file to jpeg and then back to pdf, file size barely changes. how do i create scanned pdf version without increasing file size? |
Beta Was this translation helpful? Give feedback.
-
Why are you using If your input PDF contains just one raster image, and that is all you want, I suggest extracting that with |
Beta Was this translation helpful? Give feedback.
-
If your PDF contains text (as vector elements, not raster), and you want that text in your result, then IM is a good tool. To get the "new" syntax, just remove Vector text doesn't take much space in the PDF. For example "hello" takes maybe 5 or 10 bytes. IM will convert this to raster (pixels), and that string might need 500 or 5000 pixels, which takes more space in the file. |
Beta Was this translation helpful? Give feedback.
-
I don't understand what that means. |
Beta Was this translation helpful? Give feedback.
-
this is processing a document so that it looks like you took a printed document and scanned it |
Beta Was this translation helpful? Give feedback.
-
Hi,
I scanned a paper document in 600dpi
The result colour file in.pdf is 8mb
If I run:
convert -density 150 "in.pdf" out.pdf
out.pdf is twice bigger
If I run:
convert -density 150 "in.pdf" -quality 80 -scene 1 dpi150q80-%3d.jpg
then
convert *.jpg -auto-orient allJpegsIntoSingleFile.pdf
allJpegsIntoSingleFile.pdf is 1.8mb
Questions:
1/ How to convert the 600dpi to 150dpi at once?
What's wrong with the first command, namely
convert -density 150 "in.pdf" out.pdf
2/ convert -density 150 "in.pdf" -quality 80 -scene 1 dpi150q80-%3d.jpg
Does a less better job in terms of jpegs when one zooms in, than
pdftoppm -jpeg "in.pdf" outJpegs
Eventhough, same algo, same colorspace and even quality is 75
What can I do to enhance the output of convert?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions