Last modified: 2005-12-14 11:28:18 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T2153, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 153 - Discrepancy between thumbnail size and <img height=xx width=xx>
Discrepancy between thumbnail size and <img height=xx width=xx>
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
unspecified
All All
: Low minor with 4 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-08-16 21:43 UTC by Stephan Walter
Modified: 2005-12-14 11:28 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
1-line patch to fix the problem (587 bytes, patch)
2005-05-30 22:24 UTC, David Benbennick
Details
There was a second "floor" I missed (585 bytes, patch)
2005-09-10 21:02 UTC, David Benbennick
Details
Fix the same issue on image description pages (2.16 KB, patch)
2005-09-26 08:01 UTC, David Benbennick
Details
Fix some problems when limiting the image's height (6.35 KB, patch)
2005-09-26 10:15 UTC, David Benbennick
Details

Description Stephan Walter 2004-08-16 21:43:38 UTC
When inserting a thumbnailed image, the size of the generated thumbnail (in
/upload/thumb/) is not always the same as the height and width specified in the
<img> tag.

Example: See http://de.wikipedia.org/wiki/Benutzer:Stw/Test

The thumbnail size is 161x101, but in the HTML you have <img ... width="161"
height="100">

This leads to ugly resizing on some browsers
Comment 1 David Benbennick 2005-05-30 07:24:36 UTC
I've seen the same thing with the third image at
[http://en.wikipedia.org/wiki/Petersen_graph].  I thought it was a problem with
my image; bravo for nailing down what the real problem is!
Comment 2 Rowan Collins [IMSoP] 2005-05-30 13:43:15 UTC
This is because MediaWiki's image code calculates the width *and* height, but
then only passes the width to the resizing code (i.e. ImageMagick or the GD
library). While it would presumably be possible to always arrive at the same
answer, it might be more reliable to ask the actual resize code what the
resulting height was and insert that into the html attribute.

If I ever get around to finally polishing my patch at bug 689, I'll probably
make it work that way.
Comment 3 David Benbennick 2005-05-30 22:24:44 UTC
Created attachment 580 [details]
1-line patch to fix the problem

ImageMagick apparently rounds when thumbnailing, instead of truncating.

I agree that it would be better to just identify the actual dimensions of the
thumbnail, instead of relying on how ImageMagick works internally.  There are
two issues with that solution:

1) Identifying the dimensions of a PNG image is slow.  We'd have to store that
data somewhere, instead of calculating it every time the page is rendered.

2) With a short, wide image (for example, [[Commons:Image:Tape measure.jpg]]),
asking for a 1px thumbnail simply copies the original image size (see
http://upload.wikimedia.org/wikipedia/commons/thumb/0/04/1px-Tape_measure.jpg,
which is 1623x393).  So that error would have to be detected.
Comment 4 Antoine "hashar" Musso (WMF) 2005-07-08 10:18:09 UTC
Solve the issue and commited. Thanks for the patch.
Comment 5 David Benbennick 2005-07-22 14:48:48 UTC
Doesn't seem to have been fixed.  See, for example,
[[Arapahoe County, Colorado]].  The locator map is 300 x 217 on the 
page, but the thumbnail is really 300 x 218.
Comment 6 David Benbennick 2005-09-10 21:02:05 UTC
Created attachment 868 [details]
There was a second "floor" I missed

Ah, there was a "floor" in Image.php, too.  This trivial patch changes it to
"round".
Comment 7 David Benbennick 2005-09-26 08:01:35 UTC
Created attachment 915 [details]
Fix the same issue on image description pages

The same problem with floor instead of round existed on image description
pages.	In addition, if the image height was the limiting factor, the code
would floor twice, adding an extra error.  This patch replaces that hunk of
code with something that only rounds once in either case, and that calculates
the thumbnail's height and width correctly.
Comment 8 David Benbennick 2005-09-26 10:15:19 UTC
Created attachment 916 [details]
Fix some problems when limiting the image's height

See http://commons.wikimedia.org/wiki/User:Dbenbenn/sandbox, which shows two
examples where MediaWiki is badly broken.  Here's a combined patch to fix all
the problems I've found so far involving a disagreement between a thumbnail's
size and the <img> height and width parameters.
Comment 9 Brion Vibber 2005-10-05 02:03:04 UTC
Marking need-review for updated patch.
Comment 10 Gregory Maxwell 2005-12-04 00:30:41 UTC
ahh I'd made the same fix as above, but didn't catch some of the other places...
Came here to submit a patch, but it seems unneeded now. You should completely
omit the -size from convert as -resize is all we need (and who knows what what
other bugs we might trigger) :)
Comment 11 Brion Vibber 2005-12-04 08:26:58 UTC
As discussed in IRC, -size is required to avoid huge memory wastage on large source JPEG images.

Patch looks ok (live on test.leuksman.com), but SF.net CVS is currently on the fritz, so can't commit 
just now.
Comment 12 Brion Vibber 2005-12-04 08:27:51 UTC
Also see bug 4162; it'll be necessary to rerender a lot of thumbs.
Comment 13 Brion Vibber 2005-12-04 09:04:54 UTC
Applied on CVS HEAD
Comment 14 lɛʁi לערי ריינהארט 2005-12-14 11:28:18 UTC
Should
bug 4207: Wrong image size when using 100x200px syntax to scale image up
be marked as a duplicate or a dependency?

regards reinhardt [[user:gangleri]]

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links