Hello.
I'm trying to autocrop PDF geometric pictures that I created with LaTeX.
I used pdftoppm to convert the PDF to a PNG, then 'convert -trim file.png newfile.png' to crop the PNG.
However, the cropped PNG is shifted down to the right, according to identify and to the Gimp:
$ identify newfile.png
ds2-tikz-1.png PNG 1654x2363 4961x7016+279+154 8-bit PseudoClass 256c 41.3kb
How can I avoid this shift automatically? In Gimp, autocrop adjusts the bounding box of the image, is there a similar function with ImageMagick?
Thanks.
--
F. Delente
Autocropping: image is shifted
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Autocropping: image is shifted
post a link to your image.
It may be that your background is not constant, so you could add -fuzz XX% -trim +repage to allow the trimming to get closer to the part of the image you want to extract and (+repage) to remove any virtual canvas,which may be the problem.
It may be that your background is not constant, so you could add -fuzz XX% -trim +repage to allow the trimming to get closer to the part of the image you want to extract and (+repage) to remove any virtual canvas,which may be the problem.
Re: Autocropping: image is shifted
> post a link to your image.
The original uncropped image (from a PDF, at 600DPI) http://fdelente.free.fr/original.png.
The image cropped by convert http://fdelente.free.fr/cropped.png.
> It may be that your background is not constant, so you could add -fuzz XX% -trim +repage to allow the trimming to get closer to the part of the image you want to extract and (+repage) to remove any virtual canvas,which may be the problem.
I don't know about the virtual canvas, that maybe the culprit, but for the fuzz part, my background is pure white so I don't think it's the cause.
--
F. Delente
The original uncropped image (from a PDF, at 600DPI) http://fdelente.free.fr/original.png.
The image cropped by convert http://fdelente.free.fr/cropped.png.
> It may be that your background is not constant, so you could add -fuzz XX% -trim +repage to allow the trimming to get closer to the part of the image you want to extract and (+repage) to remove any virtual canvas,which may be the problem.
I don't know about the virtual canvas, that maybe the culprit, but for the fuzz part, my background is pure white so I don't think it's the cause.
--
F. Delente
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Autocropping: image is shifted
your trim has left a virtual canvas around the image, so remove the virtual canvas after trimming
convert original.png -trim +repage cropped.png
see if that does what you want.
convert original.png -trim +repage cropped.png
see if that does what you want.
Re: Autocropping: image is shifted
Perfect, problem solved!
Thank you very much for your help!
--
F. Delente
Thank you very much for your help!
--
F. Delente