如何使用Sip更改TIFF图像的压缩样式?

问题描述 投票:0回答:3

我是Mac家伙,

如何使用sips获得PackBits压缩?

下面的LZW可以正常工作。

sips -s formatOptions lzw /DefaultGroup.tif

但是失败了:

sips -s formatOptions packbits /DefaultGroup.tif

知道为什么吗?

command-line tiff sip
3个回答
3
投票

代替

sips -s formatOptions packbits /DefaultGroup.tif

尝试

sips -s formatOptions pacbits /DefaultGroup.tif

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

有点令人惊讶,但确实有。


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);

0
投票

loopqoob是正确的。

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

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

E.G。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.