Pdf image crop on windows server

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?".
Post Reply
pieter
Posts: 4
Joined: 2016-09-06T02:45:55-07:00
Authentication code: 1151

Pdf image crop on windows server

Post by pieter »

Hello,

Is it possible with imageMagick to crop a pdf to another pdf (with different size) with a command on windows server?

Kind regards,

Pieter
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Pdf image crop on windows server

Post by snibgo »

Yes.

If you want more detail, we need more information. Do you want half the pages, or half of each page, or what? If your input pdf contains vector data or ordinary text, that will be rasterized (converted to pixels).
snibgo's IM pages: im.snibgo.com
pieter
Posts: 4
Joined: 2016-09-06T02:45:55-07:00
Authentication code: 1151

Re: Pdf image crop on windows server

Post by pieter »

Hello snibgo, that sounds great. Thank you:)

Each pdf is one page with a photo on it, but it has a edge which is white. This white edge is for example 50 millimetre wide.

Imageimage hosting site over 5mb

It would great if a pdf can be cropped this way automaticly when a pdf is uploaded to a windows server. Another way is that a pdf can be send from our application to imagemagick with a command to crop the pdf. If one of these ways is possible this could save a lot of time for us:)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Pdf image crop on windows server

Post by snibgo »

pieter wrote:Each pdf is one page with a photo on it, ...
Okay. I would extract the photo with pdfimages, a tool available for Unix and Windows. This makes a raster image file, eg "myphoto.jpg". Then use IM to convert that to a PDF:

Code: Select all

convert myphoto.jpg myphoto.pdf
The result myphoto.pdf will have no margins.

Personally, I can't see the point of a PDF wrapper around raster images, but some people like them.
snibgo's IM pages: im.snibgo.com
pieter
Posts: 4
Joined: 2016-09-06T02:45:55-07:00
Authentication code: 1151

Re: Pdf image crop on windows server

Post by pieter »

I am not sure whether we need pdfimages, because the pdf is actually one picture, (Not a pdf with a picture/photo/jpg in it).
pieter
Posts: 4
Joined: 2016-09-06T02:45:55-07:00
Authentication code: 1151

Re: Pdf image crop on windows server

Post by pieter »

Hello,

An update:

I have installed Image Magick and ghostscript.

I almost got a solution. I removed a white edge of 5 mm at the bottom, but unfortunatly a small white edge appeared at the top of the pdf. It is still a big improvement. I will work further on it.

Some examples:
magick -density 300 -quality 100 input.pdf -gravity South -chop 0X78 output.pdf
magick -density 400 -quality 100 input.pdf -gravity South -chop 0X70 output.pdf
magick -density 300x300 input.pdf -background white -extent 637.794x1003.9371 output.pdf
magick -density 254x254 input.pdf -gravity South -chop 0x59,05512 output.pdf

snibgo, again thanks for your suggestions:D

Pieter
Post Reply