使用图像转换分发ruby脚本 [英] Distributing ruby script with image conversion

查看:212
本文介绍了使用图像转换分发ruby脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分发一个Ruby脚本的Mac / Windows可执行文件(除了其他东西)将执行从/到常见图像格式到.xpm / X PixMap的转换(维基百科

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)

我知道以下宝石充当包装器预装的库(主要是ImageMagick):RMagick,Mini magick,Image science,Magickly,Devil,Im magick,Free-image等。

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.

问题归结为根据我的理解,以下内容:Imagemagick和Freeimage需要安装在系统上,而不仅仅是在脚本中以相对方式指向。并且Ruby2Exe,Ocra,Crate没有将库和我的脚本作为可执行文件分发的功能。

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.

有没有技术上的原因我还没有发现gem可以在不使用外部库的情况下执行此操作?
我的问题有哪些可能的解决方案?

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?

推荐答案

一种可能的解决方案:

找到一个免费的命令行实用程序,它可以执行您需要的转换。最好的是不需要任何特殊安装(只需将EXE文件放到硬盘驱动器上并运行它)。

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).

在Ruby程序中,调用使用反引号的命令行实用程序。如果它不在系统路径上,则可能必须将其作为 utility.exe 而不是实用程序调用。因此,无论当前工作目录如何,您都可以正确调用它,您可能必须使用绝对路径,使用 File.dirname(__ FILE __)和<$ c生成$ C> File.expand_path 。或者在尝试调用该实用程序之前更改工作目录。

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.

最后,您只需要将该实用程序与Ocra生成的Ruby EXE一起打包。

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

我建议这一切因为我知道尝试在Windows系统上安装RMagick会非常痛苦。

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

这篇关于使用图像转换分发ruby脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆