Question

I would like to distribute an executable for Mac/Windows of a Ruby script that (besides other things) will be doing a conversion from/to common image formats to .xpm / X PixMap (wikipedia)

I know about the following gems that act as a wrapper around pre-installed libraries (mostly ImageMagick): RMagick, Mini magick, Image science, Magickly, Devil, Im magick, Free-image, etc.

The problem boils down to, from what I understand, the following: Imagemagick and Freeimage need to be installed on the system, not just pointed in a relative way in the script. And Ruby2Exe, Ocra, Crate don't have the functionality to distribute the library and my script, as an executable.

Is there a technical reason why I haven't yet found a gem can perform this operation without the use of an external library? What are the possible solutions to my problem?

Was it helpful?

Solution

One possible solution:

Find a free command-line utility which can perform the conversions you need. The best would be one which doesn't require any special installation (just dropping an EXE file onto the hard drive and running it).

In your Ruby program, invoke the command-line utility using backticks. If it is not on the system path, you may have to invoke it as utility.exe rather than utility. And so that you can invoke it correctly, regardless of the current working directory, you may have to use an absolute path, generated using File.dirname(__FILE__) and File.expand_path. Or change the working directory before trying to invoke the utility.

Finally, you will just have to package that utility together with your Ocra-generated Ruby EXE.

I suggest all this because I know that trying to install RMagick on a Windows system can be incredibly painful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top