pax_global_header00006660000000000000000000000064122447727400014523gustar00rootroot0000000000000052 comment=4884a295544a891571fa63ff55ce7276b857d915 minimagick-3.7.0/000077500000000000000000000000001224477274000136425ustar00rootroot00000000000000minimagick-3.7.0/.gitignore000066400000000000000000000000521224477274000156270ustar00rootroot00000000000000/pkg coverage *.lock .idea .yardoc .rvmrc minimagick-3.7.0/.travis.yml000066400000000000000000000003031224477274000157470ustar00rootroot00000000000000language: ruby rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - ruby-head - ree - jruby-18mode - jruby-19mode - jruby-20mode - jruby-head matrix: allow_failures: - rvm: ruby-head minimagick-3.7.0/Gemfile000066400000000000000000000000471224477274000151360ustar00rootroot00000000000000source "https://rubygems.org" gemspec minimagick-3.7.0/MIT-LICENSE000066400000000000000000000020771224477274000153040ustar00rootroot00000000000000Copyright (c) 2005-2013 Corey Johnson probablycorey@gmail.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. minimagick-3.7.0/README.md000066400000000000000000000104121224477274000151170ustar00rootroot00000000000000# MiniMagick A ruby wrapper for ImageMagick or GraphicsMagick command line. Tested on the following Rubies: MRI 1.8.7, 1.9.2, 1.9.3, 2.0.0, REE, JRuby, Rubinius. [![Build Status](https://secure.travis-ci.org/minimagick/minimagick.png)](http://travis-ci.org/minimagick/minimagick) ## Installation Add the gem to your Gemfile: ```ruby gem "mini_magick" ``` ## Information * [Rdoc](http://rubydoc.info/github/minimagick/minimagick) ## Why? I was using RMagick and loving it, but it was eating up huge amounts of memory. Even a simple script would use over 100MB of Ram. On my local machine this wasn't a problem, but on my hosting server the ruby apps would crash because of their 100MB memory limit. ## Solution! Using MiniMagick the ruby processes memory remains small (it spawns ImageMagick's command line program mogrify which takes up some memory as well, but is much smaller compared to RMagick) MiniMagick gives you access to all the command line options ImageMagick has (Found here http://www.imagemagick.org/script/mogrify.php) ## Examples Want to make a thumbnail from a file... ```ruby image = MiniMagick::Image.open("input.jpg") image.resize "100x100" image.write "output.jpg" ``` Want to make a thumbnail from a blob... ```ruby image = MiniMagick::Image.read(blob) image.resize "100x100" image.write "output.jpg" ``` Got an incoming IOStream? ```ruby image = MiniMagick::Image.read(stream) ``` Want to make a thumbnail of a remote image? ```ruby image = MiniMagick::Image.open("http://www.google.com/images/logos/logo.png") image.resize "5x5" image.format "gif" image.write "localcopy.gif" ``` Need to combine several options? ```ruby image = MiniMagick::Image.open("input.jpg") image.combine_options do |c| c.sample "50%" c.rotate "-90>" end image.write "output.jpg" ``` Want to composite two images? Super easy! (Aka, put a watermark on!) ```ruby image = Image.open("original.png") result = image.composite(Image.open("watermark.png", "jpg")) do |c| c.gravity "center" end result.write "my_output_file.jpg" ``` Want to manipulate an image at its source (You won't have to write it out because the transformations are done on that file) ```ruby image = MiniMagick::Image.new("input.jpg") image.resize "100x100" ``` Want to get some meta-information out? ```ruby image = MiniMagick::Image.open("input.jpg") image[:width] # will get the width (you can also use :height and :format) image["EXIF:BitsPerSample"] # It also can get all the EXIF tags image["%m:%f %wx%h"] # Or you can use one of the many options of the format command ``` For more on the format command see http://www.imagemagick.org/script/command-line-options.php#format Want to composite (merge) two images? ```ruby first_image = MiniMagick::Image.open "first.jpg" second_image = MiniMagick::Image.open "second.jpg" result = first_image.composite(second_image) do |c| c.compose "Over" # OverCompositeOp c.geometry "+20+20" # copy second_image onto first_image from (20, 20) end result.write "output.jpg" ``` ## Thinking of switching from RMagick? Unlike [RMagick](http://rmagick.rubyforge.org), MiniMagick is a much thinner wrapper around ImageMagick. * To piece together MiniMagick commands refer to the [Mogrify Documentation](http://www.imagemagick.org/script/mogrify.php). For instance you can use the `-flop` option as `image.flop`. * Operations on a MiniMagick image tend to happen in-place as `image.trim`, whereas RMagick has both copying and in-place methods like `image.trim` and `image.trim!`. * To open files with MiniMagick you use `MiniMagick::Image.open` as you would `Magick::Image.read`. To open a file and directly edit it, use `MiniMagick::Image.new`. ## Windows Users When passing in a blob or IOStream, Windows users need to make sure they read the file in as binary. ```ruby # This way works on Windows buffer = StringIO.new(File.open(IMAGE_PATH,"rb") { |f| f.read }) MiniMagick::Image.read(buffer) # You may run into problems doing it this way buffer = StringIO.new(File.read(IMAGE_PATH)) ``` ## Using GraphicsMagick Simply set ```ruby MiniMagick.processor = :gm ``` And you are sorted. # Requirements You must have ImageMagick or GraphicsMagick installed. # Caveats Version 3.5 doesn't work in Ruby 1.9.2-p180. If you are running this Ruby version use the 3.4 version of this gem. minimagick-3.7.0/Rakefile000066400000000000000000000005021224477274000153040ustar00rootroot00000000000000require 'bundler' Bundler::GemHelper.install_tasks $:.unshift 'lib' desc 'Default: run unit tests.' task :default => [:print_version, :spec] task :print_version do puts `mogrify --version` end require 'rspec/core/rake_task' desc "Run specs" RSpec::Core::RakeTask.new do |t| t.pattern = "./spec/**/*_spec.rb" end minimagick-3.7.0/lib/000077500000000000000000000000001224477274000144105ustar00rootroot00000000000000minimagick-3.7.0/lib/mini_gmagick.rb000066400000000000000000000000611224477274000173500ustar00rootroot00000000000000require 'mini_magick' MiniMagick.processor = :gm minimagick-3.7.0/lib/mini_magick.rb000066400000000000000000000036641224477274000172150ustar00rootroot00000000000000require 'tempfile' require 'subexec' require 'stringio' require 'pathname' require 'shellwords' require 'mini_magick/command_builder' require 'mini_magick/errors' require 'mini_magick/image' require 'mini_magick/utilities' module MiniMagick class << self attr_accessor :processor attr_accessor :processor_path attr_accessor :timeout ## # Tries to detect the current processor based if any of the processors exist. # Mogrify have precedence over gm by default. # # === Returns # * [String] The detected procesor def choose_processor if MiniMagick::Utilities.which('mogrify').size > 0 self.processor = 'mogrify' elsif MiniMagick::Utilities.which('gm').size > 0 self.processor = "gm" end end ## # Discovers the imagemagick version based on mogrify's output. # # === Returns # * The imagemagick version def image_magick_version @@version ||= Gem::Version.create(`mogrify --version`.split(" ")[2].split("-").first) end ## # The minimum allowed imagemagick version # # === Returns # * The minimum imagemagick version def minimum_image_magick_version @@minimum_version ||= Gem::Version.create("6.6.3") end ## # Checks whether the imagemagick's version is valid # # === Returns # * [Boolean] def valid_version_installed? image_magick_version >= minimum_image_magick_version end ## # Picks the right processor if it isn't set and returns whether it's mogrify or not. # # === Returns # * [Boolean] def mogrify? self.choose_processor if self.processor.nil? self.processor == 'mogrify' end ## # Picks the right processor if it isn't set and returns whether it's graphicsmagick or not. # # === Returns # * [Boolean] def gm? self.choose_processor if self.processor.nil? self.processor == 'gm' end end end minimagick-3.7.0/lib/mini_magick/000077500000000000000000000000001224477274000166575ustar00rootroot00000000000000minimagick-3.7.0/lib/mini_magick/command_builder.rb000066400000000000000000000115451224477274000223360ustar00rootroot00000000000000module MiniMagick class CommandBuilder 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} IMAGE_CREATION_OPERATORS = %w{canvas caption gradient label logo pattern plasma radial radient rose text tile xc } def initialize(tool, *options) @tool = tool @args = [] options.each { |arg| push(arg) } end def command com = "#{@tool} #{args.join(' ')}".strip com = "#{MiniMagick.processor} #{com}" unless MiniMagick.mogrify? com = File.join MiniMagick.processor_path, com unless MiniMagick.processor_path.nil? com.strip end def escape_string_windows(value) # For Windows, ^ is the escape char, equivalent to \ in Unix. escaped = value.gsub(/\^/, '^^').gsub(/>/, '^>') if escaped !~ /^".+"$/ && escaped.include?("'") escaped.inspect else escaped end end def args if !MiniMagick::Utilities.windows? @args.map(&:shellescape) else @args.map { |arg| escape_string_windows(arg) } end end # Add each mogrify command in both underscore and dash format MOGRIFY_COMMANDS.each do |mogrify_command| # Example of what is generated here: # # def auto_orient(*options) # add_command("auto-orient", *options) # self # end # alias_method :"auto-orient", :auto_orient dashed_command = mogrify_command.to_s.gsub("_","-") underscored_command = mogrify_command.to_s.gsub("-","_") define_method(underscored_command) do |*options| add_command(__method__.to_s.gsub("_","-"), *options) self end alias_method dashed_command, underscored_command end def format(*options) raise Error, "You must call 'format' on the image object directly!" end IMAGE_CREATION_OPERATORS.each do |operator| define_method operator do |*options| add_creation_operator(__method__.to_s, *options) self end end def +(*options) push(@args.pop.gsub(/^-/, '+')) if options.any? options.each do |o| push o end end end def add_command(command, *options) push "-#{command}" if options.any? options.each do |o| push o end end end def add_creation_operator(command, *options) creation_command = command if options.any? options.each do |option| creation_command << ":#{option}" end end push creation_command end def push(arg) @args << arg.to_s.strip end alias :<< :push end end minimagick-3.7.0/lib/mini_magick/errors.rb000066400000000000000000000001351224477274000205170ustar00rootroot00000000000000module MiniMagick class Error < RuntimeError; end class Invalid < StandardError; end end minimagick-3.7.0/lib/mini_magick/image.rb000066400000000000000000000366071224477274000203020ustar00rootroot00000000000000module MiniMagick class Image # @return [String] The location of the current working file attr_accessor :path def path_for_windows_quote_space(path) path = Pathname.new(@path).to_s # For Windows, if a path contains space char, you need to quote it, otherwise you SHOULD NOT quote it. # If you quote a path that does not contains space, it will not work. @path.include?(' ') ? path.inspect : path end def path MiniMagick::Utilities.windows? ? path_for_windows_quote_space(@path) : @path end def path=(path) @path = path end # Class Methods # ------------- class << self # This is the primary loading method used by all of the other class methods. # # Use this to pass in a stream object. Must respond to Object#read(size) or be a binary string object (BLOBBBB) # # As a change from the old API, please try and use IOStream objects. They are much, much better and more efficient! # # Probably easier to use the #open method if you want to open a file or a URL. # # @param stream [IOStream, String] Some kind of stream object that needs to be read or is a binary String blob! # @param ext [String] A manual extension to use for reading the file. Not required, but if you are having issues, give this a try. # @return [Image] def read(stream, ext = nil) if stream.is_a?(String) stream = StringIO.new(stream) elsif stream.is_a?(StringIO) # Do nothing, we want a StringIO-object elsif stream.respond_to? :path if File.respond_to?(:binread) stream = StringIO.new File.binread(stream.path.to_s) else stream = StringIO.new File.open(stream.path.to_s,"rb") { |f| f.read } end end create(ext) do |f| while chunk = stream.read(8192) f.write(chunk) end end end # @deprecated Please use Image.read instead! def from_blob(blob, ext = nil) warn "Warning: MiniMagick::Image.from_blob method is deprecated. Instead, please use Image.read" create(ext) { |f| f.write(blob) } end # Creates an image object from a binary string blob which contains raw pixel data (i.e. no header data). # # === Returns # # * [Image] The loaded image. # # === Parameters # # * [blob] String -- Binary string blob containing raw pixel data. # * [columns] Integer -- Number of columns. # * [rows] Integer -- Number of rows. # * [depth] Integer -- Bit depth of the encoded pixel data. # * [map] String -- A code for the mapping of the pixel data. Example: 'gray' or 'rgb'. # * [format] String -- The file extension of the image format to be used when creating the image object. Defaults to 'png'. # def import_pixels(blob, columns, rows, depth, map, format="png") # Create an image object with the raw pixel data string: image = create(".dat", validate = false) { |f| f.write(blob) } # Use ImageMagick to convert the raw data file to an image file of the desired format: converted_image_path = image.path[0..-4] + format arguments = ["-size", "#{columns}x#{rows}", "-depth", "#{depth}", "#{map}:#{image.path}", "#{converted_image_path}"] cmd = CommandBuilder.new("convert", *arguments) #Example: convert -size 256x256 -depth 16 gray:blob.dat blob.png image.run(cmd) # Update the image instance with the path of the properly formatted image, and return: image.path = converted_image_path image end # Opens a specific image file either on the local file system or at a URI. # # Use this if you don't want to overwrite the image file. # # Extension is either guessed from the path or you can specify it as a second parameter. # # If you pass in what looks like a URL, we require 'open-uri' before opening it. # # @param file_or_url [String] Either a local file path or a URL that open-uri can read # @param ext [String] Specify the extension you want to read it as # @return [Image] The loaded image def open(file_or_url, ext = nil) file_or_url = file_or_url.to_s # Force it to be a String... hell or highwater if file_or_url.include?("://") require 'open-uri' ext ||= File.extname(URI.parse(file_or_url).path) Kernel::open(file_or_url) do |f| self.read(f, ext) end else ext ||= File.extname(file_or_url) File.open(file_or_url, "rb") do |f| self.read(f, ext) end end end # @deprecated Please use MiniMagick::Image.open(file_or_url) now def from_file(file, ext = nil) warn "Warning: MiniMagick::Image.from_file is now deprecated. Please use Image.open" open(file, ext) end # Used to create a new Image object data-copy. Not used to "paint" or that kind of thing. # # Takes an extension in a block and can be used to build a new Image object. Used # by both #open and #read to create a new object! Ensures we have a good tempfile! # # @param ext [String] Specify the extension you want to read it as # @param validate [Boolean] If false, skips validation of the created image. Defaults to true. # @yield [IOStream] You can #write bits to this object to create the new Image # @return [Image] The created image def create(ext = nil, validate = true, &block) begin tempfile = Tempfile.new(['mini_magick', ext.to_s.downcase]) tempfile.binmode block.call(tempfile) tempfile.close image = self.new(tempfile.path, tempfile) if validate and !image.valid? raise MiniMagick::Invalid end return image ensure tempfile.close if tempfile end end end # Create a new MiniMagick::Image object # # _DANGER_: The file location passed in here is the *working copy*. That is, it gets *modified*. # you can either copy it yourself or use the MiniMagick::Image.open(path) method which creates a # temporary file for you and protects your original! # # @param input_path [String] The location of an image file # @todo Allow this to accept a block that can pass off to Image#combine_options def initialize(input_path, tempfile = nil) @path = input_path @tempfile = tempfile # ensures that the tempfile will stick around until this image is garbage collected. end # Checks to make sure that MiniMagick can read the file and understand it. # # This uses the 'identify' command line utility to check the file. If you are having # issues with this, then please work directly with the 'identify' command and see if you # can figure out what the issue is. # # @return [Boolean] def valid? run_command("identify", path) true rescue MiniMagick::Invalid false end # A rather low-level way to interact with the "identify" command. No nice API here, just # the crazy stuff you find in ImageMagick. See the examples listed! # # @example # image["format"] #=> "TIFF" # image["height"] #=> 41 (pixels) # image["width"] #=> 50 (pixels) # image["colorspace"] #=> "DirectClassRGB" # image["dimensions"] #=> [50, 41] # image["size"] #=> 2050 (bits) # image["original_at"] #=> 2005-02-23 23:17:24 +0000 (Read from Exif data) # image["EXIF:ExifVersion"] #=> "0220" (Can read anything from Exif) # # @param format [String] A format for the "identify" command # @see For reference see http://www.imagemagick.org/script/command-line-options.php#format # @return [String, Numeric, Array, Time, Object] Depends on the method called! Defaults to String for unknown commands def [](value) # Why do I go to the trouble of putting in newlines? Because otherwise animated gifs screw everything up case value.to_s when "colorspace" run_command("identify", "-format", '%r\n', path).split("\n")[0].strip when "format" run_command("identify", "-format", '%m\n', path).split("\n")[0] when "height" run_command("identify", "-format", '%h\n', path).split("\n")[0].to_i when "width" run_command("identify", "-format", '%w\n', path).split("\n")[0].to_i when "dimensions" run_command("identify", "-format", MiniMagick::Utilities.windows? ? '"%w %h\n"' : '%w %h\n', path).split("\n")[0].split.map{|v|v.to_i} when "size" File.size(path) # Do this because calling identify -format "%b" on an animated gif fails! when "original_at" # Get the EXIF original capture as a Time object Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil when /^EXIF\:/i result = run_command('identify', '-format', "%[#{value}]", path).chomp if result.include?(",") read_character_data(result) else result end else run_command('identify', '-format', value, path).split("\n")[0] end end # Sends raw commands to imagemagick's `mogrify` command. The image path is automatically appended to the command. # # Remember, we are always acting on this instance of the Image when messing with this. # # @return [String] Whatever the result from the command line is. May not be terribly useful. def <<(*args) run_command("mogrify", *args << path) end # This is used to change the format of the image. That is, from "tiff to jpg" or something like that. # Once you run it, the instance is pointing to a new file with a new extension! # # *DANGER*: This renames the file that the instance is pointing to. So, if you manually opened the # file with Image.new(file_path)... then that file is DELETED! If you used Image.open(file) then # you are ok. The original file will still be there. But, any changes to it might not be... # # Formatting an animation into a non-animated type will result in ImageMagick creating multiple # pages (starting with 0). You can choose which page you want to manipulate. We default to the # first page. # # If you would like to convert between animated formats, pass nil as your # page and ImageMagick will copy all of the pages. # # @param format [String] The target format... like 'jpg', 'gif', 'tiff', etc. # @param page [Integer] If this is an animated gif, say which 'page' you want # with an integer. Default 0 will convert only the first page; 'nil' will # convert all pages. # @return [nil] def format(format, page = 0) c = CommandBuilder.new('mogrify', '-format', format) yield c if block_given? if page c << "#{path}[#{page}]" else c << path end run(c) old_path = path self.path = path.sub(/(\.\w*)?$/, ".#{format}") File.delete(old_path) if old_path != path unless File.exists?(path) raise MiniMagick::Error, "Unable to format to #{format}" end end # Collapse images with sequences to the first frame (ie. animated gifs) and # preserve quality def collapse! run_command("mogrify", "-quality", "100", "#{path}[0]") end # Writes the temporary file out to either a file location (by passing in a String) or by # passing in a Stream that you can #write(chunk) to repeatedly # # @param output_to [IOStream, String] Some kind of stream object that needs to be read or a file path as a String # @return [IOStream, Boolean] If you pass in a file location [String] then you get a success boolean. If its a stream, you get it back. # Writes the temporary image that we are using for processing to the output path def write(output_to) if output_to.kind_of?(String) || !output_to.respond_to?(:write) FileUtils.copy_file path, output_to run_command "identify", MiniMagick::Utilities.windows? ? path_for_windows_quote_space(output_to.to_s) : output_to.to_s # Verify that we have a good image else # stream File.open(path, "rb") do |f| f.binmode while chunk = f.read(8192) output_to.write(chunk) end end output_to end end # Gives you raw image data back # @return [String] binary string def to_blob f = File.new path f.binmode f.read ensure f.close if f end def mime_type format = self[:format] "image/" + format.to_s.downcase end # If an unknown method is called then it is sent through the mogrify program # Look here to find all the commands (http://www.imagemagick.org/script/mogrify.php) def method_missing(symbol, *args) combine_options do |c| c.send(symbol, *args) end end # You can use multiple commands together using this method. Very easy to use! # # @example # image.combine_options do |c| # c.draw "image Over 0,0 10,10 '#{MINUS_IMAGE_PATH}'" # c.thumbnail "300x500>" # c.background background # end # # @yieldparam command [CommandBuilder] def combine_options(tool = "mogrify", &block) c = CommandBuilder.new(tool) c << path if tool.to_s == "convert" block.call(c) c << path run(c) end def composite(other_image, output_extension = 'jpg', &block) begin second_tempfile = Tempfile.new(output_extension) second_tempfile.binmode ensure second_tempfile.close end command = CommandBuilder.new("composite") block.call(command) if block command.push(other_image.path) command.push(self.path) command.push(second_tempfile.path) run(command) return Image.new(second_tempfile.path, second_tempfile) end def run_command(command, *args) if command == 'identify' args.unshift '-ping' # -ping "efficiently determine image characteristics." args.unshift '-quiet' if MiniMagick.mogrify? # graphicsmagick has no -quiet option. end run(CommandBuilder.new(command, *args)) end def run(command_builder) command = command_builder.command sub = Subexec.run(command, :timeout => MiniMagick.timeout) if sub.exitstatus != 0 # Clean up after ourselves in case of an error destroy! # Raise the appropriate error if sub.output =~ /no decode delegate/i || sub.output =~ /did not return an image/i raise Invalid, sub.output else # TODO: should we do something different if the command times out ...? # its definitely better for logging.. otherwise we dont really know raise Error, "Command (#{command.inspect.gsub("\\", "")}) failed: #{{:status_code => sub.exitstatus, :output => sub.output}.inspect}" end else sub.output end end def destroy! return if @tempfile.nil? File.unlink(path) if File.exists?(path) @tempfile = nil end private # Sometimes we get back a list of character values def read_character_data(list_of_characters) chars = list_of_characters.gsub(" ", "").split(",") result = "" chars.each do |val| result << ("%c" % val.to_i) end result end end end minimagick-3.7.0/lib/mini_magick/utilities.rb000066400000000000000000000014771224477274000212300ustar00rootroot00000000000000require 'rbconfig' module MiniMagick module Utilities class << self # Cross-platform way of finding an executable in the $PATH. # # which('ruby') #=> /usr/bin/ruby def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe } end return nil end # Finds out if the host OS is windows def windows? RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ end def windows_escape(cmdline) '"' + cmdline.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"' end end end end minimagick-3.7.0/lib/mini_magick/version.rb000066400000000000000000000000521224477274000206660ustar00rootroot00000000000000module MiniMagick VERSION = "3.7.0" end minimagick-3.7.0/mini_magick.gemspec000066400000000000000000000020071224477274000174550ustar00rootroot00000000000000# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "mini_magick/version" Gem::Specification.new do |s| s.name = "mini_magick" s.version = MiniMagick::VERSION s.platform = Gem::Platform::RUBY s.summary = "Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick" s.description = "" s.requirements << "You must have ImageMagick or GraphicsMagick installed" s.authors = ["Corey Johnson", "Hampton Catlin", "Peter Kieltyka"] s.email = ["probablycorey@gmail.com", "hcatlin@gmail.com", "peter@nulayer.com"] s.homepage = "https://github.com/minimagick/minimagick" s.files = Dir['README.rdoc', 'VERSION', 'MIT-LICENSE', 'Rakefile', 'lib/**/*'] s.test_files = Dir['test/**/*'] s.require_paths = ["lib"] s.add_runtime_dependency('subexec', ['~> 0.2.1']) s.add_development_dependency('rake') s.add_development_dependency('test-unit') s.add_development_dependency('rspec') s.add_development_dependency('mocha') end minimagick-3.7.0/spec/000077500000000000000000000000001224477274000145745ustar00rootroot00000000000000minimagick-3.7.0/spec/files/000077500000000000000000000000001224477274000156765ustar00rootroot00000000000000minimagick-3.7.0/spec/files/actually_a_gif.jpg000066400000000000000000000052351224477274000213500ustar00rootroot00000000000000GIF89a2    #  !!"!# $!%($)$ )'*++%,% ,),* ,*,,-*"-3.01322-3&3)3+#3-441#44 5%5.+53627539+96 96:5:8 :8;,#;3+<$<%<2$= = =9?" ?81@< A$A<A=B-!B61CC&C4%C6*C9#D*DA;E9,E;2E@EAGF@HCJ,J8&JD%K2$K6*K:+K<2L0L9LG@MB6MF-MJFMLINE9P.POLQ@,QF;R+RL%RQMS4%S7(S<0SA3T1T;+TH,bOBc`]d@.dD2dJ9dZJd]fa@i?*i]Qi^JjC.jcDkE2kbSkgalI4lM;lVHlbJleZlicnQCnYEnojoqepF4pcXqI5qQ7qoirUBreTrkKsmTtM9tZFtrmuQ;v\HvqTxN9y]Jyumzt[zva{S=|cQ|tT|zc|{t|}j}V@}Y:}YB}n]}p~x]aMkU?W@vU}uhxWj]HfScV7\D~^bKczaGcz^FgPkYp^cJjTfLhNkR{mSqVxsY! ,2،[9lĈq*BŎ(Rá@Xq"940b0q[s BQX*̙F.p§A2>5.E *T$Yv0"Pmx$\bV˖'k'P0ATp1W7t0ajOQ5&7T P ) ]xR%Jo-'94i0kD T摰uٓo[G'uu~{!oLoéP9C:icty)˗_ ӛ%Đ26L;DvYn qRL`BEh%B6LrMtaSݧYo! 0a2$CI"M0.1Toa^9P)ȱ#26#XZ#%WnwV p[+t䃘mE/踃N( ,p)!uf 8P4I#6| ]0a'> 9i~H(p 2uZ&]Ŝb(h  ]p -\.fE1h798ו*WI'<@FWi!`b9U:cD TB"iR̨Xh2L!hAo(´WQMa l_fH w .I"Δ3 *;}R %G>LEm25h SX B ,|F\̃J*ݙ! 0ބxNp%MF.ư#Jx" Ҁ;D lW]Ԅ7aA8CO.p ;pQQ00J= +gpy8`4CE 0:C>< It@.T@\'CM6[F41DE``.Î:P4:! |! ,2 l-P6lİqI RpAŎ.iʨP.AE 1#H `brp[AS9RDPmh/帣`7gG\vvmWw[)(pOE(l1 :!MtD.DSue7wDLp ZhA!H)|l )4G M^\#p1Tr-(!>hA6V%_[20m( s CȠ" )#XBU p]DQ=q 4(r$<…"6PCn eW XjpppĢ5Τmt o6WGP=u t 0\Ȓp#4P\2,!LE!1uYv!J0^AD!0OȑEq#u  ]GU \ A 6@#L!-T|-G vtK8 b%҅ nHK(pGËqh+!tAٝ-ABV4A@&%@x!Ռ AN6D88aevxMjSa sa 3#,p8C >3M6UXc{8vXC7Ѓ>LCz>HDRF.1[cY0X@N찃H$߈3hI1_  ;minimagick-3.7.0/spec/files/animation.gif000066400000000000000000000234421224477274000203510ustar00rootroot00000000000000GIF89add # # ( )  '   9 * #   2  $ *0    !AI +41"B!):+2:B1"*>+BI29!/$R!!C"K   !: 3(@*V  1 9"""#"""")"!3"":"#B"#I##-R#.X$(C$)K$1L$2\% % %% +%1S& #'(<'5b()))")!)%9)'C)+J),R***!$**<*2T*:j+ +")+$2++C+:Z,,9S-(4-1J-4Y-Pj>T?KhA-1A.,A0-A6JB23BC[C39C5CC9;CCWCIdCKhD9KDEaDGhDJrE;@E>REI^FSsFZwH49I52I>JIEWIF]II\ILjJ4.J83JJcK::K:AKQkKTqLYxNXuORgP60PTmPgQ;5Q<5GVSuk orI:n VCʓA2un=S}Uan.<$]ǎ]8#"M?\zɉࠁr]/TQ(uB]!ItAQy h^{-|_ad\QGQwM nd4IQ"Xa8⸜ :pԡ^Iu4Fx $$%hD^5S:xO)&nE"W{]yC!C`rTPӍ\#^a9&Ds hQ?Uȣ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 |`dM_{2regw4ţH=e|ֻYuZױ5r+,]̀\}i}C`M`(p(B& YL2214{Q غ ۼ@ Jڹ٥ԵÉ0͠H-P O.V-si Ӱ{A~ͯmq)#희ֽ/p/kޒa J]t-]k߭jG;minimagick-3.7.0/spec/files/composited.jpg000066400000000000000000000103171224477274000205500ustar00rootroot00000000000000JFIFHHExifMM*  (12<ԇiFUJIFILMFinePix A340 HHQuickTime 7.0.42006:04:05 22:06:54Mac OS X 10.4.5^f"'d0220n     Ơ0100 ΢֢  <2005:02:23 23:17:242005:02:23 23:17:24{d9  XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmC      C   " "!1#1!a ?N?N}w 58bcʦT~pFOOݚZPcYU> 1iZB4y4qHdDn{minimagick-3.7.0/spec/files/erroneous.jpg000066400000000000000000000051531224477274000204250ustar00rootroot00000000000000JFIFHH^Photoshop 3.08BIM%Z%GFPixelmator 1.6.78BIM%vqf~Cƛ@ICC_PROFILE0appl mntrRGB XYZ   acspAPPLappl-appl dscmdescogXYZlwtptrXYZbXYZrTRCcprt8chad,gTRCbTRCmluc enUS&~esES&daDK.deDE,fiFI(frFU(*itIT(VnlNL(nbNO&ptBR&svSE&jaJPRkoKR@zhTWlzhCNruRU"plPL,Yleinen RGB-profiiliGenerisk RGB-profilProfil Gnrique RVBN, RGB 000000u( RGB r_icϏPerfil RGB GenricoAllgemeines RGB-Profilfn RGB cϏeNGenerel RGB-beskrivelseAlgemeen RGB-profiel| RGB \ |Profilo RGB GenericoGeneric RGB Profile1I89 ?@>D8;L RGBUniwersalny profil RGBdescGeneric RGB ProfileGeneric RGB ProfileXYZ Zus4XYZ RXYZ tM=XYZ (6curvtextCopyright 2007 Apple Inc., all rights reserved.sf32 B&lExifMM*bj(1r2iHHPixelmator 1.6.72012-01-17 14:10:58 +0100  xhttp://ns.adobe.com/xap/1.0/ CC  }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?( minimagick-3.7.0/spec/files/leaves (spaced).tiff000066400000000000000000000211341224477274000213710ustar00rootroot00000000000000MM*.w<F :# ?A wd P 1U&™9@kDct 6yp @Ԋf@1s @Iv=4 .0B0`T>a{YPx ;6IO"I0!oK(ڥ@72ʤR(]iP( =rˍ~:֖i#` w \"ɅfwD{h䋘G!r.jp"utݬ8JA|3@Rl}D ")`"{H8 g iGz)ay`xQ x.vQKHJq ~ C&@|ИQ(Ts(٦lJ@P=a^d.* `-o@$Gt0  ;;b7}Q` 20 6ޛ'BuX*p W8T!&5Z}ɺ 4F@nul(J `qNb#jGlc~!D+@M ~3SɤM$ov!@C m0f RyiyGN"a UفD{At%+'ʥKh`R@Rxn 0"fі ;RM%j斨&H 2 "4U `1;ט 8a[O騆 Ƙ] @&Q>BGF\I;/M4 >PøpB<- Z 1xl ziy0 |Eh#>M@89 TTX\qd` ,,C%\$4),RYt*>1;R4m 0 Hy @lǩ}#i\EPB`$!MIQH*L) ~Vp'CG-u@9@xQaG-PUUp.@)#ܚPAI0(LOD;X#E68r5&XP0dH!N,nj.Gf`$ChCnsŒ*K z&]@~miqNɩ-T@ C92%ny Nr41XceG p($  _]p S&>*F."? z&^H&ݏaRecI:DxjNa1 R  z$x_@6u;8*斆"fg^>,.C !&@V6aĔtAD:, 0Ȗa\O\Bd`6BCE#⡃Ba#2C $$@b"j  $-!Y ͦ!a8BRBD 4!A sz!& .@rG8@#B$5`- ~F¿v@.t@$1X# A^ k #k4(" V"X~aa?`@:G!*T2`ª" &1J&6Bb8JD9gJAdȾCJfH< 0&xa9)~c-+r8N B [@D܅Bb"0C$!ST|#d (@8 J6``n„!0,v&Y41 cAz%va~ dHe qCf r:h>*#eXd6k>| :@ d0CA"a@4/To ʍ#v<"ǜEBD G ^8 2`&-fb1`4`6`!<|VZJ&`c49bT$ᤨ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)9}!)lsF+lG@+`MǓ0&]̀Ǔp21 )@S{cm41 SAEB@ wN@ZI)KM; h4 TP jcن )d{q=l1ln`*^s(|sL |Xb?-8 ʮ~.2*`| +'u *@+@ PJIL *bbZtm*`471眮tgE :Dx"Pgdʧ`qg((!8wT-zjJ!O偙B |+ %`W*` 5v+(,'IJ3e)?Mht)A~,'@:(aA]]Q*b,C`i> SH [:y`,$ga>@*ik 5牿z8@) 겛zěri<**xsPv# Y l)I~:Hʮy ", gʔh(8t@gyҸ> P'i`p viej6ۙ&4r&+( x v:^f@Tp8* ҩr9I# ieMKhBJv|A@* ?7O ˜82i*CĔѴ@D@pm \ Gl4H6tXNrѭq>`,U2 @ * qsq@YHduEt$$eHo`0Zi&zG+< &aSJl@@phRcPmR8~%pғ8 8|$V;(!8 I^80 lțJ`0G}!GVg3x,Px7(|gVH,xr>?{ NN푴`d0i\Z :rJ@.3uC4@h<hHvlRq``H`l{ M4aap 80'aG<]mkRHne ;5+QS@Cy07qE*gX;Gund3S?+ PAqcAp"$#@iZӤ @l2ƸQ4𰇐&{6OR?6(o@$:ypL =پB]!'9ԔSq*e+v7l N+Q( à 4Uɘ>=Bh`-*Þ=m `h/Y2 "R |- 7@@2) )%(=RS$s0,HH0appl mntrRGB XYZ   acspAPPLappl-appl dscmdescogXYZlwtptrXYZbXYZrTRCcprt8chad,gTRCbTRCmluc enUS&~esES&daDK.deDE,fiFI(frFU(*itIT(VnlNL(nbNO&ptBR&svSE&jaJPRkoKR@zhTWlzhCNruRU"plPL,Yleinen RGB-profiiliGenerisk RGB-profilProfil Gnrique RVBN, RGB 000000u( RGB r_icϏPerfil RGB GenricoAllgemeines RGB-Profilfn RGB cϏeNGenerel RGB-beskrivelseAlgemeen RGB-profiel| RGB \ |Profilo RGB GenericoGeneric RGB Profile1I89 ?@>D8;L RGBUniwersalny profil RGBdescGeneric RGB ProfileGeneric RGB ProfileXYZ Zus4XYZ RXYZ tM=XYZ (6curvtextCopyright 2007 Apple Inc., all rights reserved.sf32 B&lminimagick-3.7.0/spec/files/not_an_image.php000066400000000000000000000000351224477274000210250ustar00rootroot00000000000000minimagick-3.7.0/spec/files/png.png000066400000000000000000000002211224477274000171630ustar00rootroot00000000000000PNG  IHDRaXIDAT8cdUrLhf````ĥ9(Hь kF`u @ 5`X3/c$a12000mIENDB`minimagick-3.7.0/spec/files/simple-minus.gif000066400000000000000000000024751224477274000210170ustar00rootroot00000000000000GIF89aګןŜүϳбáģͨӦԩӭδͷӱֳذ̥ͬϭխڭѬij˲Դسƪͻеڶҹۺ׹翹п–ĜΞãʥ΢̫óƾ̾͵é¼Ļߵຌć́ڎѕśƐ˕Λ̋Ӆ܎ܕ՜՗ښ؝ݹǭťϠɯɴͥҪӫѤ٬ޱֶڢ⦹㫽Ļնںܿޯ!,q۶Mܰa;M0a "،ܪ*TW ZQX#:s=x٪T ܕAXƊ*gc%t(kyɍ\!4mV,F"c͐%CJ٫WΨeR)TĂm)'aDӊC')Ҝ^ Ç$3M;IɍRHF-2HX0MM@5 Bb9; n̠Y"<(]Jw lPK ԒB$d 5u!Ȃ=܀CrU2Q4 9D!z`)Q|XPA}a P(Aw$p#xq + )dxb0 '|!tb3 3.X'6CK | 2X6~jP5$#XH ˆ#(HIS `b̥V3Kr`  YK| ms 'b Y'2:;minimagick-3.7.0/spec/files/simple.gif000066400000000000000000000111431224477274000176560ustar00rootroot00000000000000GIF89a7TtvwnYM,`J5׫hn'褤yؒNQԊEFu;siV򓅖qnkQNmjvd{6xf/WͶdrɹjsvMXn=vNHSL튋Ux:u7Q%[ҵ(o7/ȟ@ʧղ,/Dq,6!ԗ%Gcy7'0qjMͅu4%büf\1*iɯO&xҠýF7V}cZKR?k̏6*F[DLUHYE x|րL2j)1TDKcU\I;sؼ}リwV>򢉆¤dU-O8wek=&ϝnak_:`l퐖{%i]K L$J2obk}sd:AÿZ3;⚁l_L?u˽l׉ƴ곳 =]A5(ݬ۱Ǯюᛲ!,7 H*\ȰÇ#JHŋ3jȱGp@)}\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000000000000000000110151224477274000200560ustar00rootroot00000000000000JFIFHH XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmExifMM*  (12<ԇiFUJIFILMFinePix A340 HHQuickTime 7.0.42006:04:05 22:06:54Mac OS X 10.4.5^f"'d0220n     Ơ0100 ΢֢  <2005:02:23 23:17:242005:02:23 23:17:24{d9 C     C   " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?coּ ্ϊu-ƹht7p*RR]@B8k!]*Fd)i|J(.2u).d;qXHBominimagick-3.7.0/spec/files/trogdor_capitalized.JPG000066400000000000000000000110151224477274000222670ustar00rootroot00000000000000JFIFHH XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmExifMM*  (12<ԇiFUJIFILMFinePix A340 HHQuickTime 7.0.42006:04:05 22:06:54Mac OS X 10.4.5^f"'d0220n     Ơ0100 ΢֢  <2005:02:23 23:17:242005:02:23 23:17:24{d9 C     C   " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?coּ ্ϊu-ƹht7p*RR]@B8k!]*Fd)i|J(.2u).d;qXHBominimagick-3.7.0/spec/lib/000077500000000000000000000000001224477274000153425ustar00rootroot00000000000000minimagick-3.7.0/spec/lib/mini_magick/000077500000000000000000000000001224477274000176115ustar00rootroot00000000000000minimagick-3.7.0/spec/lib/mini_magick/command_builder_spec.rb000066400000000000000000000100041224477274000242670ustar00rootroot00000000000000require 'spec_helper' # All tests tagged as `ported` are ported from # testunit tests and are there for backwards compatibility MiniMagick.processor = 'mogrify' describe MiniMagick::CommandBuilder do before(:each) do @processor = MiniMagick.processor @processor_path = MiniMagick.processor_path end after(:each) do MiniMagick.processor_path = @processor_path MiniMagick.processor = @processor end describe "ported from testunit", :ported => true do let(:builder){ MiniMagick::CommandBuilder.new('test') } it "builds a basic command" do builder.resize "30x40" builder.args.join(" ").should == '-resize 30x40' end it "builds a full command" do builder.resize "30x40" builder.command.should == "test -resize 30x40" end describe 'windows only', :if => MiniMagick::Utilities.windows? do it "builds a complicated command" do builder.resize "30x40" builder.alpha '1 3 4' builder.resize 'mome fingo' builder.args.join(" ").should == '-resize 30x40 -alpha 1 3 4 -resize mome fingo' end it "builds a command with multiple options and plus modifier" do builder.distort.+ 'srt', '0.6 20' builder.args.join(" ").should == '+distort srt 0.6 20' end it "sets a colorspace correctly" do builder.set 'colorspace RGB' builder.command.should == 'test -set colorspace RGB' end end describe 'not windows', :if => !MiniMagick::Utilities.windows? do it "builds a complicated command" do builder.resize "30x40" builder.alpha '1 3 4' builder.resize 'mome fingo' builder.args.join(" ").should == '-resize 30x40 -alpha 1\ 3\ 4 -resize mome\ fingo' end it "sets a colorspace correctly" do builder.set 'colorspace RGB' builder.command.should == 'test -set colorspace\ RGB' end it "builds a command with multiple options and plus modifier" do builder.distort.+ 'srt', '0.6 20' builder.args.join(" ").should == '\+distort srt 0.6\ 20' end end it "raises error when command is invalid" do expect do command = MiniMagick::CommandBuilder.new('test', 'path') command.input 2 end.to raise_error(NoMethodError) end it "builds a dashed command" do builder.auto_orient builder.args.join(" ").should == '-auto-orient' end it "builds a dashed command via send" do builder.send('auto-orient') builder.args.join(' ').should == '-auto-orient' end it "builds a canvas command" do builder.canvas 'black' builder.args.join(' ').should == 'canvas:black' end it "sets a processor path correctly" do MiniMagick.processor_path = "/a/strange/path" builder.auto_orient builder.command.should == "/a/strange/path/test -auto-orient" end it "builds a processor path with processor" do MiniMagick.processor_path = "/a/strange/path" MiniMagick.processor = "processor" builder.auto_orient builder.command.should == "/a/strange/path/processor test -auto-orient" end end context 'deprecated' do let(:builder){ MiniMagick::CommandBuilder.new('test') } before(:each) { MiniMagick.processor = nil } it "builds a full command" do builder.resize "30x40" builder.command.should == "test -resize 30x40" end describe 'windows only', :if => MiniMagick::Utilities.windows? do it "sets a colorspace correctly" do builder.set 'colorspace RGB' builder.command.should == 'test -set colorspace RGB' end end describe 'not windows', :if => !MiniMagick::Utilities.windows? do it "sets a colorspace correctly" do builder.set 'colorspace RGB' builder.command.should == 'test -set colorspace\ RGB' end end it "sets a processor path correctly" do MiniMagick.processor_path = "/a/strange/path" builder.auto_orient builder.command.should == "/a/strange/path/test -auto-orient" end end end minimagick-3.7.0/spec/lib/mini_magick/image_spec.rb000066400000000000000000000255701224477274000222430ustar00rootroot00000000000000require 'spec_helper' require 'pathname' require 'tempfile' MiniMagick.processor = 'mogrify' describe MiniMagick::Image do describe "ported from testunit", :ported => true do it 'reads image from blob' do File.open(SIMPLE_IMAGE_PATH, "rb") do |f| image = MiniMagick::Image.read(f.read) image.valid?.should be true image.destroy! end end it 'reads image from tempfile', :if => !MiniMagick::Utilities.windows? do tempfile = Tempfile.new('magick') File.open(SIMPLE_IMAGE_PATH, 'rb') do |f| tempfile.write(f.read) tempfile.rewind end image = MiniMagick::Image.read(tempfile) image.valid?.should be true image.destroy! end it 'opens image' do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image.valid?.should be true image.destroy! end it 'reads image from buffer' do buffer = StringIO.new File.open(SIMPLE_IMAGE_PATH,"rb") { |f| f.read } image = MiniMagick::Image.read(buffer) image.valid?.should be true image.destroy! end it 'creates an image' do expect do image = MiniMagick::Image.create do |f| #Had to replace the old File.read with the following to work across all platforms f.write(File.open(SIMPLE_IMAGE_PATH,"rb") { |f| f.read }) end image.destroy! end.to_not raise_error end it 'loads a new image' do expect do image = MiniMagick::Image.new(SIMPLE_IMAGE_PATH) image.destroy! end.to_not raise_error end it 'loads remote image' do image = MiniMagick::Image.open("http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png") image.valid?.should be true image.destroy! end it 'loads remote image with complex url' do image = MiniMagick::Image.open("http://a0.twimg.com/a/1296609216/images/fronts/logo_withbird_home.png?extra=foo&plus=bar") image.valid?.should be true image.destroy! end it 'reformats an image with a given extension' do expect do image = MiniMagick::Image.open(CAP_EXT_PATH) image.format "jpg" end.to_not raise_error end it 'opens and writes an image' do output_path = "output.gif" begin image = MiniMagick::Image.new(SIMPLE_IMAGE_PATH) image.write output_path File.exists?(output_path).should be true ensure File.delete output_path end image.destroy! end it 'opens and writes an image with space in its filename' do output_path = "test output.gif" begin image = MiniMagick::Image.new(SIMPLE_IMAGE_PATH) image.write output_path File.exists?(output_path).should be true ensure File.delete output_path end image.destroy! end it 'writes an image with stream' do stream = StringIO.new image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image.write("#{Dir.tmpdir}/foo.gif") image.write(stream) MiniMagick::Image.read(stream.string).valid?.should be true image.destroy! end it 'tells when an image is invalid' do image = MiniMagick::Image.new(NOT_AN_IMAGE_PATH) image.valid?.should be false image.destroy! end it "raises error when opening a file that isn't an image" do expect do image = MiniMagick::Image.open(NOT_AN_IMAGE_PATH) image.destroy end.to raise_error(MiniMagick::Invalid) end it 'inspects image meta info' do image = MiniMagick::Image.new(SIMPLE_IMAGE_PATH) image[:width].should be 150 image[:height].should be 55 image[:dimensions].should == [150, 55] image[:colorspace].should be_an_instance_of(String) image[:format].should match(/^gif$/i) image.destroy! end it 'inspects an erroneus image meta info' do image = MiniMagick::Image.new(ERRONEOUS_IMAGE_PATH) image[:width].should be 10 image[:height].should be 10 image[:dimensions].should == [10, 10] image[:format].should == 'JPEG' image.destroy! end it 'inspects meta info from tiff images' do image = MiniMagick::Image.new(TIFF_IMAGE_PATH) image[:format].to_s.downcase.should == 'tiff' image[:width].should be 50 image[:height].should be 41 image.destroy! end it 'inspects a gif with jpg format correctly' do image = MiniMagick::Image.new(GIF_WITH_JPG_EXT) image[:format].to_s.downcase.should == 'gif' image.destroy! end it 'resizes an image correctly' do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image.resize "20x30!" image[:width].should be 20 image[:height].should be 30 image[:format].should match(/^gif$/i) image.destroy! end it 'resizes an image with minimum dimensions' do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) original_width, original_height = image[:width], image[:height] image.resize "#{original_width + 10}x#{original_height + 10}>" image[:width].should be original_width image[:height].should be original_height image.destroy! end it 'combines options to create an image with resize and blur' do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image.combine_options do |c| c.resize "20x30!" c.blur "50" end image[:width].should be 20 image[:height].should be 30 image[:format].should match(/^gif$/i) image.destroy! end it "combines options to create an image even with minuses symbols on it's name it" do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) background = "#000000" expect do image.combine_options do |c| c.draw "image Over 0,0 10,10 '#{MINUS_IMAGE_PATH}'" c.thumbnail "300x500>" c.background background end end.to_not raise_error image.destroy! end it "inspects the EXIF of an image" do image = MiniMagick::Image.open(EXIF_IMAGE_PATH) image["exif:ExifVersion"].should == '0220' image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image["EXIF:ExifVersion"].should == '' image.destroy! end it 'inspects the original at of an image' do image = MiniMagick::Image.open(EXIF_IMAGE_PATH) image[:original_at].should == Time.local('2005', '2', '23', '23', '17', '24') image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) image[:original_at].should be nil image.destroy! end it 'has the same path for tempfile and image' do image = MiniMagick::Image.open(TIFF_IMAGE_PATH) image.instance_eval("@tempfile.path").should == image.path image.destroy! end it 'has the tempfile at path after format' do image = MiniMagick::Image.open(TIFF_IMAGE_PATH) image.format('png') File.exists?(image.path).should be true image.destroy! end it "hasn't previous tempfile at path after format" do image = MiniMagick::Image.open(TIFF_IMAGE_PATH) before = image.path.dup image.format('png') File.exist?(before).should be false image.destroy! end it "changes the format of image with special characters", :if => !MiniMagick::Utilities.windows? do tempfile = Tempfile.new('magick with special! "chars\'') File.open(SIMPLE_IMAGE_PATH, 'rb') do |f| tempfile.write(f.read) tempfile.rewind end image = MiniMagick::Image.new(tempfile.path) image.format('png') File.exists?(image.path).should be true image.destroy! File.delete(image.path) tempfile.unlink end it "raises exception when calling wrong method" do image = MiniMagick::Image.open(TIFF_IMAGE_PATH) expect { image.to_blog }.to raise_error(NoMethodError) image.to_blob image.destroy! end it "can create a composite of two images" do if MiniMagick.valid_version_installed? image = MiniMagick::Image.open(EXIF_IMAGE_PATH) result = image.composite(MiniMagick::Image.open(TIFF_IMAGE_PATH)) do |c| c.gravity "center" end File.exists?(result.path).should be true else puts "Need at least version #{MiniMagick.minimum_image_magick_version} of ImageMagick" end end # https://github.com/minimagick/minimagick/issues/8 it "has issue 8 fixed" do image = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) expect do image.combine_options do |c| c.sample "50%" c.rotate "-90>" end end.to_not raise_error image.destroy! end # https://github.com/minimagick/minimagick/issues/8 it 'has issue 15 fixed' do expect do image = MiniMagick::Image.open(Pathname.new(SIMPLE_IMAGE_PATH)) output = Pathname.new("test.gif") image.write(output) end.to_not raise_error FileUtils.rm("test.gif") end # https://github.com/minimagick/minimagick/issues/37 it 'respects the language set' do original_lang = ENV["LANG"] ENV["LANG"] = "fr_FR.UTF-8" expect do image = MiniMagick::Image.open(NOT_AN_IMAGE_PATH) image.destroy end.to raise_error(MiniMagick::Invalid) ENV["LANG"] = original_lang end it 'can import pixels with default format' do columns = 325 rows = 200 depth = 16 # 16 bits (2 bytes) per pixel map = 'gray' pixels = Array.new(columns*rows) {|i| i} blob = pixels.pack("S*") # unsigned short, native byte order image = MiniMagick::Image.import_pixels(blob, columns, rows, depth, map) image.valid?.should be true image[:format].to_s.downcase.should == 'png' image[:width].should == columns image[:height].should == rows image.write("#{Dir.tmpdir}/imported_pixels_image.png") end it 'can import pixels with custom format' do columns = 325 rows = 200 depth = 16 # 16 bits (2 bytes) per pixel map = 'gray' format = 'jpeg' pixels = Array.new(columns*rows) {|i| i} blob = pixels.pack("S*") # unsigned short, native byte order image = MiniMagick::Image.import_pixels(blob, columns, rows, depth, map, format) image.valid?.should be true image[:format].to_s.downcase.should == format image[:width].should == columns image[:height].should == rows image.write("#{Dir.tmpdir}/imported_pixels_image." + format) end it 'loads mimetype correctly' do gif = MiniMagick::Image.open(SIMPLE_IMAGE_PATH) jpeg = MiniMagick::Image.open(EXIF_IMAGE_PATH) png = MiniMagick::Image.open(PNG_PATH) tiff = MiniMagick::Image.open(TIFF_IMAGE_PATH) hidden_gif = MiniMagick::Image.open(GIF_WITH_JPG_EXT) gif.mime_type.should == "image/gif" jpeg.mime_type.should == "image/jpeg" png.mime_type.should == "image/png" tiff.mime_type.should == "image/tiff" hidden_gif.mime_type == "image/gif" end end end minimagick-3.7.0/spec/lib/mini_magick_spec.rb000066400000000000000000000032011224477274000211440ustar00rootroot00000000000000require 'spec_helper' describe MiniMagick do context '.choose_processor' do it "identifies when mogrify exists" do MiniMagick::Utilities.expects(:which).with('mogrify').returns('/usr/bin/mogrify\n') MiniMagick.choose_processor.should == 'mogrify' end it "identifies when gm exists" do MiniMagick::Utilities.expects(:which).with('mogrify').returns('') MiniMagick::Utilities.expects(:which).with('gm').returns('/usr/bin/gm\n') MiniMagick.choose_processor.should == 'gm' end end context '.mogrify?' do it "checks if minimagick is using mogrify" do MiniMagick.processor = 'mogrify' MiniMagick.mogrify?.should == true end it "checks if minimagick isn't using mogrify" do MiniMagick.processor = 'gm' MiniMagick.mogrify?.should == false end it "sets the processor if it's not set" do MiniMagick.processor = nil MiniMagick::Utilities.expects(:which).with('mogrify').returns('/usr/bin/mogrify\n') MiniMagick.mogrify? MiniMagick.processor = 'mogrify' end end context '.gm?' do it "checks if minimagick is using gm" do MiniMagick.processor = 'gm' MiniMagick.gm?.should == true end it "checks if minimagick isn't using gm" do MiniMagick.processor = 'mogrify' MiniMagick.gm?.should == false end it "sets the processor if it's not set" do MiniMagick.processor = nil MiniMagick::Utilities.expects(:which).with('mogrify').returns('') MiniMagick::Utilities.expects(:which).with('gm').returns('/usr/bin/gm\n') MiniMagick.gm? MiniMagick.processor = 'gm' end end end minimagick-3.7.0/spec/spec_helper.rb000066400000000000000000000017401224477274000174140ustar00rootroot00000000000000require 'rubygems' require 'bundler/setup' require 'rspec' require 'mocha/api' require 'mini_magick' RSpec.configure do |config| config.mock_framework = :mocha config.color_enabled = true config.formatter = 'documentation' end # Image files from testunit port to RSpec test_files = File.expand_path(File.dirname(__FILE__) + "/files") SIMPLE_IMAGE_PATH = test_files + "/simple.gif" MINUS_IMAGE_PATH = test_files + "/simple-minus.gif" TIFF_IMAGE_PATH = test_files + "/leaves (spaced).tiff" NOT_AN_IMAGE_PATH = test_files + "/not_an_image.php" GIF_WITH_JPG_EXT = test_files + "/actually_a_gif.jpg" EXIF_IMAGE_PATH = test_files + "/trogdor.jpg" CAP_EXT_PATH = test_files + "/trogdor_capitalized.JPG" ANIMATION_PATH = test_files + "/animation.gif" PNG_PATH = test_files + "/png.png" COMP_IMAGE_PATH = test_files + "/composited.jpg" ERRONEOUS_IMAGE_PATH = test_files + "/erroneous.jpg"