Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Nextcloud 20 help with HEIC support via Imagick7

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
@nikinp You did successfully reinstall the ImageMagick6-nox11 package? You can check in the file /var/db/ports/graphics_ImageMagick6/options (yes, without "-nox11" this time) if you really enabled HEIC in the beginning. There should be a line reading OPTIONS_FILE_SET+=HEIF in there.
You can double check with convert -list format | grep HEIC.
 

nikinp

Member
Joined
Sep 7, 2014
Messages
85
@nikinp You did successfully reinstall the ImageMagick6-nox11 package? You can check in the file /var/db/ports/graphics_ImageMagick6/options (yes, without "-nox11" this time) if you really enabled HEIC in the beginning. There should be a line reading OPTIONS_FILE_SET+=HEIF in there.
You can double check with convert -list format | grep HEIC.
There is no such folder as /var/db/ports/graphics_ImageMagick6/ only /var/db/ports/graphics_ImageMagick6-nox11 and in that folder there is that line in the Options file. Also the double check gives:
HEIC* HEIC rw- Apple High efficiency Image Format (1.10.0)

Did I do something wrong since the folder seems to be different?
I used this code:

mkdir -p /usr/ports
svnlite co https://svn.freebsd.org/ports/head /usr/ports
cd /usr/ports/graphics/ImageMagick6-nox11
make config
# enable HEIF
make -DBATCH
make deinstall reinstall
pkg lock ImageMagick6-nox11
pkg autoremove
 

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Looks good. Did you restart your jail?
 

nikinp

Member
Joined
Sep 7, 2014
Messages
85
Yes and the whole freenas
 

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Please check if pecl-imagick is installed. pkg info | grep imagick
 

nikinp

Member
Joined
Sep 7, 2014
Messages
85
that command returns:
php74-pecl-imagick-3.4.4_2 PHP wrapper to the ImageMagick/GraphicsMagick library version 6
 

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Also good. So just possibly you would need ImageMagick7 for everything to work. I don't know, honestly. Anyone here who knows?
 

FloRho

Neophyte
Joined
Feb 2, 2021
Messages
4
Hi,
thank you for this discussion. Based in this I was able to enable HEIC/HEIF support in my NextCloud jail. However I come over some problems, therefore I decided to write a short tutorial about this topic. Hopefully this helps some people.

Greetings,
Florian
 

invar

Junior Member
Joined
Jan 23, 2021
Messages
14
Nice write-up but very different to my own method! Assuming you have NextCloud setup already and a pre-existing ImageMagick version working:

1) From jail console, download ImageMagick source somewhere. I like to be in a workspace located in /root/src

Code:
fetch https://download.imagemagick.org/ImageMagick/download/ImageMagick-7.0.11-1.tar.xz


2) extract source
Code:
tar xvfz ImageMagick-7.0.11-1.tar.xz


3)
Code:
cd ImageMagick-7.0.11-1

4) configure
Code:
./configure --with-heic --enable-hdri=no --with-quantum-depth=8


(Note I disable HDRI and use QD 8 for speed. Supposedly QD 16 is a 33% slowdown in image generation. These are thumbnails so I don't think quality is important. Throw in whatever other switches you want. ./configure --help for a full list)

5) compile
Code:
make

Or if you have a multithreaded processor (I have a Ryzen 5 1600 AF which has 12 threads):
Code:
make -j 12


6) If make spits back compile errors like it did on mine regarding not knowing how to make certain PC files, you have to copy the files that are missing and weren't generated for some reason, then continue compiling. This should work as a workaround.
Code:
cp MagickCore/MagickCore.pc MagickCore/MagickCore-7.Q8.pc
cp MagickCore/ImageMagick.pc MagickCore/ImageMagick-7.Q8.pc
cp MagickWand/MagickWand.pc MagickWand/MagickWand-7.Q8.pc
cp Magick++/lib/Magick++.pc Magick++/lib/Magick++-7.Q8.pc
make

Note that the correct destination filename to copy to depends on the configure options to choose earlier. If you picked QD 16, it will be Q16 instead. And if you enable HDRI it will have HDRI in the filename. Pay attention to the error you received to figure this out.

7)
Code:
make install

8) verify ImageMagick installed and correct formats are listed:
Code:
convert --version

HEIC should be listed now
9) Go back to your workspace and download the php imagick extension source:
Code:
fetch http://pecl.php.net/get/imagick-3.4.4.tgz

10) extract
Code:
tar xvfz imagick-3.4.4.tgz

11)
Code:
cd imagick-3.4.4

12) install autoconf which is needed for next step:
Code:
pkg install autoconf


13) prepare php extension source for compiling:
Code:
phpize

14) configure
Code:
./configure

15) compile
Code:
make


Or if you have a multithreaded processor (I have a Ryzen 5 1600 AF which has 12 threads):

Code:
make -j 12

16) install
Code:
make install

17) verify extension is properly installed and being utilized:
Code:
php --ri imagick |less

HEIC should be there now.

18) restart php-fpm
Code:
service php-fpm restart


Something important to remember: if you are using NextCloud as a plugin, upgrading/updating the plugin afterwards will likely completely mess up all your changes because the plugin reinstalls the premade packages. For this reason, I migrated my NextCloud install into a basejail only.
 
Last edited:

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Sorry, but why would you prefer to do a complete self compile without any support from the FreeBSD package system instead of using the FreeBSD port?
 

invar

Junior Member
Joined
Jan 23, 2021
Messages
14
I'm admittedly a novice for this type of stuff. Can you tell me what are the advantages of doing it the other way? In other words, what type of support do I get from it that I would actually need or use?

I did it the way I did because it's the method I'm familiar with in Linux and the flavor I started in the 90s was Slackware where *everything* was compiled by hand with no package manager or anything else.

After reading the write-up, I did try doing it the other way in a test jail, for the experience at least.
 

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Well, this is FreeBSD. So you can work with the system or against. The FreeBSD ports system is how the packages are built. So if you have the packages in your jail installed via pkg install and the standard configuration, you are getting the quarterly branch that gets updated quarterly (surprise!) and only gets security updates inbetween. Which is a reasonable policy in my book.

So pkg is similar to apt or apt-get. The downside is - and this is no different from Linux - that you get the features the package maintainers decide to include and nothing more.

The beauty of the FreeBSD system is that the packages in the official repository are built using the same ports system as you can do in your own jail. So if you recompile only one port/package with different features compared to the standard FreeBSD repository, on your local system the installed port is still registered as a package with the local package management. And if you pkg lock the software you installed via ports, you can still pkg upgrade your jail and the package system will do the right thing.

If you have a couple of systems which all need one or more packages with special options you can even build them automatically with a tool called "poudriere" which lets you build your own FreeBSD package repository with all the tweaks you need in your environment.

The general FreeBSD philosophy is "infrastructure, not product" - which is different from most Linux distributions. You can build your own install medium from source with a single command and you can build your own packages if you like.

HTH
Patrick
 

invar

Junior Member
Joined
Jan 23, 2021
Messages
14
Hmm very informative. So if I had stuck with the Nextcloud plugin originally and built IM7 via ports with the HEIC support I needed, then pkg locked it along with the imagick PHP extension, then plugin updates would not have rebroken HEIC?

Thanks so much for the primer.
 

Patrick M. Hausen

Dedicated Sage
Joined
Nov 25, 2013
Messages
2,768
Sorry, I don't know zilch about the plugin upgrades. I don't use plugins. Jails in FreeNAS/TrueNAS are essentially lightweight FreeBSD virtual machines or containers if you want to call them that. The plugins are based on jails and technically the same.

The major point to ponder is which upstream project you decide to depend on.

If you use the plugin you get updates whenever the plugin maintainer decides to update the plugin. And the plugin update might or might not work in the first place.
If you create a base jail, then install all the necessary packages yourself or e.g. with a script like the one by @danb35, then you can do a pkg upgrade just like you do with any Linux distro and apt-get upgrade or whatever. Definitely more frequently and up to date than the TrueNAS plugin.
And if even that is not current enough for you, you are of course free to compile your own, but you lose quite a bit of support and convenience.

I being familiar and very much at home with FreeBSD regularly opt for the second alternative. Create standard jails in TrueNAS, then do my own package management in there.
 

invar

Junior Member
Joined
Jan 23, 2021
Messages
14
I was a complete novice to FreeNAS and FreeBSD so the concept of the FreeNAS plugin was very appealing to me for ease of setup. I setup Emby, Plex and Nextcloud using the plugins literally within a few hours after my first install of FreeNAS so that was great.

Last week, I migrated over my NextCloud setup and destroyed all the plugins and went to basejails instead after reading about the shortcomings that you mentioned.

So basically the only advantages for my first post above (manual compile and install) are:

-looking for bleeding edge latest version of ImageMagick (I don't really care about this I guess)

-less drive space consumed because the ports source takes up space. (I'm assuming after a compile and install via ports the source can just be deleted anyway, right?)

Thanks so much for the education on all this so far. Wondering now if I should remove the stuff I did above by hand and do it the proper way via ports or just leave it. Decisions decisions!
 

invar

Junior Member
Joined
Jan 23, 2021
Messages
14
Ended up undoing all my own manual changes and proceeding with compiling using ports. Also recompiled imagick PHP extension since there was now a mismatch. Everything working great again.

Thanks again!
 

Cyrilik

Neophyte
Joined
Mar 6, 2021
Messages
9
Unfortunately the FreeBSD package of ImageMagick 7 is built without HEIF/HEIC support:

So you would need to install that one from ports. Log into your jail as root, then do:
Code:
mkdir -p /usr/ports
svnlite co https://svn.freebsd.org/ports/head /usr/ports
cd /usr/ports/graphics/ImageMagick7-nox11
make config
# enable HEIF
make -DBATCH
make deinstall reinstall
pkg lock ImageMagick7-nox11
pkg autoremove

Provided it is ImageMagick7-nox11 you installed for your Nextcloud installation. Adjust accordingly.
Pure magick! Greatly appreciated! Works like a charm...
 
Top