我一直在用下面的颜色进行转换
if @image.colorspace == Magick::CMYKColorspace
# @image.colorspace #=> CMYKColorspace=12
@image.colorspace = Magick::RGBColorspace
@image = @image.negate
end
Run Code Online (Sandbox Code Playgroud)
它大约有效,但颜色亮度不对.我需要否定图像的事实留下了非常难闻的气味.
该文档提到了使用color_profiles,但除此之外我找不到多少.
我现在正在努力
@image = @image.quantize(16777216, Magick::RGBColorspace)
Run Code Online (Sandbox Code Playgroud)
颜色更好,但仍然关闭.
我写了一个简单的Sinatra应用程序,它使用来自某些用户输入的rmagick生成图像.图像以唯一的文件名保存在./public目录中.在Sinatra生成的HTML中使用唯一文件名,以便每个用户获取正确的图像.每天一次脚本删除超过一小时的文件.这显然是一个可怕的黑客,但我没有网络经验!
有没有办法在没有先将它保存到磁盘的情况下在sinatra中提供rmagick图像?
我想拍一个pdf并将其转换成图像......每个pdf页面都成为一个单独的图像.
这里有类似的帖子:将.doc或.pdf转换为图像并在Ruby中显示缩略图? 但它没有涵盖如何为每个页面制作单独的图像.
当我gem install rmagick-2.13.1.gem从rmagick-2.13.1.gem所在的目录运行时,我得到一个错误,说它无法构建gem原生扩展,在它下面说
c:/Ruby192/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5 ... yes
Unable to get Imagemagick version
***extconf.rb failed***
Could not create Makefile due to some reason, probably lack
of necessary libraries and/or headers. Check the mkmf.log file
for more details.
Run Code Online (Sandbox Code Playgroud)
据我所知,在http://rmagick.rubyforge.org/install-faq.html#os上阅读常见问题解答的答案时,rmagick应该与ImageMagick Windows Installer捆绑在一起.答案还提到了rmagick-win32.gem.我没有在任何地方见过它.这就是为什么我会假设rmagick-2.13.1.gem是我需要的,因为它是唯一可用的,考虑到常见问题解答引用旧版本的rmagick.所以,我真的很困惑这该死的问题是什么.
我还看了一下mkmf.log文件,我发现的唯一的东西就是
checking for Ruby version >= 1.8.5 ... yes
Run Code Online (Sandbox Code Playgroud)
整件事让我感到困惑.所以,任何帮助都将非常感激.非常感谢提前.
我有一个问题是找到一种方法来保存使用RMagick在回形针附件中创建的图像.
imageList = Magick::ImageList.new
imageList.new("images/apple.gif", "images/overlay.png")
...
picture = imageList.flatten_images
Run Code Online (Sandbox Code Playgroud)
我在一个有附件的模型中
has_attached_file :picture,
:url => ...,
:path => ...
我只想将imageList.flatten_images返回的图像保存为我模型的图片.
有谁知道如何轻松地做到这一点?
谢谢
我跟着安装了RMagick for OSX: http ://rmagick.rubyforge.org/install-faq.html#osx
我已经完成了John Maddux的Imagemagick安装(在不使用MacPorts的情况下在OSX 上安装ImageMagick的解决方案)
这是我的终端窗口:
Suebphatt:~ suebphattleelertphong$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Suebphatt:~ suebphattleelertphong$ rails -v
Rails 3.0.3
Suebphatt:~ suebphattleelertphong$ gem -v
1.3.7
Suebphatt:~ suebphattleelertphong$ gem install rmagick
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/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed …Run Code Online (Sandbox Code Playgroud) 我使用了ruby 1.9.2和rails 3.0.3.我试图安装rmagick gem但是当我运行时bundle install我得到一个错误告诉我:
Installing rmagick (2.12.1) with native extensions c:/Ruby192/lib/ruby/site_ruby
/1.9.1/rubygems/installer.rb:529: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... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib …Run Code Online (Sandbox Code Playgroud) $ gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/XXXXXXX/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180/bin:/Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180@global/bin:/Users/XXXXXXX/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/XXXXXXX/.rvm/bin:/Users/XXXXXXX/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options. …Run Code Online (Sandbox Code Playgroud) 在尝试安装fileutils gem时,我得到以下输出:
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the …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提前.