- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
当我在 rails 的 lib 文件夹中运行命令 ruby billede.rb 时,出现错误:
C:\Rails\myapp\lib>ruby billede.rb
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
no such file to load -- RMagick (LoadError)
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n `require'
from billede.rb:2:in `<main>'
我的 Billede.rb:
class Billede
require 'rubygems'
require 'RMagick'
if !ARGV[0]
puts "Usage: watermark /image.png"
exit
end
image = Magick::Image.read(ARGV[0]).first
mark = Magick::Image.new(image.columns, image.rows)
gc = Magick::Draw.new
gc.gravity = Magick::CenterGravity
gc.pointsize = 32
gc.font_family = "Helvetica"
gc.font_weight = Magick::BoldWeight
gc.stroke = 'none'
gc.annotate(mark, 0, 0, 0, 0, "Watermark\nby\nRMagick")
mark = mark.shade(true, 310, 30)
image.composite!(mark, Magick::CenterGravity, Magick::HardLightCompositeOp)
out = ARGV[0].sub(/\./, "-wm.")
puts "Writing #{out}"
image.write(out)
end
我已经安装了 RMagick。
安装 gem 时更新。
在我的 gemfile 中我有:
gem "rmagick", :require => 'RMagick'
运行捆绑安装时:
C:\Rails\myapp>bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.1)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.4)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.30)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using addressable (2.2.6)
Using bundler (1.0.18)
Using multipart-post (1.1.4)
Using faraday (0.7.6)
Using friendly_id (4.0.0)
Using hashie (1.2.0)
Using json (1.6.1)
Using multi_json (1.0.4)
Using mysql (2.8.1)
Using oauth2 (0.5.2)
Using omniauth (1.0.2)
Using omniauth-oauth2 (1.0.0)
Using omniauth-facebook (1.2.0)
Using rdoc (3.10)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using rest-client (1.6.7)
Installing rmagick (2.13.1) with native extensions C:/Ruby192/lib/ruby/site_ruby
/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR
: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
C:/Ruby192/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... yes
checking for snprintf() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdin
t.h,sys/types.h,wand/MagickWand.h... yes
checking for AcquireImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,s
tdint.h,sys/types.h,wand/MagickWand.h... yes
checking for AffinityImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,
stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for AffinityImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h
,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for AutoGammaImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for AutoLevelImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for BlueShiftImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h
,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for ConstituteComponentTerminus() in assert.h,ctype.h,stdio.h,stdlib.h,
math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for DeskewImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,st
dint.h,sys/types.h,wand/MagickWand.h... yes
checking for EncipherImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,
stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for EqualizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for FloodfillPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for FunctionImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for GetAuthenticIndexQueue() in assert.h,ctype.h,stdio.h,stdlib.h,math.
h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for GetAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,ti
me.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for GetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for GetVirtualPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for LevelImageColors() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for LevelColorsImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math
.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for LevelizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for LiquidRescaleImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,ti
me.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for MagickLibAddendum() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,tim
e.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for OpaquePaintImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math
.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for QueueAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for RemapImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,std
int.h,sys/types.h,wand/MagickWand.h... yes
checking for RemoveImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SelectiveBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,ma
th.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,
time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SetImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SetMagickMemoryMethods() in assert.h,ctype.h,stdio.h,stdlib.h,math.
h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SparseColorImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time
.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for SyncAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,t
ime.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for TransparentPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h
,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for TransparentPaintImageChroma() in assert.h,ctype.h,stdio.h,stdlib.h,
math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for QueryMagickColorname() new signature... yes
checking for Image.type in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdin
t.h,sys/types.h,wand/MagickWand.h... yes
checking for DrawInfo.kerning in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h
,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for DrawInfo.interline_spacing in assert.h,ctype.h,stdio.h,stdlib.h,mat
h.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for DrawInfo.interword_spacing in assert.h,ctype.h,stdio.h,stdlib.h,mat
h.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for DitherMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,std
int.h,sys/types.h,wand/MagickWand.h... yes
checking for MagickFunction in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,s
tdint.h,sys/types.h,wand/MagickWand.h... yes
checking for ImageLayerMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h
,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for long double in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdi
nt.h,sys/types.h,wand/MagickWand.h... yes
checking for AlphaChannelType.CopyAlphaChannel... yes
checking for AlphaChannelType.BackgroundAlphaChannel... yes
checking for CompositeOperator.BlurCompositeOp... yes
checking for CompositeOperator.DistortCompositeOp... yes
checking for CompositeOperator.LinearBurnCompositeOp... yes
checking for CompositeOperator.LinearDodgeCompositeOp... yes
checking for CompositeOperator.MathematicsCompositeOp... yes
checking for CompositeOperator.PegtopLightCompositeOp... yes
checking for CompositeOperator.PinLightCompositeOp... yes
checking for CompositeOperator.VividLightCompositeOp... yes
checking for CompressionType.DXT1Compression... yes
checking for CompressionType.DXT3Compression... yes
checking for CompressionType.DXT5Compression... yes
checking for CompressionType.ZipSCompression... yes
checking for CompressionType.PizCompression... yes
checking for CompressionType.Pxr24Compression... yes
checking for CompressionType.B44Compression... yes
checking for CompressionType.B44ACompression... yes
checking for DistortImageMethod.BarrelDistortion... yes
checking for DistortImageMethod.BarrelInverseDistortion... yes
checking for DistortImageMethod.BilinearForwardDistortion... yes
checking for DistortImageMethod.BilinearReverseDistortion... yes
checking for DistortImageMethod.DePolarDistortion... yes
checking for DistortImageMethod.PolarDistortion... yes
checking for DistortImageMethod.PolynomialDistortion... yes
checking for DistortImageMethod.ShepardsDistortion... yes
checking for DitherMethod.NoDitherMethod... yes
checking for FilterTypes.KaiserFilter... yes
checking for FilterTypes.WelshFilter... yes
checking for FilterTypes.ParzenFilter... yes
checking for FilterTypes.LagrangeFilter... yes
checking for FilterTypes.BohmanFilter... yes
checking for FilterTypes.BartlettFilter... yes
checking for FilterTypes.SentinelFilter... yes
checking for MagickEvaluateOperator.PowEvaluateOperator... yes
checking for MagickEvaluateOperator.LogEvaluateOperator... yes
checking for MagickEvaluateOperator.ThresholdEvaluateOperator... yes
checking for MagickEvaluateOperator.ThresholdBlackEvaluateOperator... yes
checking for MagickEvaluateOperator.ThresholdWhiteEvaluateOperator... yes
checking for MagickEvaluateOperator.GaussianNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.ImpulseNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.LaplacianNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.MultiplicativeNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.PoissonNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.UniformNoiseEvaluateOperator... yes
checking for MagickEvaluateOperator.CosineEvaluateOperator... yes
checking for MagickEvaluateOperator.SineEvaluateOperator... yes
checking for MagickEvaluateOperator.AddModulusEvaluateOperator... yes
checking for MagickFunction.ArcsinFunction... yes
checking for MagickFunction.ArctanFunction... yes
checking for MagickFunction.PolynomialFunction... yes
checking for MagickFunction.SinusoidFunction... yes
checking for ImageLayerMethod.FlattenLayer... yes
checking for ImageLayerMethod.MergeLayer... yes
checking for ImageLayerMethod.MosaicLayer... yes
checking for ImageLayerMethod.TrimBoundsLayer... yes
checking for VirtualPixelMethod.HorizontalTileVirtualPixelMethod... yes
checking for VirtualPixelMethod.VerticalTileVirtualPixelMethod... yes
checking for VirtualPixelMethod.HorizontalTileEdgeVirtualPixelMethod... yes
checking for VirtualPixelMethod.VerticalTileEdgeVirtualPixelMethod... yes
checking for VirtualPixelMethod.CheckerTileVirtualPixelMethod... yes
checking for ruby/io.h... yes
checking for rb_frame_this_func() in ruby.h,ruby/io.h... yes
creating extconf.h
creating Makefile
======================================================================
Wed 25Apr12 14:10:35
This installation of RMagick 2.13.1 is configured for
Ruby 1.9.2 (i386-mingw32) and ImageMagick 6.7.6
======================================================================
make
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2
.13.1 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/ext/RMagick
/gem_make.out
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `b
lock in build_extensions'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `e
ach'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `b
uild_extensions'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `i
nstall'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour
ce.rb:101:in `block in install'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby
gems_integration.rb:78:in `preserve_paths'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/sour
ce.rb:91:in `install'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst
aller.rb:58:in `block (2 levels) in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/ruby
gems_integration.rb:93:in `with_build_args'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst
aller.rb:57:in `block in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst
aller.rb:49:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/inst
aller.rb:8:in `install'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/cli.
rb:220:in `install'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor/task.rb:22:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor/invocation.rb:118:in `invoke_task'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor.rb:263:in `dispatch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/vend
or/thor/base.rb:386:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/bin/bundle:13:in
`<top (required)>'
from C:/Ruby192/bin/bundle:19:in `load'
from C:/Ruby192/bin/bundle:19:in `<main>'
C:\Rails\myapp>
最佳答案
如果您正在使用 Bundler(当您使用 Rails 时,您也在使用 Bundler),您需要将 RMagick 添加到您的 Gemfile 中。 Bundler 只会将捆绑的 gem 加载到您的环境中。
gem 文件
source :rubygems
# loads of other stuff
gem 'rmagick'
然后运行
bundle install
你应该可以开始了
关于ruby-on-rails - 安装 Rmagick : `require' : no such file to load -- RMagick (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10312493/
我有 2 个图像, Logo 和背景, Logo 是我放置在背景中心的一个小图像。为了使图像看起来更好,我试图让它在 Logo 边缘拾取颜色并将其设置为背景的背景颜色。 我已经让一切正常工作了颜色查找
我正在尝试使用 Rmagick 调整图像大小,如果我使用 resize_to_fit方法总是先调整高度,而不是宽度,但似乎我的大多数图像都首先调整为宽度。无论如何使用resize_to_fit告诉它“
我有一个带有大图像的全尺寸 slider 例如:1885x1440这些是照片,我需要使用 RMagick 对其进行优化但保持质量和图像大小(1885x1440) 我认为应该是这种方法之一http://
尝试使用 rmagick 镶嵌图像。 如何“马赛克模糊”现有图像使其代表马赛克的图片? 喜欢: 最佳答案 这就是你如何使用 RMagick 做马赛克 #!/home/software/ruby-1.8
当我在 rails 的 lib 文件夹中运行命令 ruby billede.rb 时,出现错误: C:\Rails\myapp\lib>ruby billede.rb C:/Ruby192/lib
当我通过 FactoryGirl 和 Faker 创建一个对象时,shell 显示一个错误 [1] pry(main)> FactoryGirl.create(:company) [DEPRECATI
我正在使用 Mac pro Lion 通过 ImageMagick Q16、RVM 和 ruby 1.8.7 进行开发 我可以在 IRB 中使用以下内容: 注意“rmagick”这个词的不同大写
我使用脚本来安装 ImageMagick http://github.com/masterkain/ImageMagick-sl 过了一会儿,我安装了 ImageMagick。 然后我运行 sudo
在 linux 中,我正在执行以下操作将多页 PDF 转换为调整大小并具有高分辨率的图像: convert -verbose -colorspace RGB -resize 800 -interlac
我正在尝试在 RMagick 中创建撕裂边缘效果。有没有类似photoshop的crystallize的滤镜? 另外,我在这里找到了这个 ImageMagick 代码 http://www.image
我的环境是 Linux centos,使用 ruby 1.8.7,代码如下: require 'rubygems' require 'RMagick' Magick::Image.read("ht
我想调整/缩放图像。原件的尺寸与 300x200 或 512x600 不同。我想将图像的大小调整为 100x100,但不要裁剪图像中的任何内容或更改比例。理想情况下,图像将首先将长边缩放到 100(宽
今天我试着写一个代码从文件夹生成动画gif但我得到这个错误: .../.gem/ruby/2.0.0/gems/rmagick-2.13.2/lib/RMagick.rb:1635:in `read'
在我的 Mac 上安装 rmagick gem 时遇到问题。我所有的软件都是最新的。这是我的错误信息。我试过重新安装 ImageMagick,但似乎没有任何效果。我使用自制软件 - 不能因为这个问题,
下面的 imageMagick 命令会将一个 Sprite 图像裁剪成几个均分的图像: convert image.png -crop 2x3-40-20@ +repage +adjoin tile-
我无法找到如何使用 RMagick 获取给定字形的所有指标。 我知道有一个 get_type_metrics 方法可以给出基线、高度、上升、下降等,但我还想获得给定字形的 x 高度、大写高度、边界矩形
我试图在将图像合成到另一个图像之前旋转图像,使用 RMagick 和 ruby。我可以合成叠加图像,但是当我尝试旋转图像时,背景的部分被移除,就像这样...... 我不确定我应该使用哪个 Comp
我在这里试过这个例子: http://www.imagemagick.org/RMagick/doc/usage.html#annotation 但我只能生成这张图片。 这看起来与该页面上生成的图像不
有没有办法在我设置宽度和高度的 rmagick 中缩放和图像,以便图像包含相同的比例? 最佳答案 我使用 resize_to_fit 方法,它将使用提供的参数作为最大宽度/高度,但会保持宽高比。所以,
我发现当你想在 Rmagick 中裁剪图像时,它不会改变当前图像对象,但会返回一个新图像。 所以,如果我有: @image = Magick::ImageList.new(path) @cropped
我是一名优秀的程序员,十分优秀!