Some ImageMagick tricks

I have a few short ImageMagick notes typed up on my website, in case they are useful to anyone. The command-line interface is not easy to remember, so I make a lot of notes, but ImageMagick has a lot of tools that allows you to do nice things with images for presentations and videos.

Using Image Magick for batch jobs.

Creating a watermark with ImageMagick.

ImageMagick has a C++ API.


ImageMagick is cool !! Is it light-speed ?

And your dog too :slight_smile:

1 Like

ImageMagick is very cool. It is about as fast as the things I write in OpenCV (C++), if I single-thread versus run them multi-threaded. I was doing some of the ImageMagick things with programs I wrote in OpenCV, now I just use ImageMagick in batch mode.

Usually, I’ll do the resize, and then apply the watermarks, so I am working with the smallest possible image size for each step.

At this point, the dog has accepted her role as a photography practice model and she is very good at posing. There are treats involved :grinning: .


Funny fact that arxiv-sanity uses ImageMagick to create the thumbnails.

See: arxiv-sanity-preserver/ at discuss · karpathy/arxiv-sanity-preserver · GitHub

1 Like

Thanks. Wow, arxiv-sanity is held together with system calls? Today’s conversation is now taking on a whole new context. And wish I had a lot of time, this could be fun (I don’t have a lot of time …).

I did look it up, and there is a Python version, PythonMagick. The documentation is non-existent, not a good sign. It is likely that Pillow, OpenCV, most anything else could do similar things with some more coding. (I hate resorting to command line calls)

right ! PythonMagick seems to be a total mistery :slight_smile:

However, in this discussion I found that apparently it’s just a wrapper around Magick++.

A snippet for the Python API:

 import PythonMagick as Magick
    img = Magick.Image("testIn.jpg")
    img.quality(100) #full compression

I couldn’t find any hello world example for the C++ API :frowning:

1 Like

Here’s sort of one,

#include <Magick++.h> 
#include <iostream> 

using namespace std; 
using namespace Magick; 

int main(int argc,char **argv) 

  // Construct the image object. Seperating image construction from the 
  // the read operation ensures that a failure to read the image file 
  // doesn't render the image object useless. 
  Image image;
  try { 
    // Read a file into image object "logo:" );

    // Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );

    // Write the image to a file 
    image.write( "logo.png" ); 
  catch( Exception &error_ ) 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
  return 0; 

from the Magick++ API page.

Back to the arxiv-sanity topic — even though this file from arxiv-sanity is a little ugly, does anyone know why it is failing? It could be something really strange, server config, server hardware failing, etc. It worked for a long time, and now isn’t – it seems.

1 Like

No idea from my side. Probably it’s worth to open an issue there and offer help ?

Sure. I saw a lot of open issues at the GH project, so Andrej may not be responding to it. Since he’s so busy, it might be worthwhile to discuss what we’re planning / willing to offer ahead of time so he can say yes/no/ or “I’ll take 1 but not 2”.

  • work on our own fork?
  • host a version? (I know nothing about this, btw)
  • something else?


I suggest to open a separate thread for this discussion :slight_smile:

I vote for #2 in advance

Next question, where to put it?? Community?

I have some things to finish up, lunch, and a meeting, but will open a thread in my afternoon.

yep, that’s a good place to start.