lib/write_xlsx/workbook.rb in write_xlsx-0.76.0 vs lib/write_xlsx/workbook.rb in write_xlsx-0.76.1

- old
+ new

@@ -118,11 +118,10 @@ @window_height = 9660 @tab_ratio = 500 @table_count = 0 @image_types = {} @images = [] - @images_seen = {} # Structures for the shared strings data. @shared_strings = Package::SharedStrings.new add_format(default_formats.merge(:xf_index => 0)) @@ -1728,24 +1727,22 @@ # and extension. Also keep track of previously seen images to optimise out # any duplicates. # def get_image_properties(filename) previous_images = [] + images_seen = {} image_id = 1; - if @images_seen[filename] + if images_seen[filename] # We've processed this file already. index = images_seen[filename] - 1 - - # Increase image reference count. - image_data[index][0] += 1 else # Open the image file and import the data. data = File.binread(filename) if data.unpack('x A3')[0] == 'PNG' # Test for PNGs. type, width, height = process_png(data) - image_types[:png] = 1 + @image_types[:png] = 1 elsif data.unpack('n')[0] == 0xFFD8 # Test for JPEG files. type, width, height = process_jpg(data, filename) @image_types[:jpeg] = 1 elsif data.unpack('A2')[0] == 'BM' @@ -1755,14 +1752,14 @@ else # TODO. Add Image::Size to support other types. raise "Unsupported image format for file: #{filename}\n" end - @images << [ filename, type] + @images << [filename, type] # Also store new data for use in duplicate images. previous_images << [image_id, type, width, height] - @images_seen[filename] = image_id + images_seen[filename] = image_id image_id += 1 end [image_id, type, width, height, File.basename(filename)] end