@ -18,7 +18,8 @@
#:slugify
#:get-image-dimensions
#:run-bash-command
#:create-thumbnail )
#:create-thumbnail
#:create-timestamp-id )
( :documentation "Utilities that do not depend on models." ) )
( in-package #:utils )
@ -102,7 +103,7 @@ The `FILEPATH' must be already merged with
:ignore-error-status t
:error-output :string ) )
( defun create-thumbnail ( file-name )
( defun create-thumbnail ( storage-sub-directory file-name )
" Runs a Bash command to convert a file to a thumbnail in /storage/media dir.
The file is reduced to 512x512 pixels if bigger than that. A new file
is then created with a 'thumbnail- ' pre-fix. This process relies on
@ -110,5 +111,13 @@ Image Magick. So, it must be installed on the system for this function
to operate properly. "
( run-bash-command
( format nil "convert ~a -resize 512x512\\> ~a"
( storage:file-exists-p "" "media" file-name )
( storage:make-path "" "media" ( format nil "thumbnail-~a" file-name ) ) ) ) )
( storage:file-exists-p "" storage-sub-directory file-name )
( storage:make-path "" storage-sub-directory
( format nil "thumbnail-~a" file-name ) ) ) ) )
( defun create-timestamp-id ( )
"Creates a integer based on time the function is called, in YYYYMMDD format."
( multiple-value-bind
( second minute hour day month year )
( get-decoded-time )
( format nil "~d~2,'0d~d~2,'0d~2,'0d~2,'0d" year month day hour minute second ) ) )