summary refs log tree commit diff stats
path: root/grunge.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-11-08 15:50:02 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-11-08 15:50:02 -0500
commitc9133b258f26951b34d278d86935273680c6ff36 (patch)
tree3933a3334dd549e0f8ea76f097580bfef4e1d403 /grunge.cpp
parent42741a3659281ffbef259eafeeb127b3286506cf (diff)
downloadgrunge-c9133b258f26951b34d278d86935273680c6ff36.tar.gz
grunge-c9133b258f26951b34d278d86935273680c6ff36.tar.bz2
grunge-c9133b258f26951b34d278d86935273680c6ff36.zip
Allowed images narrower than 800 pixels
Previously, the bot would try to ensure that it didn't use an image
narrower than 800 pixels. This would sometimes cause it to download lots
of images trying to find a valid one, and eventually end up stalling
forever. To prevent this, images that are narrower than 800 pixels are
now scaled up.
Diffstat (limited to 'grunge.cpp')
-rw-r--r--grunge.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/grunge.cpp b/grunge.cpp index 2f6783c..af5da13 100644 --- a/grunge.cpp +++ b/grunge.cpp
@@ -243,7 +243,7 @@ Magick::Image grunge::getImageForNoun(verbly::word pictured) const
243 { 243 {
244 pic.read(img); 244 pic.read(img);
245 245
246 if ((pic.rows() > 0) && (pic.columns() >= 800)) 246 if (pic.rows() > 0)
247 { 247 {
248 std::cout << url << std::endl; 248 std::cout << url << std::endl;
249 found = true; 249 found = true;
@@ -265,6 +265,16 @@ Magick::Image grunge::getImageForNoun(verbly::word pictured) const
265 265
266Magick::Image grunge::pixelateImage(Magick::Image image) const 266Magick::Image grunge::pixelateImage(Magick::Image image) const
267{ 267{
268 // Check that the image is at least 800 pixels in width.
269 if (image.columns() < 800)
270 {
271 Magick::Geometry blownUp(
272 800,
273 image.rows() * 800 / image.columns());
274
275 image.zoom(blownUp);
276 }
277
268 // Check that the image dimensions are a multiple of four. 278 // Check that the image dimensions are a multiple of four.
269 if ((image.rows() % 4 != 0) || (image.columns() % 4 != 0)) 279 if ((image.rows() % 4 != 0) || (image.columns() % 4 != 0))
270 { 280 {