0

I'm using carrierwave-vips (with ruby-vips) to upload and process 16 bit tiff. The 16 bit tiff will get save (not a problem for carrierewave alone), but I also want to process a thumbnail (jpeg). The problem is that the resulting thumbnail is completely blown out. What can I do?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
cgat
  • 3,689
  • 4
  • 24
  • 38

1 Answers1

0

The problem is that the 16 bit digtals that represents your band levels aren't getting scaled down. Add the following method to your uploader:

def convert_to_8bit
    manipulate! do |image|
      #vips specific
      image.scale
    end
  end

and then process: :convert_to_8bit in your version.

cgat
  • 3,689
  • 4
  • 24
  • 38
  • `image.scale` will search the image for max and min, then scale it to fit 0 - 255. This will produce bad results for some images. You want to just take the top 8 bits of the 16. I would use `(image >> 8).clip2fmt :uchar`, ie. shift bits 8 to the right, cast down to unsigned char. The most recent libvips, 7.32, will do this for you automatically, so updating is also an option. – jcupitt Mar 08 '13 at 11:22
  • Hey, thanks for your comment. Probably not a big use issue for my current image set, but very relevant. I'll try to upgrade my libvips first and see if that fixes the issue. – cgat Mar 10 '13 at 01:34
  • I've upgraded to 7.32 and it doesn't seem to be doing this automatically. I believe you are a maintainer, should I open up a bug? The file that I'm using is a ~200mb grayscale 16 tiff. – cgat Mar 10 '13 at 22:44