Add MediaMetadata model.

Add a model for storing image and video metadata for uploaded files.

Metadata is extracted using ExifTool. You will need to install ExifTool
after this commit. ExifTool 12.22 is the minimum required version
because we use the `--binary` option, which was added in this release.

The MediaMetadata model is separate from the MediaAsset model because
some files contain tons of metadata, and most of it is non-essential.
The MediaAsset model represents an uploaded file and contains essential
metadata, like the file's size and type, while the MediaMetadata model
represents all the other non-essential metadata associated with a file.

Metadata is stored as a JSON column in the database.

ExifTool returns all the file's metadata, not just the EXIF metadata.
EXIF is one of several types of image metadata, hence why we call
it MediaMetadata instead of EXIFMetadata.
This commit is contained in:
evazion
2021-09-07 18:22:34 -05:00
parent 291758ddb7
commit 3d660953d4
20 changed files with 235 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ ARG RUBY_VERSION=2.7.1
ARG NODE_VERSION=14.15.5
ARG VIPS_VERSION=8.10.6
ARG FFMPEG_VERSION=4.3.2
ARG EXIFTOOL_VERSION=12.30

View File

@@ -5,6 +5,7 @@ set -xeuo pipefail
RUBY_VERSION="${RUBY_VERSION:-2.7.1}"
VIPS_VERSION="${VIPS_VERSION:-8.10.6}"
FFMPEG_VERSION="${FFMPEG_VERSION:-4.3.2}"
EXIFTOOL_VERSION="${EXIFTOOL_VERSION:-12.30}"
COMMON_BUILD_DEPS="
curl ca-certificates build-essential pkg-config git
@@ -59,6 +60,17 @@ install_ffmpeg() {
ffprobe -version
}
install_exiftool() {
EXIFTOOL_URL="https://github.com/exiftool/exiftool/archive/refs/tags/${EXIFTOOL_VERSION}.tar.gz"
curl -L "$EXIFTOOL_URL" | tar -C /usr/local/src -xzvf -
cd /usr/local/src/exiftool-${EXIFTOOL_VERSION}
perl Makefile.PL
make -j "$(nproc)" install
exiftool -ver
}
install_ruby() {
apt_install $RUBY_BUILD_DEPS
@@ -73,7 +85,7 @@ cleanup() {
apt-get purge -y $RUBY_BUILD_DEPS $VIPS_BUILD_DEPS $FFMPEG_BUILD_DEPS
apt-get purge -y --allow-remove-essential \
build-essential pkg-config e2fsprogs git libglib2.0-bin libglib2.0-doc \
mount perl-modules-5.30 procps python3 readline-common shared-mime-info tzdata
mount procps python3 readline-common shared-mime-info tzdata
apt-get autoremove -y
rm -rf \
@@ -91,6 +103,7 @@ cleanup() {
apt-get update
apt_install $COMMON_BUILD_DEPS $DANBOORU_RUNTIME_DEPS
install_asdf
install_exiftool
install_ffmpeg
install_vips
install_ruby