كيفية تغيير نمط ضغط صورة TIFF باستخدام SIPS؟
-
21-09-2019 - |
سؤال
أنا رجل ماك ،
كيفية الحصول على ضغط packbits باستخدام رشفات?
أقل من واحد ل LZW يعمل بشكل جيد.
sips -s formatOptions lzw /DefaultGroup.tif
لكن هذا فشل:
sips -s formatOptions packbits /DefaultGroup.tif
أي فكرة لماذا؟
المحلول 2
الرمز أدناه يعمل. لكن ما زلت لم أتمكن من العثور على الإجابة الفعلية على استعلامي.
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
بمعنى آخر ، استخدم "pacbits" بدلاً من "packbits".
نوع من مفاجأة ، ولكن هناك.
لا تنتمي إلى StackOverflow