问题
While converting TIFF to BMP using libtiff on Mac OS X, I got these errors:
scannerdata.tif: Old-style JPEG compression support is not configured.
scannerdata.tif: Sorry, requested compression method is not configured.
I am currently using libtiff in Mac OS X.
My implementation of tiff to bmp:
static void tifftobmp(char *colorMode){
    DBG(1, ">> tifftobmp \n");
    /* For files and file header */
    char infile[PATH_MAX] = {0};
    char outfile[PATH_MAX] = {0};
    char tempfile[PATH_MAX] = {0};
    TIFF *tifFile;
    FILE *bmpFile, *tmpBitmapFile;
    uint32 image_width, image_height, long_val, short_val;
    /* For Colour table */
    unsigned char padding;
    unsigned short i;
    unsigned char value;
    /* For image information */
    Image_Information *image_info;
    image_info = (Image_Information *)malloc(sizeof(Image_Information));
    sprintf(infile, TIFF_IMAGE_DATA);
    sprintf(outfile, BMP_IMAGE_DATA);
    sprintf(tempfile, TEMP_IMAGE_DATA);
    /* Open necessary files */
    tifFile = TIFFOpen(infile, "r");
    if (!tifFile){
        DBG(128, "Can't open %s for reading\n", infile);
        TIFFClose(tifFile);
    }
    bmpFile = fopen(outfile, "wb");
    if (!bmpFile){
        DBG(128, "Can't open %s for writing\n", outfile);
        fclose(bmpFile);
    }
    tmpBitmapFile = fopen(tempfile, "wb");
    if (!tmpBitmapFile){
        DBG(128, "Can't open %s for writing\n", tempfile);
        fclose(tmpBitmapFile);
    }
    TIFFGetField(tifFile, TIFFTAG_IMAGELENGTH, &image_height);
    TIFFGetField(tifFile, TIFFTAG_IMAGEWIDTH, &image_width);
    image_info->img_height = image_height;
    image_info->img_width = image_width;
    /* Get Image Info Color */
    if(strcmp(colorMode,"COLOR") == 0){
        get_image_info_color(image_info);
    }else if (strcmp(colorMode,"GRAY") == 0){
        get_image_info_gray(image_info);
    }else if(strcmp(colorMode,"MONO") == 0){
        get_image_info_mono(image_info);
    }
    /* Set Header */
    fwrite("BM", 1, 2, bmpFile);        /* Signature */
    long_val = sizeof(BITMAPFILEHEADER)  + sizeof(BITMAPINFOHEADER) + image_info->img_scansize * image_info->img_height;
    fwrite(&long_val, 4, 1, bmpFile);   /* Size in bytes of the bitmap file */
    short_val = 0;
    fwrite(&short_val, 2, 1, bmpFile);  /* Reserved, set as 0 */
    fwrite(&short_val, 2, 1, bmpFile);  /* Reserved, set as 0 */
    if(strcmp(colorMode,"COLOR") == 0){ /* Offset of the image from file start */
        long_val = 54;
    }else{
        long_val = 54 + (4 * (1 << image_info->img_bits_per_pixel));
    }
    fwrite(&long_val, 4, 1, bmpFile);
    long_val = sizeof(BITMAPINFOHEADER);  /* Size of BMPInfoHeader structure */
    fwrite(&long_val, 4, 1, bmpFile);
    fwrite(&image_info->img_width, 4, 1, bmpFile);
    fwrite(&image_info->img_height, 4, 1, bmpFile);
    short_val = 1;                  /* Number of image planes */
    fwrite(&short_val, 2, 1, bmpFile);
    if(strcmp(colorMode,"MONO") == 0){ /* Number of bits per pixel */
        short_val = image_info->img_bits_per_pixel;
    }else if (strcmp(colorMode,"COLOR") == 0){
        short_val = image_info->img_bits_per_pixel;
    }else if (strcmp(colorMode,"GRAY") == 0){
        short_val = image_info->img_bits_per_pixel;
    }
    fwrite(&short_val, 2, 1, bmpFile);
    long_val = 0;                   /* Compression method */
    fwrite(&long_val, 4, 1, bmpFile);
    long_val = 0;                   /* Size of uncompressed image in bytes */
    fwrite(&long_val, 4, 1, bmpFile);
    long_val = 0;                   /* X resolution, pixels per meter */
    fwrite(&long_val, 4, 1, bmpFile);
    long_val = 0;                   /* Y resolution, pixels per meter */
    fwrite(&long_val, 4, 1, bmpFile);
    if(strcmp(colorMode,"COLOR") == 0){  /* Size of colour table */
        long_val = 0;
    }else{
        long_val = 1 << image_info->img_bits_per_pixel;
    }
    fwrite(&long_val, 4, 1, bmpFile);
    long_val = 0;                   /* Number of important colours */
    fwrite(&long_val, 4, 1, bmpFile);
    /* Colour table */
    if(strcmp(colorMode,"MONO") == 0){
        value = 0xFF;
        padding = 0;
        /* white */
        fwrite(&value, 1, 1, bmpFile); /* R component */
        fwrite(&value, 1, 1, bmpFile); /* G component */
        fwrite(&value, 1, 1, bmpFile); /* B component */
        fwrite(&padding, 1, 1, bmpFile); /* padding */
        /* black */
        value = 0x00;
        fwrite(&value, 1, 1, bmpFile); /* R component */
        fwrite(&value, 1, 1, bmpFile); /* G component */
        fwrite(&value, 1, 1, bmpFile); /* B component */
        fwrite(&padding, 1, 1, bmpFile); /* padding */
    }else if (strcmp(colorMode,"GRAY") == 0){
        padding = 0;
        for ( i = 0; i <= 255; i++ ){
            fwrite(&i, 1, 1, bmpFile); /* R component */
            fwrite(&i, 1, 1, bmpFile); /* G component */
            fwrite(&i, 1, 1, bmpFile); /* B component */
            fwrite(&padding, 1, 1, bmpFile); /* padding */
        }
    }
    /* Read and write image */
    if(strcmp(colorMode,"MONO") == 0){
        read_mono_image(tifFile, tmpBitmapFile, image_info);
    }else if(strcmp(colorMode,"GRAY") == 0){
        read_gray_image(tifFile, tmpBitmapFile, image_info);
    }else if(strcmp(colorMode,"COLOR") == 0){
        read_color_image(tifFile, bmpFile, image_info);
    }
    if(strcmp(colorMode,"COLOR") != 0){
        fclose(tmpBitmapFile);
        flip_image(image_info, bmpFile);
    }
    fclose(bmpFile);
    TIFFClose(tifFile);
    DBG(1, "<< tifftobmp \n");
}
    回答1:
Take a look at the source code of Libtiff in "nmake.opt"
#
# Uncomment and edit following lines to enable JPEG support.
#
#JPEG_SUPPORT   = 1
...
!IFDEF JPEG_SUPPORT
LIBS        = $(LIBS) $(JPEG_LIB)
EXTRAFLAGS  = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS)
!ENDIF
So, by default the JPEG support not enabled.
来源:https://stackoverflow.com/questions/25359846/libtiff-error-old-style-jpeg-compression-support-is-not-configured