From: "C. Dagnon" Date: 2009-05-18T08:21:57+09:00 Subject: TkPhotoImage.copy always gives "too many colors" Error I'm working to copy and eventually manipulate images within Ruby, but the Tk extension seems to be broken. My program (minus some crud) looks like this: require 'tk' require 'tk/image' require 'tkextlib/tkimg' # Settings image_file_suffix = '.jpg' final_filename = "final.jpg" # Find all the separate images Dir.chdir( to_dir ) image_filenames = [] regex = Regexp.compile("^[0-9]+.*\\#{image_file_suffix}$") Dir.foreach(".") {|filename| image_filenames << filename if filename =~ regex } photos = [] pixel_height = 0 pixel_width = 0 image_filenames.each{ |image_fn| image = TkPhotoImage.new( :file => image_fn ) photos << image pixel_width += photo.width pixel_height = photo.height > pixel_height ? photo.height : pixel_height } compound_image = TkPhotoImage.new( :height => pixel_height, :width => pixel_width ) compound_image.blank curr_x = 0 photo = photos[0] # All give C:/ruby/ruby1_86_26/lib/ruby/1.8/tk.rb:2272:in `__invoke': too many colors (RuntimeError) #compound_image.copy( photo, :from => [0,0,photo.width, photo.height] ) #data = photo.data( :from => [0,0,photo.width, photo.height] ) #compound_image.copy( photo ) compound_image.put( photo.data ) compound_image.write final_filename ---------------------------- So I've tried the 4 different commands near the end and everything fails. In particular I added a puts at the tk.rb method mentioned and get the following out using any .copy() call: INVOKE: ["i00002", "copy", "i00000"] INVOKE: ["i00002", "write", "final.jpg"] INVOKE: ["rename", "INTERP_FINALIZE_HOOK", ""] And it is always after the last one when the error gets thrown. The .put(.data()) call dumps all the data to the console (and takes a looong time), but otherwise the last 2 commands and the error are always the same. The file actually created is only 6 bytes - not a good result when trying to copy a 35K file over... I've tried it as a simple way to copy a couple different images with the same results. Google only finds me many versions of a code file with INTERP_FINALIZE_HOOK in it - nothing useful nor explanatory except possibly a couple links at the very end in Japanese. Any ideas appreciated! -Chris WinXP SP3?, Ruby 1.8.6, ActiveTcl 8.4.17.0... -- Posted via http://www.ruby-forum.com/.