Watermarking images in multiple sub-directories

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
philipt18
Posts: 9
Joined: 2012-12-04T13:51:10-07:00
Authentication code: 6789

Re: Watermarking images in multiple sub-directories

Post by philipt18 »

It's true that some PDFs have no resolution, when they're generate with text and scalable graphics. However, when a PDF is a scanned image, for example, it's basically just holding an embedded JPG image inside it, and that image has a resolution. So for example, if I scan a business card at 600dpi and save it as a PDF, and then convert the PDF using imagemagick it seems I would get a business-card size image at 72dpi, which would obviously be unreadable. That's what's going on here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking images in multiple sub-directories

Post by fmw42 »

snibgo wrote:See, for example, Low resolution when converting small PDF to png.

As I understand it, there is no "as is" resolution for PDF files. They can be reproduced at any resolution. By default, IM doesn't supersample the pixels so it is fast, but supersampling is frequently needed for decent quality.

The real issue is when the PDF has an imbedded image. This has been discussed quite a bit on the forum. So the original poster should search the forum and read those posts.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermarking images in multiple sub-directories

Post by fmw42 »

philipt18 wrote:I see in other discussions this resolution loss problem when converting from PDF to JPG. It suggests using the -density setting to counteract that. Seems odd that there is no way to get it to keep the resolution as is. If you know of a way, I would love to hear it.

Also, I noticed your mogrify command uses -format jpg, but as it's operating on *.jpg, what does that do? Thanks.

The usual way to improve PDFs is to use super sampling.

convert -density 288 image.pdf -resize 25% image.jpg

nominal density is 72, so 72*4=288 and then resize back down to 1/4=25%

The -format jpg used is to make sure all resulting images are jpg. The *.jpg could have been just * and it would try to change every type of image, not just jpg.


You may have to do one pass for every non vector format (jpg, png, tiff, bmp etc), which I think can be done in one pass for them all.

And then do another pass just for the vector formats such as pdf with changed density, though I have not tested that with the commands above.
Post Reply