Hi!
I've googling around like crazy and I haven't been able to find a solution to my problem. I'm using ImageMagicks convert to create png images from a pdf file. The problem is that on every pdf I try it adds white margins on the created images and I can't find how to get rid of them
I'm using ImageMagick 6.6.0-4 on a Debian 6.0 server. The command I execute is this:
convert "PDF_FILE" -colorspace RGB -resize 490x694\! -density 300 -quality 100 "PNG_FILE"
I've tried it with and without the resize, with crop, with no parameters at all...
Here is a PDF file I've tried and the resulting PNG file:
The PDF: https://dl.dropbox.com/u/4279061/epeich.pdf
A PNG image, the first page of the PDF file: https://dl.dropbox.com/u/4279061/340.png
I guess it's something simple... but as a newbie... I can't find the solution. Thanks for the help!
Convert adds white margins
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert adds white margins
I suspect it is some feature in the PDF file such as bounding box. You can either try using Ghostscript directly with more options than IM uses with GS or just trim the result and add any border that you want, such as
convert -colorspace RGB epeich.pdf[0] +repage -resize 490x694\! -density 300 -quality 100 -trim -bordercolor white -border 10 result.png
Here I have just used the first page as noted by [0]. Also for vector images, you should put -colorspace before reading the input.
convert -colorspace RGB epeich.pdf[0] +repage -resize 490x694\! -density 300 -quality 100 -trim -bordercolor white -border 10 result.png
Here I have just used the first page as noted by [0]. Also for vector images, you should put -colorspace before reading the input.
Re: Convert adds white margins
Thanks!!! Worked like a charm
Re: Convert adds white margins
Woops! Maybe I wrote too fast. Now it works as wanted, no white margins, but it doesn't do to the specified size
The output images are 368x544 even it has " -resize 490x694\! " Here is an generated image:
https://dl.dropbox.com/u/4279061/344.png
Thanks for the fast response
The output images are 368x544 even it has " -resize 490x694\! " Here is an generated image:
https://dl.dropbox.com/u/4279061/344.png
Thanks for the fast response
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert adds white margins
try putting the -trim before the resize
convert -colorspace RGB epeich.pdf[0] +repage -trim +repage -resize 490x694\! -density 300 -quality 100 result.png
or
convert -colorspace RGB epeich.pdf[0] +repage -trim +repage -bordercolor white -border XX -resize 490x694\! -density 300 -quality 100 result.png
Use the border value XX as desired for padding.
convert -colorspace RGB epeich.pdf[0] +repage -trim +repage -resize 490x694\! -density 300 -quality 100 result.png
or
convert -colorspace RGB epeich.pdf[0] +repage -trim +repage -bordercolor white -border XX -resize 490x694\! -density 300 -quality 100 result.png
Use the border value XX as desired for padding.
Re: Convert adds white margins
Thanks! It worked perfectly