0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 18:51:29 -05:00

🐛 Fixed problem with import SVG image size

This commit is contained in:
alonso.torres 2020-12-07 14:55:09 +01:00 committed by Alonso Torres
parent 4ef471919c
commit b80332b9b3
2 changed files with 15 additions and 14 deletions

View file

@ -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}]

View file

@ -41,6 +41,7 @@ RUN set -ex; \
python \
build-essential \
imagemagick \
librsvg2-bin \
netpbm \
potrace \
webp \