See for example https://es.wikipedia.org/wiki/Usuario:Sophivorus/gallerybug
The issue happens whether you set the "heights" parameter or not (the "widths" parameter doesn't seem to work with packed galleries), and not only with mode=packed but also with "packed-overlay" and "packed-hover".
I think the reason is that some JavaScript is recalculating and changing the image sizes after they load, because when I refresh the page with "Inspect" open, I see that a "width" attribute is set after the page loads.