rmagick

How do I get the hex value from each pixel in RMagick or Chunky_PNG?

给你一囗甜甜゛ 提交于 2019-12-11 20:37:41
问题 I'm trying to read the value of each pixel as hex (HTML notation) using RMagick or Chunky_PNG e.g. #5DBCD2 . At the moment I have the below which kind of does what I want but I couldn't find the right way to actually read the hex value. I'd prefer to use Chunky_PNG though, thanks! require 'chunky_png' img = ChunkyPNG::Image.from_file("image.png") height = img.dimension.height width = img.dimension.width height.times do |i| width.times do |j| p [ChunkyPNG::Color.r(img[j,i]), ChunkyPNG::Color.g

Rmagick errors when running Rails S after upgrading to OSX Mavericks 10.9

三世轮回 提交于 2019-12-11 18:26:05
问题 I updated my osx to Mavericks 10.9 from 10.7, and since then I have been having issues running 'rails s'. The issue is with Rmagick, and I have tried almost every solution that I could find. Most people recommended reinstalling imagemagick through homebrew, and reinstalling rmagick gem, but that didn't work. I even uninstalled homebrew as a whole, and reinstalled it. I tried getting rid of gemfile.lock, and running bundle install again, but none of these worked. Here is the error message I

Reading uploaded image: undefined method `file' for nil:NilClass

守給你的承諾、 提交于 2019-12-11 13:51:30
问题 I receive the following error when I try to get image during thumbnail creation: undefined method `file' for nil:NilClass My code: version :thumb do img = ::Magick::Image::read(@file.file).first w = img.columns h = img.rows if w < h process :resize_to_limit => [30, 50] else process :resize_to_limit => [50, 30] end end Any ideas what is this not working? 来源: https://stackoverflow.com/questions/24363366/reading-uploaded-image-undefined-method-file-for-nilnilclass

Rails show rgb color string as color swatch

旧时模样 提交于 2019-12-11 11:03:16
问题 Im using RMagick to take the average color of an image a user uploads. and I've got it down to displaying as RGB format. Now I'd like to take that RGB string and display it as a color swatch on the page...any idea on how to accomplish this? {:r=>155, :g=>132, :b=>118} 回答1: # controller @image = Magick::Image.read(@design.photo.path).first average_color = # your magick method to return the average color # so average is like " {:r=>155, :g=>132, :b=>118} " @average_color_string = "##{average

Error while installing ImageMagick for Ruby on Rails on Windows

南笙酒味 提交于 2019-12-11 07:41:47
问题 I'm installing ruby on rails and redmine with xampp following this documentation: http://nlb-creations.com/2013/06/26/installing-ruby-on-rails-and-redmine-with-xampp-on-windows-7/ Step 12 requires installing rmagick, I followed the steps correctly till I reached 12-d : In the cmd window, run the following: gem install rmagick --platform=ruby -- --with-opt-lib=c:/ImageMagick/lib --with-opt-include=c:/ImageMagick/include I got the following error: C:\xampp\htdocs\dev-ruby\redmine>gem install

How do I improve Rails / Paperclip image compression inside or ImageMagick / Rmagick?

喜夏-厌秋 提交于 2019-12-11 03:26:06
问题 I'm using Paperclip to crop an image in rails. I use these convert options: "-quality #{attachment.quality} \ -crop #{attachment.width}x#{attachment.height}+#{attachment.x}+#{attachment.y}" If I crop and save the image as a JPEG with 65% quality the image comes out awful and still has quite a large image size. However if I use Image Bucket Pro and do the exact same thing, the JPEG comes out looking much better and with a smaller file size. What can I do to Paperclip (ImageMagick / Rmagick) to

Rmagic isn't work on Rails3

回眸只為那壹抹淺笑 提交于 2019-12-11 02:24:24
问题 My Rmagic isn't work ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] rails -v Rails 3.0.0.beta4 irb require rubygems true require rmagick true but , I put the fllow code: gem 'rmagick', :require => false it error: checking for Ruby version >= 1.8.5... yes checking for stdint.h... no checking for sys/types.h... no checking for wand/MagickWand.h... no Can't install RMagick 2.13.1. Can't find MagickWand.h. *** extconf.rb failed *** Could not create Makefile due to some reason,

How to tell if GIF is animated?

左心房为你撑大大i 提交于 2019-12-10 22:28:04
问题 I have this Rails app with Paperclip for image uploads -- but how do I check if the image is an animated GIF with RMagick? 回答1: You can count the scenes associated with the image. In Rmagick that means doing something like this: image = Magick::ImageList.new(image_file) if image.scene == 0 #this is not an animated gif else #this is an animated gif end 来源: https://stackoverflow.com/questions/27238816/how-to-tell-if-gif-is-animated

Paperclip & RMagick - 3-page thumbnail of PDF and renaming

若如初见. 提交于 2019-12-10 21:44:11
问题 I want to upload pdf file, and create (as a separate file) a thumbnail image with first 3 pages of the pdf aligned horizontally. I managed to do a Paperclip Processor with RMagick to generate that file, but the problem is: I want the seperate file (the one with style for thumbnail) have the right extension (ex. jpg) not original pdf. It would be great if I could still get the correct path by using the url method with style, for ex.: >> attachment.url => "/some/path/id/original/test.pdf" #

Rails 3 - RMagick doesn't find libfreetype.6.dylib using Paperclip

孤街醉人 提交于 2019-12-10 20:44:42
问题 I'm trying to use Paperclip to upload some image. It's work fine but if I want add some style with : :styles => { :small => "100x100" } It does not work anymore, I have this error message : myImage is not recognized by the 'identify' command. So, I've found some tips on the web and I've installed ImageMagick with Brew then I've added gem 'Rmagick' to my GemFile. And now when I restart my server, I get this message error : /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rmagick-2.13.1/lib