Browse files

Fix for teeny-tiny files

  • Loading branch information...
1 parent 0c1b8b9 commit 90a781c5c07062434514a373776610581fbf1345 @geoffyoungs committed Jul 22, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 jpeg-dpi.rb
View
7 jpeg-dpi.rb
@@ -93,13 +93,14 @@ class JFIF < DeRePacker
end
if $mmap
+ len = [File.size(source),256].min
if write_dpi
FileUtils.cp(source, target) unless target == source
- mmap = Mmap.new(target, "a", "offset" => 0, 'length' => 256)
+ mmap = Mmap.new(target, "a", "offset" => 0, 'length' => len)
else
- mmap = Mmap.new(source, 'r', 'offset' => 0, 'length' => 256)
+ mmap = Mmap.new(source, 'r', 'offset' => 0, 'length' => len)
end
- data = mmap[0..255]
+ data = mmap[0...len]
puts "Modify in-place" if $DEBUG
else
data = File.open(source) { |fp|

0 comments on commit 90a781c

Please sign in to comment.