TIFF can output CMYK
authormayeut <mayeut@users.noreply.github.com>
Fri, 21 Aug 2015 17:54:22 +0000 (19:54 +0200)
committermayeut <mayeut@users.noreply.github.com>
Fri, 21 Aug 2015 17:54:22 +0000 (19:54 +0200)
src/bin/jp2/converttif.c
src/bin/jp2/opj_decompress.c

index daddbfee83ec7a9d18d828d9245a82043823591f..f164989f4133d250724076640461c9830cf37d33 100644 (file)
@@ -183,7 +183,18 @@ int imagetotif(opj_image_t * image, const char *outfile)
        
        numcomps = image->numcomps;
        
-       if (numcomps > 2U) {
+       if (image->color_space == OPJ_CLRSPC_CMYK) {
+               if (numcomps < 4U) {
+                       fprintf(stderr,"imagetotif: CMYK images shall be composed of at least 4 planes.\n");
+                       fprintf(stderr,"\tAborting\n");
+                       return 1;
+               }
+               tiPhoto = PHOTOMETRIC_SEPARATED;
+               if (numcomps > 4U) {
+                       numcomps = 4U; /* Alpha not supported */
+               }
+       }
+       else if (numcomps > 2U) {
                tiPhoto = PHOTOMETRIC_RGB;
                if (numcomps > 4U) {
                        numcomps = 4U;
@@ -266,6 +277,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
        TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, tiPhoto);
        TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
+       
        strip_size = TIFFStripSize(tif);
        rowStride = ((OPJ_SIZE_T)width * numcomps * (OPJ_SIZE_T)bps + 7U) / 8U;
        if (rowStride != (OPJ_SIZE_T)strip_size) {
index 76f592fd197a5458fe225dedb102f6137345ea9f..ac17b69dcef990ccefd3b96124cb352a44f15792 100644 (file)
@@ -1359,12 +1359,10 @@ int main(int argc, char **argv)
                if(image->color_space == OPJ_CLRSPC_SYCC){
                        color_sycc_to_rgb(image);
                }
-               else
-               if(image->color_space == OPJ_CLRSPC_CMYK){
+               else if((image->color_space == OPJ_CLRSPC_CMYK) && (parameters.cod_format != TIF_DFMT)){
                        color_cmyk_to_rgb(image);
                }
-               else
-               if(image->color_space == OPJ_CLRSPC_EYCC){
+               else if(image->color_space == OPJ_CLRSPC_EYCC){
                        color_esycc_to_rgb(image);
                }