Images with embedded thumbnail whose orientation (rotation) is different than that of the main image render thumbnails wrong (smaller than they should be).
Originally reported at https://commons.wikimedia.org/wiki/Commons:Village_pump#Odd_stretched_thumbnails
Example affected file: File:Hellemani_torn_2011_(1).jpg (check the old version from 9 June 2012 for demonstration)
- A 337px thumbnail actually renders a 106x189px file: https://upload.wikimedia.org/wikipedia/commons/thumb/archive/4/45/20170803211025!Hellemani_torn_2011_(1).jpg/337px-Hellemani_torn_2011_(1).jpg
- Iit should be 337x600px, like this: https://upload.wikimedia.org/wikipedia/commons/thumb/4/45/Hellemani_torn_2011_(1).jpg/337px-Hellemani_torn_2011_(1).jpg
What I suspect happens is that we try to render e.g. a 337-pixel-wide thumbnail of the 1456×2592px original file, but at some point the dimensions are mixed up and we end up calculating the dimensions as if the file was 2592×1456px – so instead of a 337×600px thumbnail, we end up with a 337×189px thumbnail, and because aspect ratio is preserved, that in turn becomes 106×189px. This is probably a PHP or ImageMagick bug – I don't know where the issue is, but I can't reproduce it locally using PHP 7.1.5-1 and ImageMagick 6.8.9-9.
I was able to fix the original file by changing the thumbnail orientation to match the image:
… and to "break" the fixed file by changing the orientation not to match: