mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
upload_creator: force ImageMagick to use internal SVG code to determine size
This change largely targets dev users, but it could potentially change behaviour in production. Jamie Wilson & I debugged a problem where "should not be larger than the maximum thumbnail size" would fail due to timeouts. On our systems, on ImageMagick 7.1.0-2, with inkscape installed, IM would attempt to rasterise the svg then check the resulting filesize, causing the test to timeout. As of now, we haven't found a way to cause this to behave better, but have a workaround in that forcing IM to use the internal renderer (`MSVG:`) seems to make it perform the same on development workstations as it does in our docker container.
This commit is contained in:
parent
0dadd61d27
commit
784e929499
|
@ -127,10 +127,14 @@ class UploadCreator
|
|||
if @image_info.type.to_s == 'svg'
|
||||
w, h = [0, 0]
|
||||
|
||||
# identify can behave differently depending on how it's compiled and
|
||||
# what programs (e.g. inkscape) are installed on your system.
|
||||
# 'MSVG:' forces ImageMagick to use internal routines and behave
|
||||
# consistently whether it's running from our docker container or not
|
||||
begin
|
||||
w, h = Discourse::Utils
|
||||
.execute_command("identify", "-ping", "-format", "%w %h", @file.path, timeout: Upload::MAX_IDENTIFY_SECONDS)
|
||||
.split(' ')
|
||||
.execute_command("identify", "-ping", "-format", "%w %h", "MSVG:#{@file.path}", timeout: Upload::MAX_IDENTIFY_SECONDS)
|
||||
.split(' ').map(&:to_i)
|
||||
rescue
|
||||
# use default 0, 0
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user