mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
✨ Start use jpeg instead of webp for thumbnails.
Because Safari still does not supports WEBP :(
This commit is contained in:
parent
c6581a91e4
commit
e0a567551f
3 changed files with 14 additions and 20 deletions
|
@ -2,7 +2,10 @@
|
|||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2016-2017 Andrey Antukh <niwi@niwi.nz>
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns uxbox.images
|
||||
"Image postprocessing."
|
||||
|
@ -62,18 +65,10 @@
|
|||
tmp (fs/create-tempfile :suffix ext)
|
||||
opr (doto (IMOperation.)
|
||||
(.addImage)
|
||||
|
||||
(.autoOrient)
|
||||
(.strip)
|
||||
(.thumbnail (int width) (int height) ">")
|
||||
(.quality (double quality))
|
||||
|
||||
;; (.autoOrient)
|
||||
;; (.strip)
|
||||
;; (.thumbnail (int width) (int height) "^")
|
||||
;; (.gravity "center")
|
||||
;; (.extent (int width) (int height))
|
||||
;; (.quality (double quality))
|
||||
(.addImage))]
|
||||
(doto (ConvertCmd.)
|
||||
(.run opr (into-array (map str [input tmp]))))
|
||||
|
@ -81,7 +76,7 @@
|
|||
(fs/delete tmp)
|
||||
(ByteArrayInputStream. thumbnail-data)))))
|
||||
|
||||
(defn generate-thumbnail2
|
||||
(defn generate-profile-thumbnail
|
||||
([input] (generate-thumbnail input nil))
|
||||
([input {:keys [quality format width height]
|
||||
:or {format "jpeg"
|
||||
|
|
|
@ -5,23 +5,22 @@
|
|||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns uxbox.services.mutations.images
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[datoteka.core :as fs]
|
||||
[promesa.core :as p]
|
||||
[uxbox.common.exceptions :as ex]
|
||||
[uxbox.common.spec :as us]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.config :as cfg]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.media :as media]
|
||||
[uxbox.images :as images]
|
||||
[uxbox.tasks :as tasks]
|
||||
[uxbox.services.queries.teams :as teams]
|
||||
[uxbox.media :as media]
|
||||
[uxbox.services.mutations :as sm]
|
||||
[uxbox.common.uuid :as uuid]
|
||||
[uxbox.services.queries.teams :as teams]
|
||||
[uxbox.tasks :as tasks]
|
||||
[uxbox.util.storage :as ust]
|
||||
[uxbox.util.time :as dt]))
|
||||
|
||||
|
@ -29,7 +28,7 @@
|
|||
{:width 800
|
||||
:height 800
|
||||
:quality 85
|
||||
:format "webp"})
|
||||
:format "jpeg"})
|
||||
|
||||
(s/def ::id ::us/uuid)
|
||||
(s/def ::name ::us/string)
|
||||
|
|
|
@ -294,12 +294,12 @@
|
|||
thumb-opts {:width 256
|
||||
:height 256
|
||||
:quality 75
|
||||
:format "webp"}
|
||||
:format "jpeg"}
|
||||
prefix (-> (sodi.prng/random-bytes 8)
|
||||
(sodi.util/bytes->b64s))
|
||||
name (str prefix ".webp")
|
||||
name (str prefix ".jpg")
|
||||
path (fs/path (:tempfile file))
|
||||
photo (images/generate-thumbnail2 path thumb-opts)]
|
||||
photo (images/generate-profile-thumbnail path thumb-opts)]
|
||||
(ust/save! media/media-storage name photo)))
|
||||
|
||||
(defn- update-profile-photo
|
||||
|
|
Loading…
Add table
Reference in a new issue