Page 1 of 1

Slicing off the bottom 20% of an image

Posted: 2010-01-21T12:06:34-07:00
by Legal
I have a stack of multi-page PDFs that I'm feeding through IM to convert to JPGs, but I've been struggling. I have two questions:

1) I can convert every page of the PDF to individual .jpg files with the command

Code: Select all

convert -density 190 filename.pdf filename.jpg
. How can I convert just the first page of the PDF (or just a single page inside the PDF?) Is this possible?
2) Even if I can't pluck out a single page, I'd like to cut off the bottom 20% of every page and save them as separate .jpg files. How can I do this?

I really appreciate any help you can provide. Thank you!

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-21T12:33:46-07:00
by Bonzo
Work on page 1: filename.pdf[0] page 2 filename.pdf[1] etc.

If you are working on standard size pages try this:
work out the 20% height size, page width, 80% page height ( all in pixels ) and:

Code: Select all

convert filename.pdf -crop pagewidth,20%height+pagewidth+80%height +repage output.jpg

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-21T13:08:32-07:00
by Legal
Bonzo,

The page selection bit works perfectly, thank you! I'm still confused about the repaging part, though. The image is 1615(w) x 2090(h). Where do those numbers fit in your example? I'm looking to keep just the bottom 20%.

I really appreciate your help.

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-21T13:57:09-07:00
by magick
As an example, try this:
  • convert rose: -gravity south -crop 100x20% +repage bottom.png

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T10:34:04-07:00
by Legal
This worked swimmingly--thank you both so much.

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T12:41:03-07:00
by Legal
Hm. Slightly different issue: it looks like I'm losing a lot of quality compared to the original PDF. I tried futzing with -density, but that didn't seem to help.

I've been using this:

Code: Select all

convert Filename.pdf -gravity south -crop 100x20% +repage Filename.jpg
...to convert every page of a PDF to a separate .jpg. Unfortunately, the final file looks like it shrinks by about 10% (width) and loses a bundle in quality (particularly, it changes to straight up B&W rather than grayscale).

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T14:28:00-07:00
by fmw42
try using supersampling (will take longer but usually gets better quality)

convert -density 288 Filename.pdf -resize 25% -gravity south -crop 100x20% +repage Filename.jpg

density 288 is 4x72, where 72 is nonminal, so you reduce afterwards by 1/4=25%

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T16:29:58-07:00
by Legal
Hm... that seems to have just shrunk it to 25% of its size.

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T18:05:52-07:00
by Legal
Alright, I have no idea what I changed, but I futzed with it until it worked. I now have:

Code: Select all

convert.exe -density 190 Filename.pdf -gravity south -crop 100x20% +repage Filename.jpg
Now to just add one more issue, I'm trying to slice off ten percent from the left and right. I tried "-crop right" and "-crop east" but those don't seem to work. What am I looking for, and where do I place it in the string for the intended result?

I really appreciate any help you can provide.

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-22T18:14:26-07:00
by fmw42
see http://www.imagemagick.org/Usage/crop/#shave

add -shave 10x0% right after the input or right after -crop

Good reading and lots of examples is at http://www.imagemagick.org/Usage/

Re: Animated Gifs

Posted: 2010-01-25T12:11:50-07:00
by Legal
You folks are tremendously helpful, thank you. The shaving worked swimmingly!

I have a slightly different question. I've got the commands I want to run now, which looks like this:

Code: Select all

convert.exe" -density 150 Filename.pdf -gravity south -crop 100x20% -shave 20x0% +repage Filename.gif
Unfortunately, unlike when I was using .jpg as the output file, the .gif takes a multi-page .pdf and converts it to an animated .gif. This isn't the result I want--I'd like separate .gifs for each file (as it did when it was a .jpg). I've reviewed the Usage guide regarding .gifs, but I was unable to locate a solution. Is this where I'm supposed to use the -dispose parameter? If so, where should it be placed.

I appreciate your patience with my questions,

Alexander

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-25T12:27:24-07:00
by fmw42
see +adjoin at http://www.imagemagick.org/script/comma ... php#adjoin

or just name your output image, Filename_%d.gif

Re: Slicing off the bottom 20% of an image

Posted: 2010-01-25T16:03:39-07:00
by Legal
Thank you so much for your help, that works!