From c9133b258f26951b34d278d86935273680c6ff36 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 8 Nov 2017 15:50:02 -0500 Subject: 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. --- grunge.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 { pic.read(img); - if ((pic.rows() > 0) && (pic.columns() >= 800)) + if (pic.rows() > 0) { std::cout << url << std::endl; found = true; @@ -265,6 +265,16 @@ Magick::Image grunge::getImageForNoun(verbly::word pictured) const Magick::Image grunge::pixelateImage(Magick::Image image) const { + // Check that the image is at least 800 pixels in width. + if (image.columns() < 800) + { + Magick::Geometry blownUp( + 800, + image.rows() * 800 / image.columns()); + + image.zoom(blownUp); + } + // Check that the image dimensions are a multiple of four. if ((image.rows() % 4 != 0) || (image.columns() % 4 != 0)) { -- cgit 1.4.1