Last modified: Wed Nov 23 08:11:46 MST 2005

Porting StirMark to UNIX

StirMark is a program developed by watermarking researchers, most notably Fabien Petitcolas. It is used to alter images in ways which are not objectionable to most users, but may cause some watermark detectors to fail to find embedded watermarks.

The source code for this program, and Windows executables, are provided at the StirMark site. The following text outlines a procedure which was used to port this code to LINUX. The code is very standard, and I have every reason to believe that this procedure will work for any UN*X-like system with GNU make.

Download Source

Get the source distribution from the StirMark WWW site. My LINUX system has a program called unzip which will extract files from the provided PK-Zip archive. If you have, or can get this program on your UNIX use it. If not, you may wish to unpack the source on a Windows machine, then FTP the source files back to UNIX in ASCII transfer mode. If you take the later route, you will be able to skip the ASCII mode translation steps which follow.

Build JPEG Library

If you already have a version of libjpeg.a from the JPEG group on your system, feel free to try it. I think it is highly likely to work. This code is fairly mature and stable.

If you are using your own library, simply add

to the linker commands in the following StirMark make file. If you wish to build the JPEG source delivered with StirMark, read the rest of this section.

Go to the directory holding the JPEG library source.

  1. Get rid of the leading space before /bin/sh in the configure script. It caused problems for me. This may not be necessary, but I did it. Then make this script executable:
          chmod +x configure
    You may be able to avoid this simply by using
    sh configure
    instead of
    I did not start all over to see if the easier sh configure method would work. Converting configure to an executable script worked for me.
  2. If you expanded the zip archive on UNIX, you will need to convert Windows-style ASCII to the UNIX standard. For me it was sufficient to convert all *.c, *.h and the configure file. I'm sure there are many standard filters to do that, but I couldn't find one. I wrote a simple perl script called pc2unix to do this. Given this script, the following csh commands can be issued to convert the base source code:
           foreach f ( `ls *.c *.h` )
              cat $f | pc2unix > t
              \rm -f $f
              mv t $f
  3. type make
  4. If you want to run the test, get rid of the extra \r from the first lines of testing.ppm. I simply used emacs. But you will need a fairly professional editor to give you the ability to remove these non-printing characters without altering any other bytes in the binary file. Let me know if vi can handle operations like this.

    After fixing this file for UNIX, type make test.

  5. Install the library if you really want to. I did not. The following instructions will link this library in directly from the JPEG build directory.

Build StirMark

If you have not already converted all *.h and *.c files to UN*X-standard ASCII, please do so following the procedure outlined above for creating the JPEG library.

Next, create a file called Makefile with the following contents:

OBJ=bench.o image.o quality.o reconstructers.o stirmark.o\
        error.o lrattack.o quantise.o resamplers.o transformations.o

StirMark:       $(OBJ)
        cc -L../JPEGLib -o StirMark $(OBJ) -ljpeg -lm
Note that lines must be indented with TAB's and not spaces.

If you are using your existing libjpeg.a, replace the -L../JPEGLib element above with the directory containing you jpeg library file.

If you have GNU make, this file should be sufficient. If you do not have GNU make, you may need to add rules to create the object files form the source.

Typing make will then create an executable called StirMark, and you are done. The StirMark executable can be moved to a position of your choosing, and should need no support files.

Aaron Birenboim