Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Gemfile.rails5_mini_magick
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2011-2023 NAITOH Jun
# Copyright (c) 2011-2025 NAITOH Jun
# Released under the MIT license
# http://www.opensource.org/licenses/MIT

Expand All @@ -8,5 +8,6 @@ source 'https://rubygems.org'
gemspec

gem "actionpack", "~> 5.2.8.1"
gem "mini_magick", "< 5.0"
gem "mini_magick"
gem 'marcel'
gem 'loofah', '<= 2.20.0' if RUBY_VERSION < '2.5'
3 changes: 2 additions & 1 deletion Gemfile.rails6_mini_magick
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ gemspec

gem "actionpack", "~> 6.1.7.2"
gem "concurrent-ruby", '1.3.4'
gem "mini_magick", "< 5.0"
gem "mini_magick"
gem 'marcel'
3 changes: 2 additions & 1 deletion Gemfile.rails7_mini_magick
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ source 'https://rubygems.org'
gemspec

gem "actionpack", "~> 7.2.2.1"
gem "mini_magick", "< 5.0"
gem "mini_magick"
gem 'marcel'
4 changes: 2 additions & 2 deletions Gemfile.rails8_mini_magick
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ source 'https://rubygems.org'
gemspec

gem "actionpack", "~> 8.0.2"
gem "mini_magick", "< 5.0"

gem "mini_magick"
gem 'marcel'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RBPDF is distributed via RubyGems, and can be installed the usual way that you i

If you are using image file, it is recommended you install:
```
gem install mini_magick
gem install mini_magick marcel
```
or
```
Expand Down
13 changes: 11 additions & 2 deletions lib/core/mini_magick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,27 @@ def getimagesize(filename)
return false
end

unless Object.const_defined?(:Marcel)
Error('No Marcel: Non-PNG file is not supported.: ' + filename);
return false
end

image = MiniMagick::Image.open(filename)

width = image.width
height = image.height

out['mime'] = image.mime_type
mime_type = File.open filename do |file|
::Marcel::MimeType.for file
end

out['mime'] = mime_type
out[0] = width
out[1] = height

# These are actually meant to return integer values But I couldn't seem to find anything saying what those values are.
# So for now they return strings. The only place that uses this at the moment is the parsejpeg method, so I've changed that too.
case image.mime_type
case mime_type
when "image/gif"
out[2] = "GIF"
when "image/jpeg"
Expand Down
6 changes: 6 additions & 0 deletions lib/rbpdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
# MiniMagick is not available
end

begin
require 'marcel' unless Object.const_defined?(:Marcel)
rescue LoadError
# Marcel is not available
end

unless Object.const_defined?(:MiniMagick)
begin
# RMagick 2.14.0
Expand Down