mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
add corner intensities and mime type hooks
This commit is contained in:
parent
e343cf9ee0
commit
91187d24f1
3 changed files with 50 additions and 1 deletions
23
lib/philomena/intensities.ex
Normal file
23
lib/philomena/intensities.ex
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
defmodule Philomena.Intensities do
|
||||||
|
@doc """
|
||||||
|
Gets the corner intensities of the given image file.
|
||||||
|
The image file must be in the PNG or JPEG format.
|
||||||
|
"""
|
||||||
|
@spec file(String.t()) :: {:ok, map()} | :error
|
||||||
|
def file(input) do
|
||||||
|
System.cmd("image-intensities", [input])
|
||||||
|
|> case do
|
||||||
|
{output, 0} ->
|
||||||
|
[nw, ne, sw, se] =
|
||||||
|
output
|
||||||
|
|> String.trim()
|
||||||
|
|> String.split("\t")
|
||||||
|
|> Enum.map(&String.to_float/1)
|
||||||
|
|
||||||
|
{:ok, %{nw: nw, ne: ne, sw: sw, se: se}}
|
||||||
|
|
||||||
|
_error ->
|
||||||
|
:error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/philomena/mime.ex
Normal file
16
lib/philomena/mime.ex
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
defmodule Philomena.Mime do
|
||||||
|
@doc """
|
||||||
|
Gets the MIME type of the given pathname.
|
||||||
|
"""
|
||||||
|
@spec file(String.t()) :: {:ok, binary()} | :error
|
||||||
|
def file(path) do
|
||||||
|
System.cmd("file", ["-b", "--mime-type", path])
|
||||||
|
|> case do
|
||||||
|
{output, 0} ->
|
||||||
|
{:ok, String.trim(output)}
|
||||||
|
|
||||||
|
_error ->
|
||||||
|
:error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -54,11 +54,21 @@ apt-get update
|
||||||
if ! install_packages build-essential postgresql-11 libpq-dev nginx nodejs \
|
if ! install_packages build-essential postgresql-11 libpq-dev nginx nodejs \
|
||||||
elasticsearch esl-erlang elixir inotify-tools git \
|
elasticsearch esl-erlang elixir inotify-tools git \
|
||||||
redis-server automake libtool zlib1g-dev ffmpeg \
|
redis-server automake libtool zlib1g-dev ffmpeg \
|
||||||
libavutil-dev libavcodec-dev libavformat-dev ; then
|
libavutil-dev libavcodec-dev libavformat-dev \
|
||||||
|
libmagic-dev libpng-dev; then
|
||||||
>&2 echo "Installation of dependencies failed."
|
>&2 echo "Installation of dependencies failed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /usr/local/bin/image-intensities ]; then
|
||||||
|
pushd .
|
||||||
|
cd /tmp
|
||||||
|
git clone https://github.com/derpibooru/cli_intensities
|
||||||
|
cd cli_intensities
|
||||||
|
make install
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i -e 's/\(-Xm[sx]\)1g/\1256m/' /etc/elasticsearch/jvm.options
|
sed -i -e 's/\(-Xm[sx]\)1g/\1256m/' /etc/elasticsearch/jvm.options
|
||||||
systemctl enable elasticsearch 2>/dev/null
|
systemctl enable elasticsearch 2>/dev/null
|
||||||
service elasticsearch start
|
service elasticsearch start
|
||||||
|
|
Loading…
Reference in a new issue