Command line 如何使用sips更改TIFF图像的压缩样式?

Command line 如何使用sips更改TIFF图像的压缩样式?,command-line,tiff,sip,Command Line,Tiff,Sip,我是一个苹果人 如何使用压缩包进行压缩 LZW的低于1工作正常 sips -s formatOptions lzw /DefaultGroup.tif 但这失败了: sips -s formatOptions packbits /DefaultGroup.tif 知道为什么吗?下面的代码可以工作。 但我仍然找不到我的问题的实际答案 int compression = NSTIFFCompressionPackBits; CGImageSourceRef source = CGImageS

我是一个苹果人

如何使用压缩包进行压缩

LZW的低于1工作正常

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);
下面的代码可以工作。 但我仍然找不到我的问题的实际答案

 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
试一试

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

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

而不是

sips -s formatOptions packbits /DefaultGroup.tif
试一试

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

有点令人惊讶,但事实确实如此。

loopqoob是对的

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

换句话说,这将起作用。它在我的Mac电脑上运行速度很快:

例如

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

loopqoob是正确的

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

换句话说,这将起作用。它在我的Mac电脑上运行速度很快:

例如

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