gravity

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
blowzy
Posts: 8
Joined: 2011-12-20T12:04:44-07:00
Authentication code: 8675308

gravity

Post by blowzy »

Is there any way with magick++ to use gravity parameter ( Magick::CenterGravity ) when croping/resizing images? Need to crop from the center (or count pixels to crop from the right/bottom) i.e. something like this gravity parameter from command line

Code: Select all

convert -thumbnail "120x90>" -gravity Center -extent 120x90 monalisa171p.jpg monalisa171p_thumb.jpg 
thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: gravity

Post by magick »

The Magick++ extent() method is overloaded and accept a gravity argument. Use one of extent ( const Geometry &geometry_, const GravityType gravity_ ) or extent ( const Geometry &geometry_, const Color &backgroundColor_, const GravityType gravity_ ).
blowzy
Posts: 8
Joined: 2011-12-20T12:04:44-07:00
Authentication code: 8675308

Re: gravity

Post by blowzy »

thanks for the answer. will try how works extent() (because still need to crop from the bottom with offset)

now, for center coping i wrote something like this and use value as crop offset:

Code: Select all

over_pixels_height = floor( ( img.rows() - thumb_height) / 2 );
ps. sorry for my english
Post Reply