Skip to content

Commit

Permalink
Add handling of format change at multi page pdf
Browse files Browse the repository at this point in the history
File variable can be "filename-*.ext". So later following image manipulations will affect all layers.
  • Loading branch information
tmaier committed Dec 30, 2012
1 parent 6c78436 commit 2873a9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/image_sorcery.rb
Expand Up @@ -91,6 +91,10 @@ def replace_file(format)
File.delete @file
@file = File.join File.dirname(@file), File.basename(@file, File.extname(@file)) + "." + format
@filename_changed = true

unless File.exists? @file
@file = File.join File.dirname(@file), File.basename(@file, File.extname(@file)) + "-*." + format
end
end

def convert_to_command(tokens)
Expand Down
12 changes: 11 additions & 1 deletion spec/image_sorcery_examples_spec.rb
Expand Up @@ -61,12 +61,22 @@
end

it "should create file with new extension" do
File.exists?("./spec/fixtures/pdf-sample-2.png").should be_true

case new_instance_method
when "new"
File.exists?("./spec/fixtures/pdf-sample-2-0.png").should be_true
File.exists?("./spec/fixtures/pdf-sample-2-1.png").should be_true
when "gm"
File.exists?("./spec/fixtures/pdf-sample-2.png").should be_true
end
end

its(:identify) { should include "PNG 595x842" }

its(:filename_changed?) { should be_true }

its(:file) { should eq "./spec/fixtures/pdf-sample-2.png" } if new_instance_method == "gm"
its(:file) { should eq "./spec/fixtures/pdf-sample-2-*.png" } if new_instance_method == "new"
end
end
end
Expand Down

0 comments on commit 2873a9a

Please sign in to comment.