Saturday, April 25, 2015

Use imagemagick to apply a GIMP gradient colormap (.ggr file)

I love using JHelioviewer to create amazing videos of the Sun using pictures from SDO (the Solar Dynamics Observatory).

However, jHelioviewer has a maximum of 1000 frames -- which is about 3 or 4 hours of SDO images (if you use every image taken). Another problem is that is nearly impossible in jHelioviewer to crop the frame in an exact way.

I already knew how to create a movie from a sequence of images using ffmpeg. However, the AIA images you download from SDO JSOC are grayscale; i.e. they don't have the standard SDO color maps.

JHelioviewer applies the SDO color maps using these GIMP gradient files, but I didn't know how to use imagemagick to apply GIMP gradient color maps.

ImageMagick can apply color maps, but they must be in the form of a color lookup table (CLUT) image. But how does one convert a ggr file (a text file!) to a CLUT image? I found a lot of examples on the web on how to convert a CLUT to a GGR, but not the other way around.

According to this jHelioviewer wiki page, you can export the color tables from jHelioviewer using exportColorTables.java somehow, but I didn't feel like figuring out how to compile it -- and also I didn't want to install the JDK.

So I posted a question on the imagemagick forums. You can go read the forum if you like, but I've summarized it here:

  1. Create a standard hald clut image using the imagemagick program "convert" from the command line:
    1. convert hald:8 hald.png
  2. Install GIMP
    1. Install ggr files in your GIMP configuration directory (on Windows 7 this is %USERPROFILE%\.gimp-2.8\gradients)
  3. Start GIMP and open hald.png
  4. Select All
  5. In the Layers Dialog, select the Gradient Tool, then select the desired gradient
  6. Apply the gradient by selecting Colors -> Map -> Gradient Map
  7. Export the file by selecting File -> Export As ... (save it as a PNG or BMP)
The resulting hald CLUT images are here:

Now, to apply any of the above color maps to a grayscale image, you do, e.g.:

convert gray-image.jp2 sdo-aia-171-colormap.png -hald-clut color-output.jpg

Thursday, April 2, 2015

Symantec 12.1.5 on Linux LiveUpdate failures -- BouncyCastleProvider

TL;DR version: To fix this, temporarily remove the "noexec" mount option from /tmp and run the install.sh program again.

We recently started using Symantec 12.1.5 on our Linux systems at work. I installed the client on a test system and immediately had issues with LiveUpdate:

/opt/Symantec/symantec_antivirus/sav liveupdate -u
Picked up JAVA_TOOL_OPTIONS:
Command failed: Problem with LiveUpdate.
Check that java directory is in PATH
Unable to perform update

In liveupdt.log:

Apr 1, 2015 11:32:26 AM There was a failure in reading the settings from the .conf file.
Apr 1, 2015 11:32:26 AM org.bouncycastle.jce.provider.BouncyCastleProvider
Apr 1, 2015 11:32:26 AM JLU received a DeleteSetting command.

Running Liveupdate in debug mode:

java -cp /opt/Symantec/LiveUpdate/jlu.jar com.symantec.liveupdate.LiveUpdate -d
Using character set UTF-8
Command-line Product Selections to update:
(ProdName, Version, Lang, ItemSeqName, SeqNum)
Debug - output[nIdx] = uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_java_t:s0-s0:c0.c1023
Adding JLU to the current command line
JLU Linux, 3.10, English, LiveUpdateSeq, 26
Trying to load jar file from /opt/Symantec/LiveUpdate/bcprov-jdk15on-148.jar
Trying to load jar file from current directory or mentioned in classpath
JLUException [
Nested Exception is:
[ java.lang.ClassNotFoundException ] org.bouncycastle.jce.provider.BouncyCastleProvider

java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
at java.net.URLClassLoader.findClass(Unknown Source)
[...]

I will leave out the frustrating troubleshooting my coworker and I did and give you the reason: Our security configuration specifies that we set the "noexec" mount option on /tmp.

Unfortunately, the Symantec install script requires exec on /tmp to install correctly. Specifically, it creates some temporary scripts in /tmp and runs them to install the BC (bouncycastle) provider. Here's an excerpt from the sepjlu-install.log:


Java LiveUpdate version 3.10 Build 26.
Extracted out unixinstall.sh to /tmp/1427202521861/unixinstall.sh.
Extracted out unixuninstall.sh to /tmp/1427202521861/unixuninstall.sh.
Extracted out liveupdate.conf to /tmp/1427202521861/liveupdate.conf.
Extracted out bcprov-jdk15on-148.jar to /tmp/1427202521861/bcprov-jdk15on-148.jar.
Copied /opt/Symantec/LiveUpdate/jlu.jar to /tmp/1427202521861/jlu-3.10.0.26.jar.
Error running /tmp/1427202521861/unixinstall.sh with reason: java.io.IOException: Cannot run program "/tmp/1427202521861/unixinstall.sh": error=13, Permission denied.

The script is supposed to copy bcprov-jdk15on-148.jar into $SYMROOT/LiveUpdate/, but obviously because "noexec" was set on /tmp, it couldn't run.

So in full, the solution is:


mount -o remount,exec /tmp
$INSTALLER_DIR/install.sh -i
mount -o remount,noexec /tmp