From ce1dbfeb0ffc067fad144e2f97f57600c6b4c4eb Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 22 May 2014 15:01:58 +0200 Subject: [PATCH] fix appearance of image search thumbnails. --- htroot/ViewImage.java | 19 +++++++++++++++++++ htroot/yacysearchitem.html | 4 ++-- htroot/yacysearchitem.java | 5 +---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java index d0e9b1271..b7fb2baba 100644 --- a/htroot/ViewImage.java +++ b/htroot/ViewImage.java @@ -21,6 +21,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import java.awt.Container; +import java.awt.Graphics2D; import java.awt.Image; import java.awt.MediaTracker; import java.awt.image.BufferedImage; @@ -72,6 +73,7 @@ public class ViewImage { String urlString = post.get("url", ""); final String urlLicense = post.get("code", ""); + final boolean quadratic = post.containsKey("quadratic"); final boolean auth = Domains.isLocalhost(header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")) || sb.verifyAuthentication(header); // handle access rights DigestURL url = null; @@ -146,6 +148,23 @@ public class ViewImage { // find original size final int h = image.getHeight(null); final int w = image.getWidth(null); + + // if a quadratic flag is set, we cut the image out to be in quadratic shape + if (quadratic && w != h) { + if (w > h) { + final BufferedImage dst = new BufferedImage(h, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = dst.createGraphics(); + g.drawImage(image, 0, 0, h - 1, h - 1, (w - h) / 2, 0, h + (w - h) / 2, h - 1, null); + g.dispose(); + image = dst; + } else { + final BufferedImage dst = new BufferedImage(w, w, BufferedImage.TYPE_INT_RGB); + Graphics2D g = dst.createGraphics(); + g.drawImage(image, 0, 0, w - 1, w - 1, 0, (h - w) / 2, w - 1, w + (h - w) / 2, null); + g.dispose(); + image = dst; + } + } // in case of not-authorized access shrink the image to prevent // copyright problems, so that images are not larger than thumbnails diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html index 8f51dfc11..2f1a2b430 100644 --- a/htroot/yacysearchitem.html +++ b/htroot/yacysearchitem.html @@ -37,9 +37,9 @@ :: #(item)#::
- + - #[name]# + #[name]#