Skip to content

Commit

Permalink
Use ImageMagick properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
weetmuts committed Jan 20, 2024
1 parent 0c2888e commit 1955c28
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: sudo apt-get update
- run: sudo apt-get install pkg-config fuse libfuse-dev librsync-dev libexiv2-dev libavformat-dev graphicsmagick-libmagick-dev-compat
- run: sudo apt-get install pkg-config fuse libfuse-dev librsync-dev libexiv2-dev libavformat-dev libmagickcore-dev libmagick++-dev
- run: |
sudo modprobe fuse
sudo chmod 666 /dev/fuse
Expand Down
36 changes: 30 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4699,12 +4699,6 @@ fi
printf "%s\n" "found" >&6; }
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libmagick++-dev" >&5
printf %s "checking for libmagick++-dev... " >&6; }

MEDIA_CFLAGS="${MEDIA_CFLAGS} $(Magick++-config --cppflags)"
MEDIA_LIBS="${MEDIA_LIBS} $(Magick++-config --libs)"

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libavformat" >&5
printf %s "checking for libavformat... " >&6; }

Expand All @@ -4721,6 +4715,36 @@ fi
printf "%s\n" "found" >&6; }
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Imagemagick MagickCore" >&5
printf %s "checking for Imagemagick MagickCore... " >&6; }
if $PKG_CONFIG MagickCore --cflags > /dev/null 2>&1
then
MAGICKCORE_CFLAGS="$($PKG_CONFIG MagickCore --cflags)"
MAGICKCORE_LIBS="$($PKG_CONFIG MagickCore --libs)"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
printf "%s\n" "found" >&6; }
else
as_fn_error $? "Could not find MagickCore!" "$LINENO" 5
fi

MEDIA_CFLAGS="${MEDIA_CFLAGS} ${MAGICKCORE_CFLAGS}"
MEDIA_LIBS="${MEDIA_LIBS} ${MAGICKCORE_LIBS}"

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Imagemagick Magick++" >&5
printf %s "checking for Imagemagick Magick++... " >&6; }
if $PKG_CONFIG Magick++ --cflags > /dev/null 2>&1
then
MAGICKPP_CFLAGS="$($PKG_CONFIG Magick++ --cflags)"
MAGICKPP_LIBS="$($PKG_CONFIG Magick++ --libs)"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5
printf "%s\n" "found" >&6; }
else
as_fn_error $? "Could not find Magick++!" "$LINENO" 5
fi

MEDIA_CFLAGS="${MEDIA_CFLAGS} ${MAGICKPP_CFLAGS}"
MEDIA_LIBS="${MEDIA_LIBS} ${MAGICKPP_LIBS}"

else
echo "media disabled"
fi
Expand Down
33 changes: 27 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017-2023 Fredrik Öhrström
# Copyright (C) 2017-2024 Fredrik Öhrström
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -269,11 +269,6 @@ if test "${ENABLE_MEDIA}" = "yes"; then
AC_MSG_RESULT([found])
fi

AC_MSG_CHECKING([for libmagick++-dev])

MEDIA_CFLAGS="${MEDIA_CFLAGS} $(Magick++-config --cppflags)"
MEDIA_LIBS="${MEDIA_LIBS} $(Magick++-config --libs)"

AC_MSG_CHECKING([for libavformat])
AC_ARG_WITH(libavformat, [AS_HELP_STRING([--with-libavformat],
[specify prefix directory for the libavformat package
Expand All @@ -284,6 +279,32 @@ if test "${ENABLE_MEDIA}" = "yes"; then
AC_MSG_RESULT([found])
fi

AC_MSG_CHECKING([for Imagemagick MagickCore])
if $PKG_CONFIG MagickCore --cflags > /dev/null 2>&1
then
MAGICKCORE_CFLAGS="$($PKG_CONFIG MagickCore --cflags)"
MAGICKCORE_LIBS="$($PKG_CONFIG MagickCore --libs)"
AC_MSG_RESULT([found])
else
AC_MSG_ERROR([Could not find MagickCore!])
fi

MEDIA_CFLAGS="${MEDIA_CFLAGS} ${MAGICKCORE_CFLAGS}"
MEDIA_LIBS="${MEDIA_LIBS} ${MAGICKCORE_LIBS}"

AC_MSG_CHECKING([for Imagemagick Magick++])
if $PKG_CONFIG Magick++ --cflags > /dev/null 2>&1
then
MAGICKPP_CFLAGS="$($PKG_CONFIG Magick++ --cflags)"
MAGICKPP_LIBS="$($PKG_CONFIG Magick++ --libs)"
AC_MSG_RESULT([found])
else
AC_MSG_ERROR([Could not find Magick++!])
fi

MEDIA_CFLAGS="${MEDIA_CFLAGS} ${MAGICKPP_CFLAGS}"
MEDIA_LIBS="${MEDIA_LIBS} ${MAGICKPP_LIBS}"

else
echo "media disabled"
fi
Expand Down
1 change: 1 addition & 0 deletions src/beak_importmedia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

// This must be before log.h since it declares a debug macro.
#include <assert.h>
#include <Magick++.h>

#include "beak.h"
Expand Down
3 changes: 2 additions & 1 deletion src/beak_indexmedia.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2020-2021 Fredrik Öhrström
Copyright (C) 2020-2023 Fredrik Öhrström
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <assert.h>
#include <Magick++.h>

#include "beak.h"
Expand Down
1 change: 1 addition & 0 deletions src/beak_servemedia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <assert.h>
#include <Magick++.h>

#include "beak.h"
Expand Down
3 changes: 3 additions & 0 deletions src/media.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <assert.h>
#include <Magick++.h>
#include <magick/MagickCore.h>

#include "beak.h"
#include "beak_implementation.h"
Expand Down Expand Up @@ -967,6 +969,7 @@ RC MediaDatabase::generateThumbnail(Media *m, Path *root)
{
verbose(MEDIA, "Caught warning: %s\n", w.what());
}
//MagickCore::GetImagePerceptualHash(image, sdf);
// Resize the image to specified size (width, height, xOffset, yOffset)
// Keep aspect ratio.
string s = image.attribute("EXIF:Orientation");
Expand Down

0 comments on commit 1955c28

Please sign in to comment.