mirror of
https://github.com/penpot/penpot.git
synced 2025-07-18 08:27:18 +02:00
🐛 Fixed problem with import SVG image size
This commit is contained in:
parent
4ef471919c
commit
b80332b9b3
2 changed files with 15 additions and 14 deletions
|
@ -119,20 +119,20 @@
|
|||
[{:keys [input] :as params}]
|
||||
(us/assert ::input input)
|
||||
(let [{:keys [path mtype]} input]
|
||||
(if (= mtype "image/svg+xml")
|
||||
{:width 100
|
||||
:height 100
|
||||
:mtype mtype}
|
||||
(let [instance (Info. (str path))
|
||||
mtype' (.getProperty instance "Mime type")]
|
||||
(when (and (string? mtype)
|
||||
(not= mtype mtype'))
|
||||
(ex/raise :type :validation
|
||||
:code :media-type-mismatch
|
||||
:hint "Seems like you are uploading a file whose content does not match the extension."))
|
||||
{:width (.getImageWidth instance)
|
||||
:height (.getImageHeight instance)
|
||||
:mtype mtype'}))))
|
||||
(let [instance (Info. (str path))
|
||||
|
||||
;; SVG files are converted to PNG to extract their properties
|
||||
mtype (if (= mtype "image/svg+xml") "image/png" mtype)
|
||||
mtype' (.getProperty instance "Mime type")]
|
||||
(when (and (string? mtype)
|
||||
(not= mtype mtype'))
|
||||
(ex/raise :type :validation
|
||||
:code :media-type-mismatch
|
||||
:hint (str "Seems like you are uploading a file whose content does not match the extension."
|
||||
"Expected: " mtype "Got: " mtype')))
|
||||
{:width (.getImageWidth instance)
|
||||
:height (.getImageHeight instance)
|
||||
:mtype mtype'})))
|
||||
|
||||
(defmethod process :default
|
||||
[{:keys [cmd] :as params}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue