summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2014-01-21 14:35:12 -0200
committerPhilip Chimento <philip@endlessm.com>2014-01-21 14:35:12 -0200
commitf3f8608f3574c0790b94d9a283c25b6cfb01a220 (patch)
treea0d403a53b69f8651edcf7c6c740a3975e62833d
parenta73b1caf87043cb3bcca683c03d2218584216bdf (diff)
Crop category pixbufs from bottom left
Instead of the top left which we were doing until now, crop the pixbufs from the bottom left. [endlessm/eos-sdk#487]
-rw-r--r--wikipedia/utils.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/wikipedia/utils.js b/wikipedia/utils.js
index f08deed..0838bd5 100644
--- a/wikipedia/utils.js
+++ b/wikipedia/utils.js
@@ -164,7 +164,8 @@ const array_contains = function (arr, obj, same_type) {
/*
* Loads a pixbuf sized to cover the dest_width and dest_height with the
- * image in res_path, while mataining the aspect ratio of the image
+ * image in res_path, while mataining the aspect ratio of the image.
+ * The anchor point for cropping is the bottom left of the image.
*/
function load_pixbuf_cover(res_path, dest_width, dest_height) {
let [load_width, load_height] = [dest_width, dest_height];
@@ -184,7 +185,8 @@ function load_pixbuf_cover(res_path, dest_width, dest_height) {
load_width, load_height, true);
let cropped_pixbuf = source_pixbuf;
if(dest_width < source_pixbuf.width || dest_height < source_pixbuf.height)
- cropped_pixbuf = source_pixbuf.new_subpixbuf(0, 0, dest_width, dest_height);
+ cropped_pixbuf = source_pixbuf.new_subpixbuf(0, source_pixbuf.height - dest_height,
+ dest_width, dest_height);
return cropped_pixbuf;
}