Magick with Images

Mr. Whitehouse gives us an introduction to a free software package for manipulating images—ImageMagick.
Programming with ImageMagick

While there are many packages available with some or all of the functions listed above, the real strength of ImageMagick lies in the ability to write programs using its library functions.

Included in the distribution is a simple program to demonstrate how to write your own image manipulation programs. It loads an image in JPEG format and creates a thumbnail in GIF format. I have changed the program slightly from its form in the distribution and presented it below. The thumbnail version will look something like the original image in Figure 1.

The C API to the ImageMagick library is documented through a set of web pages, which are also included in the distribution.

To compile the example code in Listing 1, you will need to give a command such as:

gcc -o example example.c -lMagick\
        -lX11 -lXext -ltiff -lpng\<\n>
        -I/usr/include/X11/magick -L/usr/X11/lib

The exact number of libraries required and the location of the libraries and include files will depend on the configuration of your system. The example given here works on my Red Hat 4.2 system installed from the RPM ImageMagick distribution.

To use the program, create a file called image.jpg and run the program in the same directory. The result will be a thumbnail-sized version of the original image called image.gif.

Using the included documentation, it is easy to see how this example can be extended and modified to form the basis of a wide variety of different functions. The same calls may also be made from Perl using the PerlMagick interface. Since I am not a Perl programmer, I have not investigated this interface.

Conclusions

ImageMagick is a complex package to use to its full potential; it is also very powerful. It offers a wealth of features in a flexible manner. It is easy to use the basic features without worrying about the more esoteric options available. I suspect that many people will use the basic options combined with only one or two of the more advanced options according to their application.

I consider ImageMagick a package well worth investigating for anyone needing anything from a basic image viewer to a full-fledged custom image manipulation system.

Pictures of Alan Cox are courtesy of Justin Mitchell and the ray-traced background image in Figure 1 was produced by David Beynon.

Image File Formats

Getting ImageMagick

Steve Whitehouse was first introduced to Linux, by the Computer Society at the University of Wales, Swansea, while studying for a degree in Electronic Engineering. Having gained his degree, he is now continuing his studies at Cambridge University by researching “Error Resilient Image Compression” and is sponsored by Racal Radio Ltd. If you want to contact him about the article or his research topic, his e-mail address is SteveW@ACM.org.

______________________

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions