

      ByteArrayInputStream bais = new ByteArrayInputStream (this.getRepresentation());
      TranscoderInput input = new TranscoderInput (bais);
      TranscoderOutput output = new TranscoderOutput (outstr);
      JPEGTranscoder transcoder =  new JPEGTranscoder ();

      TranscodingHints hints = transcoder.getTranscodingHints();

      if (properties != null)
      {
        Float height = properties.getHeight();
        if (height != null)
        {
          hints.put(ImageTranscoder.KEY_HEIGHT, height);
        }

        Float width = properties.getWidth();
        if (width != null)
        {
          hints.put(ImageTranscoder.KEY_WIDTH, width);
        }
      }

      hints.put(JPEGTranscoder.KEY_QUALITY, new Float(JPEG_QUALITY));
      transcoder.setTranscodingHints(hints);

      transcoder.transcode(input, output);

