0
我是一名Mac小伙,如何使用sips更改TIFF图像的压缩风格?
如何使用sips获取PackBits压缩?
LZW下面的工作正常。
sips -s formatOptions lzw /DefaultGroup.tif
但这种失败:
sips -s formatOptions packbits /DefaultGroup.tif
任何想法,为什么?
我是一名Mac小伙,如何使用sips更改TIFF图像的压缩风格?
如何使用sips获取PackBits压缩?
LZW下面的工作正常。
sips -s formatOptions lzw /DefaultGroup.tif
但这种失败:
sips -s formatOptions packbits /DefaultGroup.tif
任何想法,为什么?
下面的代码工作。 但我仍然无法找到我的查询的实际答案。
int compression = NSTIFFCompressionPackBits;
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)dataToWrite, NULL);
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFMutableDictionaryRef saveMetaAndOpts = CFDictionaryCreateMutable(nil,0,&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFMutableDictionaryRef tiffProfsMut = CFDictionaryCreateMutable(nil, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(tiffProfsMut, kCGImagePropertyTIFFCompression, CFNumberCreate(NULL, kCFNumberIntType, &compression));
CFDictionarySetValue(saveMetaAndOpts, kCGImagePropertyTIFFDictionary, tiffProfsMut);
NSURL *outURL = [[NSURL alloc] initFileURLWithPath:filename];
CGImageDestinationRef dr = CGImageDestinationCreateWithURL ((CFURLRef)outURL, (CFStringRef)@"public.tiff" , 1, NULL);
CGImageDestinationAddImage(dr, imageRef, saveMetaAndOpts);
CGImageDestinationFinalize(dr);
CFRelease(dr);
[outURL release];
CFRelease(tiffProfsMut);
CFRelease(saveMetaAndOpts);
CFRelease(imageRef);
CFRelease(source);
代替
sips -s formatOptions packbits /DefaultGroup.tif
尝试
sips -s formatOptions pacbits /DefaultGroup.tif
换句话说,而不是使用 'PACKBITS' pacbits“。
有点令人惊讶,但它是。