int process(Magick::Image & img)
{
Magick::Geometry geo;
geo.width(144);
geo.height(144);
img.resize(geo); //缩放
geo.width(114);
geo.height(114);
geo.xOff(15);
geo.yOff(15);
img.crop(geo); //裁剪
printf("crop 114|%s \n", img.baseFilename().c_str());
return 0;
{
Magick::Geometry geo;
geo.width(144);
geo.height(144);
img.resize(geo); //缩放
geo.width(114);
geo.height(114);
geo.xOff(15);
geo.yOff(15);
img.crop(geo); //裁剪
printf("crop 114|%s \n", img.baseFilename().c_str());
return 0;
}
效果:原图
缩放
裁剪

本文介绍了一个使用Magick::Image库进行图片处理的方法,包括将图片缩放到144x144像素,然后从中心裁剪出114x114像素的图片。此过程通过定义几何参数并调用resize与crop函数实现。

被折叠的 条评论
为什么被折叠?



