I managed to run this line in development with no problem:
canvas = Magick::Image.read("caption:#{something}")
But deploying in Heroku, this message appears:
Magick::ImageMagickError (must specify image size `something?' # error/caption.c/ReadCAPTIONImage/135)
Is there any way to proceed without providing image dimensions? I need to these image files with text on the fly and I can't provide an exact width.
Thank you
You are most likely having a compatibility issue between rMagick and ImageMagick (which rMagick uses). I had the reverse problem: reading images suddenly didn't work locally, but worked fine on production.
I just read that Heroku is using a very old version of ImageMagick (6.5, but that may have changed.) I would try downgrading the version of rMagick you are using by setting it in your Gemfile. I'm using v 2.13.3.
gem "rmagick", "2.13.3", :require => "RMagick"
Related
I get this error when i ran my rails app on my Windows Localhost when I tried to upload an image.
I have a "product" model and I am using Mini_Magick with CarrierWave for uploading the product's image.
Image Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: ImageMagick/GraphicsMagick is not installed
I have done the "bundle install" command after putting mini_magick gem in my gem-file and I have checked that Imagemagick is installed by running "convert" everything works fine... What could be the problem?
Have you installed GraphicsMagick on your machine? You will need this installed locally if your doing any kind of image manipulation with your uploads, which it appears you are.
Downloads can be found here:
ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/
Another advise: this error happened to me even after installing GraphicsMagick, I solved it by restarting visual studio code, which is the IDE I'm using. So, be ware of restarting the terminal you are using to run rails after installing GraphicsMagick
I'm looking for a way to set up my rails app/Gem file to conditionally include a gem based on if I am in linux or not. I need the app in Linux, but it is not compatible with windows and I don't need it there anyway.
I was able to get everything working on Linux, but since I am using LESS stylesheets, I needed a javascript runtime. I didn't want to install Node.js, so i installed therubyracer, which is now in my gemfile. Then I pushed everything to github and cloned the app on my windows computer.
I tried to install all of the gems and realized there was no way install therubyracer on windows because of an incompatibility they haven't fixed yet (see therubyracer gem on windows)
I read elsewhere that I don't need therubyracer on windows because rails will automatically pick up the JScript runtime, so I'd like to have a simple way to only include therubyracer in linux. I read in does using ":platforms =>" in your gemfile work? that I can use an if block in my gemfile, but that it will cause my gemfile.lock to be regenerated every time. That was over a year ago though. Is there a way to only include therubyracer without regenerating gemfile.lock every time? Or maybe is gemfile.lock ok to remove my git and just have it generated every time locally?
I think you'll probably have to use that answer in the :platforms question and just ignore the fact that the gemfile.lock is regenerated. There's not much point in keeping the lockfile in your repository when it will be different on each platform. However, you can still maintain some of the control that the lockfile provides by manually specifying specific versions and dependencies in the gemfile.
I am using Carrierwave with RMagick in my Ruby on Rails application.
Everything works fine in development, but on my staging environment, I am having some problems.
I tracked it down to what seems to be a problem with RMagick, losing part of the file path being passed to it. Here is some output from my rails console
require 'RMagick'
=> true
# Prove the file exists
File.open('/tmp/logo.png')
=> #<File:/tmp/logo.png>
# Cant find it with RMagick
Magick::Image::read('/tmp/logo.png').first
=> Magick::ImageMagickError: unable to open file `o.png' # error/png.c/ReadPNGImage/3698
# Unless I add some characters at the start of my filepath (anything will do)
Magick::Image::read('12345678/tmp/logo.png').first
=> 0x200=>200x100 4634766966517661696x200+100+0 DirectClass 8-bit 6kb
I have tried digging into the source code for RMagick, but without much success. I am hoping that someone can suggest what maybe going wrong.
I have tried recompiling ImageMagick and re-deployed the code several times.
We use rvm, Ruby 1.9.2, Rails 3.2.11 and deploy using Capistrano.
My colleague found the solution -
It was to re-install the rmagick gem.
I've been trying to work with Paperclip. I've installed ImageMagick. I've added the line
Paperclip.options[:command_path] = "/usr/local/bin" in config/initializers/paperclip.rb.
But i'm still getting the error "Avatar Paperclip::CommandNotFoundError".
How can i possibly solve this?
First, make sure you have the rmagick gem in your Gemfile
gem 'rmagick', :require => 'RMagick'
Next, open a rails console from the command line.
$ rails c
type:
`which convert`
You should see something like
=> "/usr/bin/convert\n"
If you do, then take the path, in this case /usr/bin, and set Paperclip.options[:command_path] to that path. If you don't, you need to make sure that ImageMagick is installed. For OSX use Homebrew (http://mxcl.github.com/homebrew/) or MacPorts. For Debian systems you'll need two packages:
imagemagick
libmagick9-dev
For Redhat/rpm-based systems, you can try their packages, but they are pretty old and you'll probably be better off compiling from source.
If you've got ImageMagick already installed then you'll need to make sure the convert command is in your path.
As a side note, if the rmagick gem installs, then you should have ImageMagick already installed, you just need to figure out where it is on your system.
have you tried installing/using rMagic?
I installed ImageMagick using the Binary from Macports for Snow Leopard. The install went fine, but Paperclip wasn't finding ImageMagick and I was getting the same errors.
I added the following to config/environments/development.rb:
Paperclip.options[:command_path] = "/opt/local/bin"
I restarted the server and everything works perfectly.
I have installed image magick on my mac os x computer and now I want to deploy it to heroku. I've installed the the paperclip plugin on heroku but I get this error when uploading an image:
Paperclip::CommandNotFoundError
I had this error before when I didn't have imagemagick instaledl on my computer before but now that I want to deploy it, how do I get image magick to work on heroku?
Do you have the RMagick gem included in your app on Heroku? It's necessary for interfacing between your Ruby code and ImageMagick.
ImageMagick is part of the Heroku platform by default, but you have to specify that you need the RMagick gem for your app. I'm guessing you have this installed locally so it works there, but it's missing from your Gemfile or gems manifest (depending on Heroku stack version).
Try to remove the Paperclip.options[:command_path] = "/path/to/" when deploying to heroku.
This solved the issue for me.
Add the following to your gemfile...
gem 'rmagick'