ImageMagick is software for manipulating and displaying images. It supports more than 100 types of image file formats such as GIF, JPEG, PNG, PDF, and TIFF, and has many functions necessary for converting and editing images from programs. It is used when you want to create a web service that processes and transforms images, such as "upload image → generate thumbnail".
Japanese manual on how to use Imagemagick
I want to use ImageMajick for various image processing.
But this is not Ruby's
In Ruby, it seems that it can be used with a gem called RMagick
, so put this in.
#add to
gem 'rmagick'
# => bundle install
However, the following error occurs.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/uenoyuuki/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rmagick-4.0.0/ext/RMagick
/Users/uenoyuuki/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20190916-2480-i0d2pg.rb extconf.rb
checking for brew... yes
checking for clang... yes
checking for pkg-config... yes
ERROR: Can't install RMagick 4.0.0. Can't find ImageMagick with pkg-config
*** 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
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/uenoyuuki/.rbenv/versions/2.5.0/bin/$(RUBY_BASE_NAME)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/uenoyuuki/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/rmagick-4.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/uenoyuuki/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rmagick-4.0.0 for inspection.
Results logged to /Users/uenoyuuki/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/rmagick-4.0.0/gem_make.out
An error occurred while installing rmagick (4.0.0), and Bundler cannot continue.
Make sure that `gem install rmagick -v '4.0.0' --source 'https://rubygems.org/'` succeeds before bundling.
It seems that you need to install Imaga Majick itself first.
Since the OS is ʻAmazon-Linux, install using
yum`.
$ sudo yum -y install ImageMagick ImageMagick-devel
#Add again
gem 'rmagick'
# => bundle install
success…!
As a failure to insert ImageMagick, I used to use a package manager as a glue, so I didn't know the difference between them, and it took a long time.
# Amazon-Not available on Linux
# Mac OS
$ brew install imagemagick@6
# Ubunts
$ sudo apt-get install imagemagick libmagick++-dev
I don't know what OS it is! It shouldn't happen, At worst, you can still check the OS.
$ cat /etc/*-release
Various ways to specify Variant for Active Storage Using RMagick with Rails Install [Gem] RMagick on CentOS The story that I solved the error when trying to use rmagick on Cloud9 Cannot install apt command
Recommended Posts