2 Replies Latest reply on Nov 8, 2014 10:53 AM by iamwickedtall

    Is there a simple way to convert bit depth to 16 bit?

    iamwickedtall Level 1

      It seems there are PDF/BITMAP specific methods to convert to 8 bit depth, but I can't find any documentation to do this easily to the file as a whole. Is there a way to do this? I want to convert from 32 to 16 bit.

        • 1. Re: Is there a simple way to convert bit depth to 16 bit?
          xbytor2 Level 4

          I have code in Image Processor Pro that looks like this:

            // Bit Depth
            var bd = toNumber(task.@bitDepth) || 0;
            if (bd) {
              var bpc = doc.bitsPerChannel;
              try {
                if (bd == 8) {
                  doc.bitsPerChannel = BitsPerChannelType.ONE;
                } else if (bd == 8) {
                  doc.bitsPerChannel = BitsPerChannelType.EIGHT;
                } else if (bd == 16) {
                  doc.bitsPerChannel = BitsPerChannelType.SIXTEEN;
                } else if (bd == 32) {
                  doc.bitsPerChannel = BitsPerChannelType.THIRTYTWO;
                }
              } catch (e) {
                LogFile.logException(e, "Error selecting bit depth " + bd);
              }
            }
          

           

          Then, later, I have this code which changes the document mode so that you can save it as a bmp file:

            if (ImageProcessorOptions.JDI && ext == "bmp") {
              // We need to make adjustments depending the number of
              // bmp save bits selected
              if (saveOpts.depth == BMPDepthType.ONE ||
                  saveOpts.depth == BMPDepthType.SIXTEEN ||
                  saveOpts.depth == BMPDepthType.TWENTYFOUR || 
                  saveOpts.depth == BMPDepthType.THIRTYTWO) {
                saveOpts.rleCompression = false;
              }
              if (saveOpts.depth == BMPDepthType.FOUR ||
                  saveOpts.depth == BMPDepthType.EIGHT) {
                doc.changeMode(ChangeMode.GRAYSCALE);
              }
              if (saveOpts.depth == BMPDepthType.ONE) {
                if (doc.mode != ChangeMode.BITMAP) {
                  doc.changeMode(ChangeMode.GRAYSCALE);
                }
                var cnvtOpts = new BitmapConversionOptions();
                doc.changeMode(ChangeMode.BITMAP, cnvtOpts);
              }
            }
          

           

          I don't think I've tested with pdfs files.

           

          Hope this helps.

          • 2. Re: Is there a simple way to convert bit depth to 16 bit?
            iamwickedtall Level 1

            Thanks! I'm just working with Tifs, but I mentioned pdf, cause there's code on the save side to convert bit depth. As per usual, I probably had my syntax wrong, but his is exactly the method I was looking for! Thanks!