diff -Nru ruby-mini-magick-4.8.0/debian/changelog ruby-mini-magick-4.9.2/debian/changelog --- ruby-mini-magick-4.8.0/debian/changelog 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/changelog 2018-12-27 11:36:03.000000000 +0000 @@ -1,3 +1,11 @@ +ruby-mini-magick (4.9.2-1) unstable; urgency=medium + + * Team upload + * Bump Standards-Version to 4.3.0 + * New upstream version 4.9.2 + + -- Utkarsh Gupta Thu, 27 Dec 2018 17:06:03 +0530 + ruby-mini-magick (4.8.0-2) unstable; urgency=medium * Team upload @@ -42,7 +50,7 @@ ruby-mini-magick (4.3.6-2) unstable; urgency=medium - * Reupload to unstable + * Reupload to unstable -- Pirate Praveen Sat, 09 Jan 2016 00:30:31 +0530 @@ -98,7 +106,7 @@ ruby-mini-magick (4.2.0-2) unstable; urgency=medium * Team upload. - * Re-upload to unstable. + * Re-upload to unstable. -- Pirate Praveen Wed, 29 Apr 2015 13:18:00 +0530 @@ -113,7 +121,7 @@ ruby-mini-magick (4.0.1-2) experimental; urgency=medium * Team upload. - * Rebuild for fixing gemspec version. + * Rebuild for fixing gemspec version. -- Pirate Praveen Sun, 30 Nov 2014 04:01:35 +0530 @@ -149,7 +157,7 @@ * New upstream release * ruby tests are moved from test/ to spec, refreshing patches - * updating Build-Dep to new requirements by upstream tests + * updating Build-Dep to new requirements by upstream tests -- Markus Tornow Thu, 19 Dec 2013 02:46:19 +0000 @@ -163,8 +171,8 @@ ruby-mini-magick (3.5.0-2) unstable; urgency=low - * Applying patch remove-remote-test by Felix Geyer (thanks to him) - to disable tests requiring network connectivity (Closes: #706517) + * Applying patch remove-remote-test by Felix Geyer (thanks to him) + to disable tests requiring network connectivity (Closes: #706517) -- Markus Tornow Thu, 09 May 2013 17:51:29 +0200 diff -Nru ruby-mini-magick-4.8.0/debian/control ruby-mini-magick-4.9.2/debian/control --- ruby-mini-magick-4.8.0/debian/control 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/control 2018-12-27 11:36:03.000000000 +0000 @@ -14,7 +14,7 @@ ruby-posix-spawn, ruby-rspec (>= 3.1~), ruby-webmock -Standards-Version: 4.1.3 +Standards-Version: 4.3.0 Vcs-Git: https://salsa.debian.org/ruby-team/ruby-mini-magick.git Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-mini-magick Homepage: https://github.com/minimagick/minimagick diff -Nru ruby-mini-magick-4.8.0/debian/patches/fix-quotes-in-tests.patch ruby-mini-magick-4.9.2/debian/patches/fix-quotes-in-tests.patch --- ruby-mini-magick-4.8.0/debian/patches/fix-quotes-in-tests.patch 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/fix-quotes-in-tests.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: Fix quotes used in tests to match the actual output from imagemagick -Author: Balasankar C -Last-Update: 2017-06-28 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/spec/lib/mini_magick/shell_spec.rb -+++ b/spec/lib/mini_magick/shell_spec.rb -@@ -51,7 +51,7 @@ - stdout, stderr, status = subject.execute(%W[identify foo]) - - expect(stdout).to eq "" -- expect(stderr).to match("unable to open image 'foo'") -+ expect(stderr).to match("unable to open image `foo'") - expect(status).to eq 1 - end - diff -Nru ruby-mini-magick-4.8.0/debian/patches/imagemagick-json-change.patch ruby-mini-magick-4.9.2/debian/patches/imagemagick-json-change.patch --- ruby-mini-magick-4.8.0/debian/patches/imagemagick-json-change.patch 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/imagemagick-json-change.patch 2018-12-27 11:36:03.000000000 +0000 @@ -4,6 +4,7 @@ Description: correctly convert NaN values for JSON output Bug: https://github.com/minimagick/minimagick/issues/434 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892189 +Origin: https://github.com/MadeInSyria/minimagick/commit/a3a92ed31bc750901078b3a4e93c1b1c8b7ff6dd --- lib/mini_magick/image/info.rb | 6 +++--- @@ -11,7 +12,7 @@ --- a/lib/mini_magick/image/info.rb +++ b/lib/mini_magick/image/info.rb -@@ -157,10 +157,10 @@ +@@ -158,10 +158,10 @@ @info["data"] ||= ( json = MiniMagick::Tool::Convert.new do |convert| convert << path diff -Nru ruby-mini-magick-4.8.0/debian/patches/remove-deprecated-test.patch ruby-mini-magick-4.9.2/debian/patches/remove-deprecated-test.patch --- ruby-mini-magick-4.8.0/debian/patches/remove-deprecated-test.patch 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/remove-deprecated-test.patch 2018-12-27 11:36:03.000000000 +0000 @@ -2,14 +2,19 @@ --- a/spec/lib/mini_magick/image_spec.rb +++ b/spec/lib/mini_magick/image_spec.rb -@@ -402,17 +402,17 @@ +@@ -417,22 +417,22 @@ require "webmock/rspec" end - + describe "#details" do - it "returns a hash of verbose information" do - expect(subject.details["Format"]).to match /^JPEG/ - if MiniMagick.cli == :imagemagick -- expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" +- if Gem::Version.new(MiniMagick.cli_version) < Gem::Version.new('7.0.0') +- expect(subject.details["Channel depth"]["red"]).to eq "8-bit" +- else +- expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" +- end +- - expect(subject.details).to have_key("Background color") - expect(subject.details["Properties"]).to have_key("date:create") - else @@ -20,7 +25,12 @@ +# it "returns a hash of verbose information" do +# expect(subject.details["Format"]).to match /^JPEG/ +# if MiniMagick.cli == :imagemagick -+# expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" ++# if Gem::Version.new(MiniMagick.cli_version) < Gem::Version.new('7.0.0') ++# expect(subject.details["Channel depth"]["red"]).to eq "8-bit" ++# else ++# expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" ++# end ++# +# expect(subject.details).to have_key("Background color") +# expect(subject.details["Properties"]).to have_key("date:create") +# else @@ -28,6 +38,6 @@ +# expect(subject.details).to have_key("Resolution") +# end +# end - + context "when verbose information includes an empty line" do subject { described_class.new(image_path(:empty_identify_line)) } diff -Nru ruby-mini-magick-4.8.0/debian/patches/remove-function-valid_version_installed ruby-mini-magick-4.9.2/debian/patches/remove-function-valid_version_installed --- ruby-mini-magick-4.8.0/debian/patches/remove-function-valid_version_installed 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/remove-function-valid_version_installed 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -Description: removing the function valid_version_installed - removing require of rubygems from test/test_helper.rg will break the functions: - image_magick_version and minimum_image_magick_version from lib/mini_magick.rb, hence - the function valid_version_installed too (It compares both former values). To get rid - of the error all three functions are removed from lib/mini_magick.rb and the test - valid_version_installed is replaced by a TRUE in test/image_test.rb. -Author: Markus Tornow -Forwarded: not-needed -Last-Update: 2013-04-02 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/lib/mini_magick.rb -+++ b/lib/mini_magick.rb -@@ -22,17 +22,10 @@ module MiniMagick - end - end - -- def image_magick_version -- @@version ||= Gem::Version.create(`mogrify --version`.split(" ")[2].split("-").first) -- end -- -- def minimum_image_magick_version -- @@minimum_version ||= Gem::Version.create("6.6.3") -- end -- -- def valid_version_installed? -- image_magick_version >= minimum_image_magick_version -+ def valid_version_installed? -+ true - end -+ - end - - MOGRIFY_COMMANDS = %w{adaptive-blur adaptive-resize adaptive-sharpen adjoin affine alpha annotate antialias append attenuate authenticate auto-gamma auto-level auto-orient backdrop background bench bias black-point-compensation black-threshold blend blue-primary blue-shift blur border bordercolor borderwidth brightness-contrast cache caption cdl channel charcoal chop clamp clip clip-mask clip-path clone clut coalesce colorize colormap color-matrix colors colorspace combine comment compose composite compress contrast contrast-stretch convolve crop cycle debug decipher deconstruct define delay delete density depth descend deskew despeckle direction displace display dispose dissimilarity-threshold dissolve distort dither draw duplicate edge emboss encipher encoding endian enhance equalize evaluate evaluate-sequence extent extract family features fft fill filter flatten flip floodfill flop font foreground format frame function fuzz fx gamma gaussian-blur geometry gravity green-primary hald-clut help highlight-color iconGeometry iconic identify ift immutable implode insert intent interlace interpolate interline-spacing interword-spacing kerning label lat layers level level-colors limit linear-stretch linewidth liquid-rescale list log loop lowlight-color magnify map mask mattecolor median metric mode modulate monitor monochrome morph morphology mosaic motion-blur name negate noise normalize opaque ordered-dither orient page paint path pause pen perceptible ping pointsize polaroid poly posterize precision preview print process profile quality quantize quiet radial-blur raise random-threshold red-primary regard-warnings region remap remote render repage resample resize respect-parentheses reverse roll rotate sample sampling-factor scale scene screen seed segment selective-blur separate sepia-tone set shade shadow shared-memory sharpen shave shear sigmoidal-contrast silent size sketch smush snaps solarize sparse-color splice spread statistic stegano stereo stretch strip stroke strokewidth style subimage-search swap swirl synchronize taint text-font texture threshold thumbnail tile tile-offset tint title transform transparent transparent-color transpose transverse treedepth trim type undercolor unique-colors units unsharp update verbose version view vignette virtual-pixel visual watermark wave weight white-point white-threshold window window-group write} diff -Nru ruby-mini-magick-4.8.0/debian/patches/remove-rubygems ruby-mini-magick-4.9.2/debian/patches/remove-rubygems --- ruby-mini-magick-4.8.0/debian/patches/remove-rubygems 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/remove-rubygems 2018-12-27 11:36:03.000000000 +0000 @@ -10,5 +10,5 @@ -require "bundler/setup" +#require "bundler/setup" require "mini_magick" - require "pry" + require_relative "support/helpers" diff -Nru ruby-mini-magick-4.8.0/debian/patches/remove-unsuported-rspec-features ruby-mini-magick-4.9.2/debian/patches/remove-unsuported-rspec-features --- ruby-mini-magick-4.8.0/debian/patches/remove-unsuported-rspec-features 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/remove-unsuported-rspec-features 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Index: ruby-mini-magick/spec/spec_helper.rb -=================================================================== ---- ruby-mini-magick.orig/spec/spec_helper.rb -+++ ruby-mini-magick/spec/spec_helper.rb -@@ -5,7 +5,6 @@ require "pry" - require_relative "support/helpers" - - RSpec.configure do |config| -- config.disable_monkey_patching! - config.formatter = "documentation" - config.color = true - config.fail_fast = true unless ENV["CI"] diff -Nru ruby-mini-magick-4.8.0/debian/patches/series ruby-mini-magick-4.9.2/debian/patches/series --- ruby-mini-magick-4.8.0/debian/patches/series 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/series 2018-12-27 11:36:03.000000000 +0000 @@ -1,5 +1,3 @@ -#remove-unsuported-rspec-features -fix-quotes-in-tests.patch skip-tests-temporarily.patch remove-rubygems remove-deprecated-test.patch diff -Nru ruby-mini-magick-4.8.0/debian/patches/skip-tests-temporarily.patch ruby-mini-magick-4.9.2/debian/patches/skip-tests-temporarily.patch --- ruby-mini-magick-4.8.0/debian/patches/skip-tests-temporarily.patch 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/patches/skip-tests-temporarily.patch 2018-12-27 11:36:03.000000000 +0000 @@ -16,9 +16,9 @@ - allow(described_class).to receive(:cli).and_return(:graphicsmagick) - expect(described_class.cli_version).to match(/^\d+\.\d+\.\d+$/) - end -+ # it "returns GraphicsMagick's version" do -+ # allow(described_class).to receive(:cli).and_return(:graphicsmagick) -+ # expect(described_class.cli_version).to match(/^\d+\.\d+\.\d+$/) -+ # end ++ # it "returns GraphicsMagick's version" do ++ # allow(described_class).to receive(:cli).and_return(:graphicsmagick) ++ # expect(described_class.cli_version).to match(/^\d+\.\d+\.\d+$/) ++ # end end end diff -Nru ruby-mini-magick-4.8.0/debian/watch ruby-mini-magick-4.9.2/debian/watch --- ruby-mini-magick-4.8.0/debian/watch 2018-03-18 08:20:44.000000000 +0000 +++ ruby-mini-magick-4.9.2/debian/watch 2018-12-27 11:36:03.000000000 +0000 @@ -1,3 +1,2 @@ -version=3 -opts=uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|b|a)\d*)$/$1~$2/,dversionmangle=s/\+(debian|dfsg|ds|deb|gh)\d*$// \ -https://github.com/minimagick/minimagick/tags .*/v?(\d[\d\.]+)\.tar\.gz +version=4 +https://gemwatch.debian.net/mini_magick .*/mini_magick-(.*).tar.gz diff -Nru ruby-mini-magick-4.8.0/install/imagemagick.sh ruby-mini-magick-4.9.2/install/imagemagick.sh --- ruby-mini-magick-4.8.0/install/imagemagick.sh 1970-01-01 00:00:00.000000000 +0000 +++ ruby-mini-magick-4.9.2/install/imagemagick.sh 2018-12-29 13:27:33.000000000 +0000 @@ -0,0 +1,7 @@ +set -e + +curl -O "http://www.imagemagick.org/download/ImageMagick-$IM_VERSION.tar.gz" +tar xzf "ImageMagick-$IM_VERSION.tar.gz" +cd ImageMagick-* +./configure --prefix=/usr +sudo make install diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/configuration.rb ruby-mini-magick-4.9.2/lib/mini_magick/configuration.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/configuration.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/configuration.rb 2018-12-29 13:27:33.000000000 +0000 @@ -8,7 +8,7 @@ # Set whether you want to use [ImageMagick](http://www.imagemagick.org) or # [GraphicsMagick](http://www.graphicsmagick.org). # - # @return [Symbol] `:imagemagick` or `:graphicsmagick` + # @return [Symbol] `:imagemagick`, `:imagemagick7`, or `:graphicsmagick` # attr_accessor :cli # @private (for backwards compatibility) @@ -25,6 +25,17 @@ attr_accessor :processor_path ## + # Adds a prefix to the CLI command. + # For example, you could use `firejail` to run all commands in a sandbox. + # Can be a string, or an array of strings. + # e.g. 'firejail', or ['firejail', '--force'] + # + # @return [String] + # @return [Array] + # + attr_accessor :cli_prefix + + ## # If you don't want commands to take too long, you can set a timeout (in # seconds). # @@ -102,8 +113,14 @@ yield self end + CLI_DETECTION = { + imagemagick: "mogrify", + graphicsmagick: "gm", + imagemagick7: "magick", + } + def processor - @processor ||= ["mogrify", "gm"].detect do |processor| + @processor ||= CLI_DETECTION.values.detect do |processor| MiniMagick::Utilities.which(processor) end end @@ -111,29 +128,24 @@ def processor=(processor) @processor = processor.to_s - unless ["mogrify", "gm"].include?(@processor) + unless CLI_DETECTION.value?(@processor) raise ArgumentError, - "processor has to be set to either \"mogrify\" or \"gm\"" \ + "processor has to be set to either \"magick\", \"mogrify\" or \"gm\"" \ ", was set to #{@processor.inspect}" end end def cli - @cli || - case processor.to_s - when "mogrify" then :imagemagick - when "gm" then :graphicsmagick - else - raise MiniMagick::Error, "ImageMagick/GraphicsMagick is not installed" - end + @cli || CLI_DETECTION.key(processor) or + fail MiniMagick::Error, "You must have ImageMagick or GraphicsMagick installed" end def cli=(value) @cli = value - if not [:imagemagick, :graphicsmagick].include?(@cli) + if not CLI_DETECTION.key?(@cli) raise ArgumentError, - "CLI has to be set to either :imagemagick or :graphicsmagick" \ + "CLI has to be set to either :imagemagick, :imagemagick7 or :graphicsmagick" \ ", was set to #{@cli.inspect}" end end diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/image/info.rb ruby-mini-magick-4.9.2/lib/mini_magick/image/info.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/image/info.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/image/info.rb 2018-12-29 13:27:33.000000000 +0000 @@ -91,7 +91,7 @@ line = line.chomp("\n") case MiniMagick.cli - when :imagemagick + when :imagemagick, :imagemagick7 if match = line.match(/^exif:/) key, value = match.post_match.split("=", 2) value = decode_comma_separated_ascii_characters(value) if ASCII_ENCODED_EXIF_KEYS.include?(key) @@ -100,6 +100,7 @@ hash[hash.keys.last] << "\n#{line}" end when :graphicsmagick + next if line == "unknown" key, value = line.split("=", 2) value.gsub!("\\012", "\n") # convert "\012" characters to newlines hash[key] = value @@ -119,7 +120,7 @@ end def details - warn "[MiniMagick] MiniMagick::Image#details has been deprecated, as it was causing too many parsing errors. You should use MiniMagick::Image#data instead, which differs in a way that the keys are in camelcase." if MiniMagick.imagemagick? + warn "[MiniMagick] MiniMagick::Image#details has been deprecated, as it was causing too many parsing errors. You should use MiniMagick::Image#data instead, which differs in a way that the keys are in camelcase." if MiniMagick.imagemagick? || MiniMagick.imagemagick7? @info["details"] ||= ( details_string = identify(&:verbose) @@ -139,8 +140,8 @@ next end - key, _, value = line.partition(/:[\s\n]/).map(&:strip) - hash = key_stack.inject(details_hash) { |hash, key| hash.fetch(key) } + key, _, value = line.partition(/:[\s]/).map(&:strip) + hash = key_stack.inject(details_hash) { |h, k| h.fetch(k) } if value.empty? hash[key] = {} key_stack.push key diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/shell.rb ruby-mini-magick-4.9.2/lib/mini_magick/shell.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/shell.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/shell.rb 2018-12-29 13:27:33.000000000 +0000 @@ -38,38 +38,36 @@ def execute_open3(command, options = {}) require "open3" - in_w, out_r, err_r, subprocess_thread = Open3.popen3(*command) + # We would ideally use Open3.capture3, but it wouldn't allow us to + # terminate the command after timing out. + Open3.popen3(*command) do |in_w, out_r, err_r, thread| + [in_w, out_r, err_r].each(&:binmode) + stdout_reader = Thread.new { out_r.read } + stderr_reader = Thread.new { err_r.read } + begin + in_w.write options[:stdin].to_s + rescue Errno::EPIPE + end + in_w.close + + begin + Timeout.timeout(MiniMagick.timeout) { thread.join } + rescue Timeout::Error + Process.kill("TERM", thread.pid) rescue nil + Process.waitpid(thread.pid) rescue nil + raise Timeout::Error, "MiniMagick command timed out: #{command}" + end - capture_command(in_w, out_r, err_r, subprocess_thread, options) + [stdout_reader.value, stderr_reader.value, thread.value] + end end def execute_posix_spawn(command, options = {}) require "posix-spawn" - - pid, in_w, out_r, err_r = POSIX::Spawn.popen4(*command) - subprocess_thread = Process.detach(pid) - - capture_command(in_w, out_r, err_r, subprocess_thread, options) - end - - def capture_command(in_w, out_r, err_r, subprocess_thread, options) - [in_w, out_r, err_r].each(&:binmode) - stdout_reader = Thread.new { out_r.read } - stderr_reader = Thread.new { err_r.read } - begin - in_w.write options[:stdin].to_s - rescue Errno::EPIPE - end - in_w.close - - Timeout.timeout(MiniMagick.timeout) { subprocess_thread.join } - - [stdout_reader.value, stderr_reader.value, subprocess_thread.value] - rescue Timeout::Error => error - Process.kill("TERM", subprocess_thread.pid) - raise error - ensure - [out_r, err_r].each(&:close) + child = POSIX::Spawn::Child.new(*command, input: options[:stdin].to_s, timeout: MiniMagick.timeout) + [child.out, child.err, child.status] + rescue POSIX::Spawn::TimeoutExceeded + raise Timeout::Error, "MiniMagick command timed out: #{command}" end def log(command, &block) diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/tool/magick.rb ruby-mini-magick-4.9.2/lib/mini_magick/tool/magick.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/tool/magick.rb 1970-01-01 00:00:00.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/tool/magick.rb 2018-12-29 13:27:33.000000000 +0000 @@ -0,0 +1,14 @@ +module MiniMagick + class Tool + ## + # @see http://www.imagemagick.org/script/command-line-processing.php + # + class Magick < MiniMagick::Tool + + def initialize(*args) + super("magick", *args) + end + + end + end +end diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/tool.rb ruby-mini-magick-4.9.2/lib/mini_magick/tool.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/tool.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/tool.rb 2018-12-29 13:27:33.000000000 +0000 @@ -15,10 +15,8 @@ # class Tool - CREATION_OPERATORS = %w[ - xc canvas logo rose gradient radial-gradient plasma pattern label caption - text - ] + CREATION_OPERATORS = %w[xc canvas logo rose gradient radial-gradient plasma + pattern text pango] ## # Aside from classic instantiation, it also accepts a block, and then @@ -112,7 +110,8 @@ ## # The executable used for this tool. Respects - # {MiniMagick::Configuration#cli} and {MiniMagick::Configuration#cli_path}. + # {MiniMagick::Configuration#cli}, {MiniMagick::Configuration#cli_path}, + # and {MiniMagick::Configuration#cli_prefix}. # # @return [Array] # @@ -121,10 +120,20 @@ # identify = MiniMagick::Tool::Identify.new # identify.executable #=> ["gm", "identify"] # + # @example + # MiniMagick.configure do |config| + # config.cli = :graphicsmagick + # config.cli_prefix = ['firejail', '--force'] + # end + # identify = MiniMagick::Tool::Identify.new + # identify.executable #=> ["firejail", "--force", "gm", "identify"] + # def executable exe = [name] + exe.unshift "magick" if MiniMagick.imagemagick7? && name != "magick" exe.unshift "gm" if MiniMagick.graphicsmagick? exe.unshift File.join(MiniMagick.cli_path, exe.shift) if MiniMagick.cli_path + Array(MiniMagick.cli_prefix).reverse_each { |p| exe.unshift p } if MiniMagick.cli_prefix exe end @@ -285,6 +294,7 @@ require "mini_magick/tool/display" require "mini_magick/tool/identify" require "mini_magick/tool/import" +require "mini_magick/tool/magick" require "mini_magick/tool/mogrify" require "mini_magick/tool/mogrify_restricted" require "mini_magick/tool/montage" diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick/version.rb ruby-mini-magick-4.9.2/lib/mini_magick/version.rb --- ruby-mini-magick-4.8.0/lib/mini_magick/version.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick/version.rb 2018-12-29 13:27:33.000000000 +0000 @@ -8,8 +8,8 @@ module VERSION MAJOR = 4 - MINOR = 8 - TINY = 0 + MINOR = 9 + TINY = 2 PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') diff -Nru ruby-mini-magick-4.8.0/lib/mini_magick.rb ruby-mini-magick-4.9.2/lib/mini_magick.rb --- ruby-mini-magick-4.8.0/lib/mini_magick.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/lib/mini_magick.rb 2018-12-29 13:27:33.000000000 +0000 @@ -31,6 +31,14 @@ end ## + # Checks whether the CLI used is ImageMagick 7. + # + # @return [Boolean] + def self.imagemagick7? + cli == :imagemagick7 + end + + ## # Checks whether the CLI used is GraphicsMagick. # # @return [Boolean] diff -Nru ruby-mini-magick-4.8.0/README.md ruby-mini-magick-4.9.2/README.md --- ruby-mini-magick-4.8.0/README.md 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/README.md 2018-12-29 13:27:33.000000000 +0000 @@ -1,5 +1,6 @@ # MiniMagick - +[![Gem Version](https://img.shields.io/gem/v/mini_magick.svg)](http://rubygems.org/gems/mini_magick) +[![Gem Downloads](https://img.shields.io/gem/dt/mini_magick.svg)](http://rubygems.org/gems/mini_magick) [![Build Status](https://travis-ci.org/minimagick/minimagick.svg?branch=master)](http://travis-ci.org/minimagick/minimagick) [![Code Climate](https://codeclimate.com/github/minimagick/minimagick/badges/gpa.svg)](https://codeclimate.com/github/minimagick/minimagick) @@ -43,14 +44,14 @@ * MRI 2.1 * MRI 2.2 * MRI 2.3 -* Rubinius -* JRuby (1.7.18 and later) +* MRI 2.4 +* JRuby 9k ## Installation Add the gem to your Gemfile: -```ruby +```rb gem "mini_magick" ``` @@ -62,7 +63,9 @@ Let's first see a basic example of resizing an image. -```ruby +```rb +require "mini_magick" + image = MiniMagick::Image.open("input.jpg") image.path #=> "/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/magick20140921-75881-1yho3zc.jpg" image.resize "100x100" @@ -80,7 +83,7 @@ `MiniMagick::Image.open` also accepts URLs, and options passed in will be forwarded to open-uri. -```ruby +```rb image = MiniMagick::Image.open("http://example.com/image.jpg") image.contrast image.write("from_internets.jpg") @@ -89,7 +92,7 @@ On the other hand, if we want the original image to actually *get* modified, we can use `MiniMagick::Image.new`. -```ruby +```rb image = MiniMagick::Image.new("input.jpg") image.path #=> "input.jpg" image.resize "100x100" @@ -103,7 +106,7 @@ command on each methods call. `MiniMagick::Image#combine_options` takes multiple options and from them builds one single command. -```ruby +```rb image.combine_options do |b| b.resize "250x200>" b.rotate "-90" @@ -114,7 +117,7 @@ As a handy shortcut, `MiniMagick::Image.new` also accepts an optional block which is used to `combine_options`. -```ruby +```rb image = MiniMagick::Image.new("input.jpg") do |b| b.resize "250x200>" b.rotate "-90" @@ -129,7 +132,7 @@ A `MiniMagick::Image` has various handy attributes. -```ruby +```rb image.type #=> "JPEG" image.mime_type #=> "image/jpeg" image.width #=> 250 @@ -145,14 +148,14 @@ If you need more control, you can also access [raw image attributes](http://www.imagemagick.org/script/escape.php): -```ruby +```rb image["%[gamma]"] # "0.9" ``` To get the all information about the image, MiniMagick gives you a handy method which returns the output from `identify -verbose` in hash format: -```ruby +```rb image.data #=> # { # "format": "JPEG", @@ -227,7 +230,7 @@ ### Configuration -```ruby +```rb MiniMagick.configure do |config| config.cli = :graphicsmagick config.timeout = 5 @@ -242,7 +245,7 @@ MiniMagick also allows you to [composite](http://www.imagemagick.org/script/composite.php) images: -```ruby +```rb first_image = MiniMagick::Image.new("first.jpg") second_image = MiniMagick::Image.new("second.jpg") result = first_image.composite(second_image) do |c| @@ -274,7 +277,7 @@ safe to assume that all input and output images are valid by default and turn off validation: -```ruby +```rb MiniMagick.configure do |config| config.validate_on_create = false config.validate_on_write = false @@ -283,7 +286,7 @@ You can test whether an image is valid: -```ruby +```rb image.valid? image.validate! # raises MiniMagick::Invalid if image is invalid ``` @@ -292,7 +295,7 @@ You can choose to log MiniMagick commands and their execution times: -```ruby +```rb MiniMagick.logger.level = Logger::DEBUG ``` ``` @@ -308,15 +311,13 @@ ```rb MiniMagick.configure do |config| - config.cli = :graphicsmagick + config.cli = :graphicsmagick # or :imagemagick or :imagemagick7 end ``` -If you're a real ImageMagick guru, you might want to use GraphicsMagick only -for certain processing blocks (because it's more efficient), or vice versa. You -can accomplish this with `.with_cli`: +You can also use `.with_cli` to temporary switch the CLI: -```ruby +```rb MiniMagick.with_cli(:graphicsmagick) do # Some processing that GraphicsMagick is better at end @@ -332,24 +333,31 @@ If you want to be close to the metal, you can use ImageMagick's command-line tools directly. -```ruby -MiniMagick::Tool::Mogrify.new do |mogrify| - mogrify.resize("100x100") - mogrify.negate - mogrify << "image.jpg" -end #=> `mogrify -resize 100x100 -negate image.jpg` +```rb +MiniMagick::Tool::Magick.new do |magick| + magick << "input.jpg" + magick.resize("100x100") + magick.negate + magick << "output.jpg" +end #=> `magick input.jpg -resize 100x100 -negate output.jpg` # OR -mogrify = MiniMagick::Tool::Mogrify.new -mogrify.resize("100x100") -mogrify.negate -mogrify << "image.jpg" -mogrify.call #=> `mogrify -resize 100x100 -negate image.jpg` +convert = MiniMagick::Tool::Convert.new +convert << "input.jpg" +convert.resize("100x100") +convert.negate +convert << "output.jpg" +convert.call #=> `convert input.jpg -resize 100x100 -negate output.jpg` ``` +If you're on ImageMagick 7, you should probably use `MiniMagick::Tool::Magick`, +though the legacy `MiniMagick::Tool::Convert` and friends will work too. On +ImageMagick 6 `MiniMagick::Tool::Magick` won't be available, so you should +instead use `MiniMagick::Tool::Convert` and friends. + This way of using MiniMagick is highly recommended if you want to maximize -performance of your image processing. Here are some of the features. +performance of your image processing. We will now show the features available. #### Appending @@ -366,7 +374,7 @@ Note that it is important that every command you would pass to the command line has to be separated with `<<`, e.g.: -```ruby +```rb # GOOD convert << "-resize" << "500x500" @@ -377,7 +385,7 @@ Shell escaping is also handled for you. If an option has a value that has spaces inside it, just pass it as a regular string. -```ruby +```rb convert << "-distort" convert << "Perspective" convert << "0,0,0,0 0,45,0,45 69,0,60,10 69,45,60,35" @@ -390,7 +398,7 @@ Instead of passing in options directly, you can use Ruby methods: -```ruby +```rb convert.resize("500x500") convert.rotate(90) convert.distort("Perspective", "0,0,0,0 0,45,0,45 69,0,60,10 69,45,60,35") @@ -403,7 +411,7 @@ Every method call returns `self`, so you can chain them to create logical groups. -```ruby +```rb MiniMagick::Tool::Convert.new do |convert| convert << "input.jpg" convert.clone(0).background('gray').shadow('80x5+5+5') @@ -414,7 +422,7 @@ #### "Plus" options -```ruby +```rb MiniMagick::Tool::Convert.new do |convert| convert << "input.jpg" convert.repage.+ @@ -427,7 +435,7 @@ #### Stacks -```ruby +```rb MiniMagick::Tool::Convert.new do |convert| convert << "wand.gif" convert.stack do |stack| @@ -446,7 +454,7 @@ If you want to pass something to standard input, you can pass the `:stdin` option to `#call`: -```ruby +```rb identify = MiniMagick::Tool::Identify.new identify.stdin # alias for "-" identify.call(stdin: image_content) @@ -455,7 +463,7 @@ MiniMagick also has `#stdout` alias for "-" for outputing file contents to standard output: -```ruby +```rb content = MiniMagick::Tool::Convert.new do |convert| convert << "input.jpg" convert.auto_orient @@ -489,7 +497,7 @@ * `MAGICK_TIME_LIMIT=30` For a full list of variables and description, see [ImageMagick's resources -documentation](http://www.imagemagick.org/script/resources.php). +documentation](http://www.imagemagick.org/script/resources.php#environment). ## Troubleshooting Binary files /tmp/tmpvFWSmw/AXldzlyAx8/ruby-mini-magick-4.8.0/spec/fixtures/no_exif.jpg and /tmp/tmpvFWSmw/eFT8jeLL6Z/ruby-mini-magick-4.9.2/spec/fixtures/no_exif.jpg differ diff -Nru ruby-mini-magick-4.8.0/spec/lib/mini_magick/configuration_spec.rb ruby-mini-magick-4.9.2/spec/lib/mini_magick/configuration_spec.rb --- ruby-mini-magick-4.8.0/spec/lib/mini_magick/configuration_spec.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/lib/mini_magick/configuration_spec.rb 2018-12-29 13:27:33.000000000 +0000 @@ -39,20 +39,36 @@ end end + describe "#cli_prefix" do + it "can be assigned" do + subject.cli_prefix = 'firejail' + expect(subject.cli_prefix).to eq 'firejail' + end + end + describe "#processor" do - it "assigns :mogrify by default" do + it "assigns 'mogrify' if ImageMagick 6 is available" do + allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(true) expect(subject.processor).to eq "mogrify" end - it "assigns :gm if ImageMagick is not available" do + it "assigns 'gm' if ImageMagick 6 is not available" do allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(nil) allow(MiniMagick::Utilities).to receive(:which).with("gm").and_return(true) expect(subject.processor).to eq "gm" end + it "assigns 'magick' if ImageMagick 6 and GraphicsMagick are not available" do + allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(nil) + allow(MiniMagick::Utilities).to receive(:which).with("gm").and_return(nil) + allow(MiniMagick::Utilities).to receive(:which).with("magick").and_return(true) + expect(subject.processor).to eq "magick" + end + it "returns nil if neither ImageMagick nor GraphicsMagick are available" do allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(nil) allow(MiniMagick::Utilities).to receive(:which).with("gm").and_return(nil) + allow(MiniMagick::Utilities).to receive(:which).with("magick").and_return(nil) expect(subject.processor).to eq nil end end diff -Nru ruby-mini-magick-4.8.0/spec/lib/mini_magick/image_spec.rb ruby-mini-magick-4.9.2/spec/lib/mini_magick/image_spec.rb --- ruby-mini-magick-4.8.0/spec/lib/mini_magick/image_spec.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/lib/mini_magick/image_spec.rb 2018-12-29 13:27:33.000000000 +0000 @@ -386,15 +386,20 @@ end describe "#exif" do - subject { described_class.new(image_path(:exif)) } - it "returns a hash of EXIF data" do + subject = described_class.new(image_path(:exif)) expect(subject.exif["DateTimeOriginal"]).to be_a(String) end it "decodes the ExifVersion" do + subject = described_class.new(image_path(:exif)) expect(subject.exif["ExifVersion"]).to eq("0220") end unless ENV["CI"] + + it "handles no EXIF data" do + subject = described_class.new(image_path(:no_exif)) + expect(subject.exif).to eq({}) + end end describe "#resolution" do @@ -415,7 +420,12 @@ it "returns a hash of verbose information" do expect(subject.details["Format"]).to match /^JPEG/ if MiniMagick.cli == :imagemagick - expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" + if Gem::Version.new(MiniMagick.cli_version) < Gem::Version.new('7.0.0') + expect(subject.details["Channel depth"]["red"]).to eq "8-bit" + else + expect(subject.details["Channel depth"]["Red"]).to eq "8-bit" + end + expect(subject.details).to have_key("Background color") expect(subject.details["Properties"]).to have_key("date:create") else diff -Nru ruby-mini-magick-4.8.0/spec/lib/mini_magick/shell_spec.rb ruby-mini-magick-4.9.2/spec/lib/mini_magick/shell_spec.rb --- ruby-mini-magick-4.8.0/spec/lib/mini_magick/shell_spec.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/lib/mini_magick/shell_spec.rb 2018-12-29 13:27:33.000000000 +0000 @@ -51,7 +51,7 @@ stdout, stderr, status = subject.execute(%W[identify foo]) expect(stdout).to eq "" - expect(stderr).to match("unable to open image 'foo'") + expect(stderr).to match("unable to open image") expect(status).to eq 1 end @@ -77,7 +77,7 @@ it "terminate long running commands if MiniMagick.timeout is set" do MiniMagick.timeout = 0.1 - expect { subject.execute(%w[sleep 0.2]) }.to raise_error(Timeout::Error) + expect { subject.execute(%w[sleep 1]) }.to raise_error(Timeout::Error) MiniMagick.timeout = nil end diff -Nru ruby-mini-magick-4.8.0/spec/lib/mini_magick/tool_spec.rb ruby-mini-magick-4.9.2/spec/lib/mini_magick/tool_spec.rb --- ruby-mini-magick-4.8.0/spec/lib/mini_magick/tool_spec.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/lib/mini_magick/tool_spec.rb 2018-12-29 13:27:33.000000000 +0000 @@ -56,11 +56,29 @@ expect(subject.executable).to eq %W[gm identify] end + it "prepends 'magick' to the command list when using ImageMagick 7" do + allow(MiniMagick).to receive(:cli).and_return(:imagemagick7) + expect(subject.executable).to eq %W[magick identify] + expect(MiniMagick::Tool::Magick.new.executable).to eq %W[magick] + end + it "respects #cli_path" do allow(MiniMagick).to receive(:cli).and_return(:imagemagick) allow(MiniMagick).to receive(:cli_path).and_return("path/to/cli") expect(subject.executable).to eq %W[path/to/cli/identify] end + + it "respects #cli_prefix as a string" do + allow(MiniMagick).to receive(:cli).and_return(:imagemagick) + allow(MiniMagick).to receive(:cli_prefix).and_return('firejail') + expect(subject.executable).to eq %W[firejail identify] + end + + it "respects #cli_prefix as an array" do + allow(MiniMagick).to receive(:cli).and_return(:imagemagick) + allow(MiniMagick).to receive(:cli_prefix).and_return(['firejail', '--force']) + expect(subject.executable).to eq %W[firejail --force identify] + end end describe "#<<" do diff -Nru ruby-mini-magick-4.8.0/spec/spec_helper.rb ruby-mini-magick-4.9.2/spec/spec_helper.rb --- ruby-mini-magick-4.8.0/spec/spec_helper.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/spec_helper.rb 2018-12-29 13:27:33.000000000 +0000 @@ -1,6 +1,5 @@ require "bundler/setup" require "mini_magick" -require "pry" require_relative "support/helpers" diff -Nru ruby-mini-magick-4.8.0/spec/support/helpers.rb ruby-mini-magick-4.9.2/spec/support/helpers.rb --- ruby-mini-magick-4.8.0/spec/support/helpers.rb 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/spec/support/helpers.rb 2018-12-29 13:27:33.000000000 +0000 @@ -9,6 +9,7 @@ when :png then "engine.png" when :animation, :gif then "animation.gif" when :exif then "exif.jpg" + when :no_exif then "no_exif.jpg" when :empty_identify_line then "empty_identify_line.png" when :badly_encoded_line then "badly_encoded_line.jpg" when :not then "not_an_image.rb" diff -Nru ruby-mini-magick-4.8.0/.travis.yml ruby-mini-magick-4.9.2/.travis.yml --- ruby-mini-magick-4.8.0/.travis.yml 2017-07-06 09:50:52.000000000 +0000 +++ ruby-mini-magick-4.9.2/.travis.yml 2018-12-29 13:27:33.000000000 +0000 @@ -5,15 +5,19 @@ - 2.0 - 2.1 - 2.2 - - 2.3.3 - - 2.4.0 + - 2.3 + - 2.4 + - 2.5 - jruby - ruby-head +env: + - IM_VERSION=7.0.8-11 + - IM_VERSION=6.9.10-11 matrix: allow_failures: - rvm: ruby-head before_install: - sudo apt-get update - - sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev - sudo apt-get install -qq graphicsmagick + - bash install/imagemagick.sh - gem update bundler