How to remove ImageMagick without breaking its dependencies?
I want to remove the pre-installed ImageMagick from my Ubuntu 16.04 LTS. Uninstalling it also removes CUPS and other dependent packages which I want to keep on my system.
Is there a way to remove only ImageMagick without harming its dependencies or without having to reinstall them after their auto-removal?
Solution 1:
ImageMagick is a suite of command line tools and libraries for working with images and packages that depend on it or uses parts of it to function.
Cups uses it for its filters and while it's possible that you don't use any filters that use ImageMagick, I'd recommend that you keep it, because removing it may break Cups.
Now, if you still want to remove it, you can do it like this:
$ sudo dpkg --purge --force-all imagemagick
Note: This will very likely break your system so don't do it!
Solution 2:
Some functionality of the dependent packages depend on ImageMagick by definition. This means that the dependent packages (cups etc.) have been built in a way that they require (depend on) ImageMagick to complete certain operations.
So, without a working ImageMagick, cups built by Ubuntu will not work as intended. To make sure all the installed packages work as intended, apt, dpkg and other system tools make sure the packages with unsatisfied dependencies will be deleted from the system.
If you still are certain you don't need ImageMagick on your system, you will have to compile cups and other dependent packages again without linking them against or making them otherwise dependent on ImageMagick. That may or may not be possible using parameters to compilation configuration script (usually invoked by ./configure command). In Ubuntu, maintaining self-built packages is usually not recommended or made particularly easy (you will have to compile the applications again manually to update them, and make sure the applications' dependant packages are compiled again, too).
The practical solutions are using a distribution where self-building applications and handling dependencies across them is meant to be easier for the end-user (Gentoo, Arch, etc.), and alternatively keep using Ubuntu without deleting ImageMagick.