mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:14:44 +08:00
FIX - use ImageMagick to determine size of svg images (#12230)
SVG files can have dimensions expressed in inches, centimeters, etc., which may lead to the dimensions being misinterpreted (e.g. “8in” ends up as 8 pixels). If the file type is `svg`, ask ImageMagick to work out what size the SVG file should be rendered on screen. NOTE: The `pencil.svg` file was obtained from https://freesvg.org/1534028868, which has placed the file in to the public domain.
This commit is contained in:
@ -535,6 +535,20 @@ RSpec.describe UploadCreator do
|
||||
end
|
||||
end
|
||||
|
||||
describe "svg sizing" do
|
||||
let(:svg_filename) { "pencil.svg" }
|
||||
let(:svg_file) { file_from_fixtures(svg_filename) }
|
||||
|
||||
it "should handle units in width and height" do
|
||||
upload = UploadCreator.new(svg_file, svg_filename,
|
||||
force_optimize: true,
|
||||
).create_for(user.id)
|
||||
|
||||
expect(upload.width).to be > 100
|
||||
expect(upload.height).to be > 100
|
||||
end
|
||||
end
|
||||
|
||||
describe '#should_downsize?' do
|
||||
context "GIF image" do
|
||||
let(:gif_file) { file_from_fixtures("animated.gif") }
|
||||
|
Reference in New Issue
Block a user