Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2771)

Issue 575041: Round instead of truncating the dimensions when resizing an image

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 1 month ago by jtarrio
Modified:
14 years, 1 month ago
Reviewers:
Paul Lindner, zhoresh, shindig.remailer
Base URL:
http://svn.apache.org/repos/asf/shindig/trunk
Visibility:
Public.

Description

The image resizing code first calculates the optimum ratio to reduce the image by, then calculates the dimensions, and checks which one hasn't changed to set the other. The problem is, when the image is 600x400 and it is to be resized to 171x171, the result of the calculation for the new image is 170.999999997, which gets truncated to 170 instead of 171, the code doesn't set the other dimension and the image gets resized to 171x171 instead of 171x114. This patch makes the code use Math.round to avoid such things happening. Note that the change also includes a 600x400 GIF file, but as it's a binary, diff didn't pick it up. it can be easily recreated for final submission as long as it's that size.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -1 line) Patch
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java View 1 chunk +2 lines, -2 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/ImageRewriterTest.java View 2 chunks +11 lines, -0 lines 0 comments Download
java/gadgets/src/test/resources/org/apache/shindig/gadgets/rewrite/image/ratio.gif View 0 chunks +-1 lines, --1 lines 0 comments Download

Messages

Total messages: 3
jtarrio
14 years, 1 month ago (2010-03-15 22:05:20 UTC) #1
zhoresh
LGTM
14 years, 1 month ago (2010-03-16 00:21:11 UTC) #2
Paul Lindner
14 years, 1 month ago (2010-03-16 06:32:50 UTC) #3
lgtm too.

Please attach this patch to a jira issue so it can clear legal reqs and I (or
one of the other committers) can get this in.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b