Tag: imagemagick

使用Paperclip圆角

如何使用Paperclip创建圆角? 我发现这个解决方案使用convert_options通过回形针创建圆角 ,但它不适用于Rails 3和Paperclip 2.4.5。 仅当我使用ImageMagick alpha参数而不是阈值参数时,生成的convert命令才有效: convert example.jpg \ \( +clone -alpha extract \ -draw ‘fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0’ \ \( +clone -flip \) -compose Multiply -composite \ \( +clone -flop \) -compose Multiply -composite \ \) -alpha off -compose CopyOpacity -composite rounded_corners.png 对应于 has_attached_file :avatar, :styles […]

回形针可以从S3铲斗中读取照片几何图形吗?

我想从S3容器中读取照片的几何图形。 当它在我的本地,这工作: def photo_geometry(style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file photo.path(style) end 但是当我将模型切换到S3时它似乎不起作用..任何建议? 更重要的是,我正在尝试编写一些代码,允许我从S3中检索照片,允许用户裁剪它们,然后将它们重新上传回仍然由回形针分配的S3。 编辑: 这是返回的错误: Paperclip::NotIdentifiedByImageMagickError: photos/199/orig/greatReads.png is not recognized by the ‘identify’ command. from /Users/daniellevine/Sites/hq_channel/vendor/gems/thoughtbot-paperclip-2.3.1/lib/paperclip/geometry.rb:24:in `from_file’ from /Users/daniellevine/Sites/hq_channel/app/models/photo.rb:68:in `photo_geometry’ from (irb):1

Ruby图形库

RMagic,ImageMagick,GD等有什么区别我应该使用哪一个? 我一直在寻找缩略图生成脚本,并注意到我发现的每个脚本都使用不同的库来执行相同的操作。

在OS X El Capitan上,gem install rmagick失败

几天前我升级到El Capitan然后跑了一个 brew update && brew upgrade 它更新了imagemagick,导致ruby的rmagick gem停止工作。 没问题,我想,我会跑 gem install rmagick 它会重新编译。 除了它没有,当我运行它时,我看到: gem install rmagick Building native extensions. This could take a while… ERROR: Error installing rmagick: ERROR: Failed to build gem native extension. /Users/sam/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151019-57347-30ju1w.rb extconf.rb checking for clang… yes checking for Magick-config… yes checking for outdated ImageMagick version (= […]

JPG到PNG使用RMagick

我正在尝试使用RMagick将获取的图像从JPG转换为PNG,resize然后将其存储在S3上: thumb = Magick::Image.read(“artist.jpg”).first thumb.write(“artist.png”) thumb.crop_resized!(120, 120, Magick::CenterGravity) AWS::S3::S3Object.store(“image.png”, thumb.to_blob, AWS_BUCKET, :content_type => ‘image/png’, :access => :public_read) 图像确实保存为png但是当我在预览中打开它时,文档类型仍然显示“JPEG图像”。 实际上,除非我将扩展名更改回“.jpg”,否则图像甚至不会在Photoshop中打开。 我错过了什么吗?

无法在Windows 7上安装Rmagick和Imagemagick

当我从gem install rmagick-2.13.1.gem的目录运行gem install rmagick-2.13.1.gem ,我得到一个错误,说它无法构建gem native扩展,在它之下 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. 据我所知,在http://rmagick.rubyforge.org/install-faq.html#os上阅读常见问题解答的答案时,rmagick应该与ImageMagick Windows Installer捆绑在一起。 答案还提到了rmagick-win32.gem。 我没见过任何地方。 这就是为什么我会假设rmagick-2.13.1.gem是我需要的,因为它是唯一可用的,考虑到常见问题解答引用旧版本的rmagick。 所以,我真的很困惑这该死的问题是什么。 我还看了一下mkmf.log文件,我发现的唯一的东西就是 checking […]

使用ImageMagick转换颜色(不是图像)

更具体地说,我想在Ruby平台上准确地将CMYK值(可能来自ISO Coated v2空间)转换为RGB值(可能来自sRGB空间)(可能使用ICC配置文件)。 ImageMagick似乎是一个很好的起点,但我也听说LittleCMS可能已被移植/包装以与Ruby一起工作。 再一次,我想转换单色,而不是图像文件。 有任何想法吗?

错误:通过Homebrew安装ImageMagick时未定义的方法`=〜’

当我试图通过Homebrew安装ImageMagick时,我得到了一个非常奇怪的答案。 它给了我这个: Holger-Sindbaeks-MacBook-Air:showwwdown_0.3 holgersindbaek$ brew install imagemagick Error: undefined method `=~’ for # Please report this bug: https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue /usr/local/Library/Homebrew/formula.rb:426:in `factory’ /usr/local/Library/Homebrew/formula_installer.rb:38:in `block (2 levels) in install’ /usr/local/Library/Homebrew/extend/ARGV.rb:121:in `filter_for_dependencies’ /usr/local/Library/Homebrew/formula_installer.rb:34:in `block in install’ /usr/local/Library/Homebrew/formula_installer.rb:30:in `each’ /usr/local/Library/Homebrew/formula_installer.rb:30:in `install’ /usr/local/Library/Homebrew/cmd/install.rb:103:in `block in install_formulae’ /usr/local/Library/Homebrew/cmd/install.rb:86:in `each’ /usr/local/Library/Homebrew/cmd/install.rb:86:in `install_formulae’ /usr/local/Library/Homebrew/cmd/install.rb:24:in `install’ /usr/local/bin/brew:83:in `’ 它绝对没有告诉我,我不知道下一步可能是什么。 你有什么想法? 我在Mac OSX 10.6和Ruby 1.9.2上运行

使用RMagick和Ruby将.pdf转换为图像

我想拍一张pdf并将其转换成图像……每个pdf页面都成为一个单独的图像。 这里有类似的post: 将.doc或.pdf转换为图像并在Ruby中显示缩略图? 但它没有涵盖如何为每个页面制作单独的图像。

Carrierwave作物特定版本

我正致力于使用carrierwave和Jcrop裁剪图像。 它是Railscasts第182集和第253集的组合。我有裁剪工作,但它裁剪原始。 无论如何都强迫manupulate! 使用不同的版本? def crop_image(x,y,w,h) manipulate! do |img| img.crop(x.to_i, y.to_i, w.to_i, h.to_i) end end 或者有没有办法从模型调用中设置版本? attr_accessor :crop_x, :crop_y, :crop_w, :crop_h attr_accessible :description, :image, :crop_x, :crop_y, :crop_w, :crop_h after_update :reprocess_image, :if => :cropping? def cropping? !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? end def reprocess_image image.crop_image(crop_x, crop_y, crop_w, crop_h) end