我是Mac的粉丝,
如何使用sips获得PackBits压缩
对于LZW,低于1的值工作正常。
sips -s formatOptions lzw /DefaultGroup.tif但这失败了:
sips -s formatOptions packbits /DefaultGroup.tif知道为什么吗?
发布于 2009-09-14 09:43:27
下面的代码可以正常工作。但我仍然找不到我的问题的实际答案。
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);发布于 2012-05-05 11:03:23
而不是
sips -s formatOptions packbits /DefaultGroup.tif试一试
sips -s formatOptions pacbits /DefaultGroup.tif换句话说,使用“pacbits”而不是“packbits”。
有点令人惊讶,但事实就是如此。
发布于 2020-04-25 21:35:02
loopqoob是对的。
sips的手册页是错误的。在使用sips时,您必须使用"pacbits“而不是"packbits”。
换句话说,这是可行的。它在我的Mac上运行High Sierra:
例如。
sips -s format tiff -s formatOptions pacbits '/Users/rob/Downloads/image20.jpg' --out '/Users/rob/Downloads/image20.tiff这样做之后,我可以在Preview中打开tiff图像。单击“工具”,然后单击下拉菜单上的“显示检查器”。您将看到TIFF图像是用Packbits压缩的。(预览显示所用压缩的正确名称)。
https://stackoverflow.com/questions/1388876
复制相似问题