Sha256: b2e3f4f4160bd3e87835c84023a9b28571f350a4730a3f59d16453d759968578

Contents?: true

Size: 1.76 KB

Versions: 10

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe Dragonfly::ImageMagick::Processors::Convert do

  def sample_content(name)
    Dragonfly::Content.new(app, SAMPLES_DIR.join(name))
  end

  let(:app){ test_app }
  let(:image){ sample_content('beach.png') } # 280x355
  let(:processor){ Dragonfly::ImageMagick::Processors::Convert.new }

  it "should allow for general convert commands" do
    processor.call(image, '-scale 56x71')
    image.should have_width(56)
    image.should have_height(71)
  end

  it "should allow for general convert commands with added format" do
    processor.call(image, '-scale 56x71', 'format' => 'gif')
    image.should have_width(56)
    image.should have_height(71)
    image.should have_format('gif')
    image.meta['format'].should == 'gif'
  end

  it "should work for commands with parenthesis" do
    processor.call(image, "\\( +clone -sparse-color Barycentric '0,0 black 0,%[fx:h-1] white' -function polynomial 2,-2,0.5 \\) -compose Blur -set option:compose:args 15 -composite")
    image.should have_width(280)
  end

  it "should work for files with spaces in the name" do
    image = Dragonfly::Content.new(app, SAMPLES_DIR.join('white pixel.png'))
    processor.call(image, "-resize 2x2!")
    image.should have_width(2)
  end

  it "updates the url with format if given" do
    url_attributes = Dragonfly::UrlAttributes.new
    processor.update_url(url_attributes, '-scale 56x71', 'format' => 'gif')
    url_attributes.ext.should == 'gif'
  end

  it "allows converting specific frames" do
    gif = sample_content('gif.gif')
    processor.call(gif, '-resize 50x50')
    all_frames_size = gif.size

    gif = sample_content('gif.gif')
    processor.call(gif, '-resize 50x50', 'frame' => 0)
    one_frame_size = gif.size

    one_frame_size.should < all_frames_size
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dragonfly-1.0.9 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.8 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.7 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.6 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.5 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.4 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.3 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.2 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0.1 spec/dragonfly/image_magick/processors/convert_spec.rb
dragonfly-1.0 spec/dragonfly/image_magick/processors/convert_spec.rb