[NBLUG/talk] ImageMagic

Dave Sisley dsisley at arczip.com
Fri Aug 6 15:45:25 PDT 2004


steve:

On Thu, Aug 05, 2004 at 08:36:32PM -0700, Steve Smith wrote:
> Do we have any ImageMagick pro's out there?

I am NO 'pro', but I've always thought ImageMagick (IM) was a really
interesting and powerful application, so I did a little research.
Also, I'm a little confused by what you are asking so take the
following with a grain of salt...

> 
> I'm trying to cut a piece out of a postscript file and
> convert the result to png.  The closest I have come so far
> is
>     convert -crop 500x700+30+50 file.ps file.png

When I run this command on an existing .jpg, I get a new file which is
a 500X700 rectangle cut from the original, offset by 30+50 pixels
(from the upperleft hand corner: 30 px from the left, 50 px down).  In
other words, it is a section cut out of the original. 

> and this sort of works, but I end up with the image offset
> by 30+50 pixels.  I tried using -geometry and -crop in every
> combination I can think of and also -chop, but nothing seems
> to work as I'd expect.

I don't understand this part.  What do you mean when you say you "end
up with the image offset by 30+50 pixels"?  If you want to crop the
original from the upper left hand corner, just change the 30+50
argument to +0+0.

Interestingly, if I leave out the offset altogether, I get a
segmentation fault. (convert -crop 500x700 picture1.jpg picture2.jpg)
But it works if I use '+0+0'.

> 
> First I must misunderstand crop because I would expect it to
> just cut my image -- I don't understand why the offset goes
> with the image.

Do you mean that you are ending up with a picture that is 530X750 and
includes the upperleft hand corner?  As I said before, the command you
used yields (for me) a 500X700 picture that does NOT include the
upperleft hand corner of the original, thanks to the offset.

At first, I thought that what you wanted to do was to *remove* a
rectangle from your original picture.  Re-reading your email, I don't
think that's what you want, but since it took me some struggling to
figure out how to do it, I will tell you anyway:

convert -draw 'rectangle 30, 50, 530, 750' picture1.jpg picture2.jpg

What this does is draw a black rectangle in the region described, with
the upper left hand corner of the rectangle at 30, 50 and the lower
right corner at 530, 750.

Note that this uses a different method for spelling out where to put
the rectangle than '-crop' uses, but the 2 commands are referencing
the same region of the original image.

> 
> And second -- assuming that crop is the right operator, how
> do I remove the offset?

Again, I don't know what you mean by offset here.  Can you be more
specific?  I'm sure we can figure this out.

-dave.

-- 
Dave Sisley
dsisley at arczip.com
roth-sisley.net




More information about the talk mailing list