我正在尝试以编程方式创建大量网页的缩略图,这些网页托管在我自己的基于ruby/rails的网站上.
我希望能够编写一个独立的ruby代码,看起来像这样:
require 'awesome-screenshot-maker'
items.each do |id|
url = "http://foo.com/bar/#{id}"
shooter = AwesomeScreenshotMaker.new(0.2) # thumbnails are 20% of original
shooter.capture(url, "/images/thumbnail-#{id}.png")
end
Run Code Online (Sandbox Code Playgroud)
我需要在Linux,Solaris和Mac OS X上构建相当容易的awesome-screenshot-maker库(及其依赖项).理想情况下,它将使用单个"gem install"命令进行安装.
我花了一个下午探索各种选项,包括Moz snap shooter,webkit2png和rbwebkitgtk.它们都在正确的区域,但似乎都不适用于所有三个平台.
如果我愿意从我的rails应用程序(而不是网页)输出PDF,RMagick看起来像是一个可能的选项,但这让我觉得很糟糕.在Mac OS X上运行RMagic和imagemagick也很费力.
是否存在可以在三个平台上轻松设置的库?
升级到Rails 3.0库之后,rmagick会被检测到更长时间.这是我的设置:
Ubuntu server 10.4
gem 1.7.2
ruby 1.9.1
rails 3.0.7
rmagick-2.13.1
Run Code Online (Sandbox Code Playgroud)
在irb可以包括库:
irb(main):002:0> require 'RMagick'
=> true
Run Code Online (Sandbox Code Playgroud)
在轨道2 rmagick是可用的.
好吧,我一直在尝试在Windows 7 x64机器上安装Rmagick.我已经查看了Stack Overflow和其他网站上的每一个教程,但无论我遵循哪个教程,我都会收到"无效的驱动器规范"错误.我的环境来自http://railsinstaller.org/.有没有人最近成功安装了Rmagick,可以指出我正确的方向?谢谢,这让我发疯,但我真的必须让它发挥作用.
如何获得当前载波实例的宽度和高度?
像这样的东西:
car_images.each do | image|
image_tag( image.photo_url, :width => image.photo_width, :height => image.photo_height)
end
Run Code Online (Sandbox Code Playgroud)
不幸的是image.photo_width,image.photo_height并没有工作.我需要指定图像的宽度和高度,这是我正在使用的jquery插件所必需的.
编辑:[固定]问题是我已经安装它,但不知道,并试图从源安装.这创建了两个版本,gem不知道使用哪个版本.我通过转到下载的源并运行来修复它
sudo make uninstall
Run Code Online (Sandbox Code Playgroud)
然后我再次运行gem install rmagick并且它工作了!
[原始问题]
我正试图在这个railscast中安装rmagick gem .这是我在gemfile中放置的片段:
gem 'rmagick'
gem 'carrierwave'
Run Code Online (Sandbox Code Playgroud)
当我运行bundle install时,我得到以下输出:
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/techusb/.rbenv/versions/1.9.3-p125/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for cc... yes
checking for Magick-config... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/usr/local/bin/Magick-config reports version 6.8.0 Q16 is installed in …Run Code Online (Sandbox Code Playgroud) 如何为Windows XP安装rmagick gem?我已经使用头文件安装了ImageMagick,并安装了DevKit附带的RailsInstaller.org.我不知道在哪里修复这些错误.
C:\RailsInstaller\ImageMagick-6.8.2-Q16>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
C:\RailsInstaller\ImageMagick-6.8.2-Q16>gem -v
1.8.16
C:\RailsInstaller\ImageMagick-6.8.2-Q16>path=%PATH%;C:\RailsInstaller\ImageMagick-6.8.2-Q16
C:\RailsInstaller\ImageMagick-6.8.2-Q16>identify
Version: ImageMagick 6.8.2-0 2013-01-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
C:\RailsInstaller\ImageMagick-6.8.2-Q16>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** extconf.rb failed ***
Could not create Makefile …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MiniMagick来调整图像大小,我在控制器文件中执行了以下操作:
require 'rubygems'
require 'mini_magick'
Run Code Online (Sandbox Code Playgroud)
和
img = MiniMagick::Image.open(file)
Run Code Online (Sandbox Code Playgroud)
但是当我调用控制器时如下
LoadError (cannot load such file -- mini_magick)
Run Code Online (Sandbox Code Playgroud)
我已添加gem 'mini_magick'到我的Gemfile中,所以我真的不知道发生了什么.有人可以帮我弄这个吗?
顺便说一句,这是在这两个可用的irb和rails console,而不是在一个服务器上运行.
Thx提前.
我正在尝试通过brew安装Imagemagick,我在安装时收到此消息:
Warning: imagemagick-6.8.6-3 already installed, it's just not linked
Run Code Online (Sandbox Code Playgroud)
当我尝试通过brew链接链接它时,我得到了这个:
brew link imagemagick
Warning: Could not link imagemagick. Unlinking...
Linking /usr/local/Cellar/imagemagick/6.8.6-3...
Error: File exists - /usr/local/etc
Run Code Online (Sandbox Code Playgroud)
想法?我试过了:
'brew link -f imagemagick'
Run Code Online (Sandbox Code Playgroud)
没有运气(我得到与上面相同的错误信息).这里建议:使用ImageMagick进行Brew链接
根据brew更新,我是最新的.Brew医生回复此信息:
Warning: You have MacPorts or Fink installed:
/Users/user_name/.rvm/bin/port, /opt/local/bin/port
This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.
sudo mv /opt/local ~/macports
Warning: You have unlinked kegs in your Cellar
Leaving kegs …Run Code Online (Sandbox Code Playgroud) 来自Rmagick指南:
将图像转换为另一种格式
将图像转换为另一种格式就像将图像写入文件一样简单.
ImageMagick使用输出文件名suffix (".jpg"
for JPEG, ".gif" for GIF, for example)或prefix ("ps:" for
PostScript, for example)确定输出图像的格式.
有没有办法在内存中转换图像?
我尝试将rails从4.1.1升级到4.2.0,然后我遇到错误安装Rmagick.在升级rails之前,Rmagick在rails4.1.1上运行良好.重新安装ImageMagick后我尝试了,但仍然出错.
这就是我得到的
sudo gem install rmagick -v 2.13.4
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for xcrun... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... 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,stdint.h,sys/types.h,wand/MagickWand.h... yes
checking for AcquireImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
checking for AffinityImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... …Run Code Online (Sandbox Code Playgroud) rmagick ×10
ruby ×8
imagemagick ×6
gem ×2
carrierwave ×1
gtk ×1
homebrew ×1
rubygems ×1
screenshot ×1
unix ×1