【发布时间】:2018-01-09 08:52:27
【问题描述】:
//add text watermark on animated gif
std::vector<Image> imglist;
std::vector<Drawable> text_list;
text_list.push_back( DrawableText(0, 0, “I love you!"));
text_list.push_back( DrawableStrokeColor(Color("black")));
try {
readImages(&imglist, "test.gif");
for (uint32_t i = 0; i < imglist.size(); ++i) {
imglist[i].font("./MILT_RG.ttf");
imglist[i].draw(text_list);
}
writeImages(imglist.begin(), imglist.end(), "test_render.gif");
} catch (Exception &error_) {
cout << error_.what() << endl;
}
但是函数 writeImages 花费了太多时间。在我的测试示例中,一个 gif,900x600,20 帧,需要 1.5 秒。有什么办法可以加快速度吗?或者,一些更好的算法可以在 gif 上添加文本水印。谢谢。
【问题讨论】:
-
只是在 Eric 稍后上线之前疯狂地猜测,但您可以尝试将文本写入透明画布一次,然后在 20 帧中的每一帧上合成...
标签: c++ image imagemagick gif