1

我是一个Mac人,

如何使用sips获得 PackBits 压缩?

下面的 LZW 工作正常。

sips -s formatOptions lzw /DefaultGroup.tif

但这失败了:

sips -s formatOptions packbits /DefaultGroup.tif

知道为什么吗?

4

3 回答 3

3

代替

sips -s formatOptions packbits /DefaultGroup.tif

尝试

sips -s formatOptions pacbits /DefaultGroup.tif

换句话说,使用“pacbits”而不是“packbits”。

有点令人惊讶,但它确实存在。

于 2012-05-05T03:03:22.727 回答
0

下面的代码有效。但我仍然找不到我的查询的实际答案。

 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);
于 2009-09-14T09:43:26.613 回答
0

loopqoob 是对的。

sips 的手册页是错误的。使用 sip 时,您必须使用“pacbits”而不是“packbits”。

换句话说,这将起作用。它在我运行 High Sierra 的 Mac 上运行:

例如

sips -s format tiff -s formatOptions pacbits '/Users/rob/Downloads/image20.jpg' --out '/Users/rob/Downloads/image20.tiff

完成后,我可以在预览中打开 tiff 图像。单击“工具”,然后在下拉菜单中单击“显示检查器”。您将看到 TIFF 图像是使用 Packbits 压缩的。(预览显示使用的压缩的正确名称)。

于 2020-04-25T13:35:01.847 回答