I am pretty sure that I had rebased on master well before I ran that import. Reading the code, the bug is in embedded_image_html
which doesn’t preserve aspect ratio:
def embedded_image_html(upload)
image_width = [upload.width, SiteSetting.max_image_width].compact.min
image_height = [upload.height, SiteSetting.max_image_height].compact.min
upload_name = upload.short_url || upload.url
%Q~![#{upload.original_filename}|#{image_width}x#{image_height}](#{upload_name})~
end
There’s not any multiplication or “square rootification” in there anywhere. About 20 years ago, my quick hack shell script to create indexes of images did this:
eval $(identify -format 'OLDWIDTH=%w;OLDHEIGHT=%h' $file)
NEWWIDTH=$(echo "sqrt(($AREA*$OLDWIDTH)/$OLDHEIGHT)" | bc)
NEWHEIGHT=$(echo "sqrt(($AREA*$OLDHEIGHT)/$OLDWIDTH)" | bc)
THIS_GEO="${NEWWIDTH}x${NEWHEIGHT}>"
That formula is a few millennia old, so I don’t claim any credit, and similar logic could keep aspect ratio while honoring the most restrictive constraint.