Last modified: 2008-12-16 05:46:27 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 T5691, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 3691 - Aspect ratio broken for SVG images without size attributes (PATCH included)
Aspect ratio broken for SVG images without size attributes (PATCH included)
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
1.6.x
All All
: Normal normal with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
http://commons.wikimedia.org/wiki/Ima...
:
: 4609 11163 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-10-13 01:14 UTC by Daniel Kinzler
Modified: 2008-12-16 05:46 UTC (History)
2 users (show)

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


Attachments
patch for Image.php for fixing size and aspect ratio of SVG images without width/height attributes. (1.91 KB, patch)
2005-10-13 01:17 UTC, Daniel Kinzler
Details
updated patch (2.13 KB, patch)
2005-10-27 22:46 UTC, Daniel Kinzler
Details
fixed float behavior (3.16 KB, patch)
2005-10-28 00:05 UTC, Daniel Kinzler
Details

Description Daniel Kinzler 2005-10-13 01:14:16 UTC
Images that do not have a width and height attribute are currently rendered to
256x256 pixel. This breaks the aspect ratio for all non-square images, and is
also quite small.

SVG does not require the width and height attributes to be present, see
<http://www.w3.org/TR/SVG/coords.html#ViewportSpace>. If not present, the size
to use is to be derived from the document including the SVG. In the case of
MediaWiki, this would be the thumbnails size, resp. the size given in the user
preferences for the size of images on image description pages. Also, the aspect
ratio defined by a viewBox attribute should be honoured, if present.

A patch that addresses there issues will follow in a minute.
Comment 1 Daniel Kinzler 2005-10-13 01:17:26 UTC
Created attachment 985 [details]
patch for Image.php for fixing size and aspect ratio of SVG images without width/height attributes.
Comment 2 Brion Vibber 2005-10-22 21:28:34 UTC
It looks like this would break if one but not both of $width and $height is 
specified. These lines are doing arithmetic against the strings:

+		if ( !$width ) $width = $height ? ( $height * $f ) : 2048; 
+		if ( !$height ) $height = $width / $f;

while the input values are only later normalized to pixel sizes.
Comment 3 Daniel Kinzler 2005-10-27 22:46:26 UTC
Created attachment 1026 [details]
updated patch

I hope I fixed all issues now.
Comment 4 Daniel Kinzler 2005-10-28 00:05:57 UTC
Created attachment 1027 [details]
fixed float behavior

gave it another go...
Comment 5 Brion Vibber 2005-10-28 01:35:04 UTC
SVG 1.1 spec says viewBox values are "separated by whitespace and/or a comma", but 
this seems to check whitespace only.

wfScaleSVGLength should probably just always return a float. If you want to check 
for unset stuff, set the false ahead and check for the false to remain after *not* 
setting the value different. There is for instance a running of wfScaleSVGLength() 
on false values added in this patch, which should just leave the prior code 
intact.

Better not to try looking for exact 0 values probably (especially if one's an int 
and one's a float so they won't match!)

+		$f = $w / $h;
There's no guard against a float divide-by-zero; this may produce a runtime 
warning. (The check for === 0 will fail if given a float 0.0.)

+       $width= round( $width );
bad spacing on these lines
Comment 6 Brion Vibber 2006-01-14 14:39:36 UTC
*** Bug 4609 has been marked as a duplicate of this bug. ***
Comment 7 Brion Vibber 2006-03-01 01:36:27 UTC
Removing bogus dependency; this was for interpretation of the file contents by 
MediaWiki.
Comment 8 Brion Vibber 2007-09-10 19:47:56 UTC
*** Bug 11163 has been marked as a duplicate of this bug. ***
Comment 9 Brion Vibber 2007-09-10 19:49:04 UTC
Just noting that the example in bug 11163 has width="100%" height="100%" and requires the same sorts of viewBox hacks, presumably.
Comment 10 Brion Vibber 2008-12-16 05:46:27 UTC
Added this w/ the new SVG size arch in r44651 / r44652.

Should also handle percentages on the width element reasonably, I hope. :)

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


Navigation
Links