2015-10-15 35 views

回答

2

JPEG Format包含several markers

的漸進標記是

\xFF\xC2 
\xFF\xDA 

如果您在文件中找到這些,那麼你正在處理的漸進式JPEG。

2

在做了一些更多的研究之後,我發現了一些關於它可以在iOS中完成的更多信息。

繼我在Technical Q&A QA1654 - Accessing image properties with ImageIO看我做了這樣的:

//Example of progressive JPEG 
NSString *imageUrlStr = @"http://cetus.sakura.ne.jp/softlab/software/spibench/pic_22p.jpg"; 

CFURLRef url = (__bridge CFURLRef)[NSURL URLWithString:imageUrlStr]; 

CGImageSourceRef myImageSource = CGImageSourceCreateWithURL(url, NULL); 

CFDictionaryRef imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL); 

的imagePropertiesDictionary字典看起來像這樣的漸進式JPEG:

Printing description of imagePropertiesDictionary: 
{ 
    ColorModel = RGB; 
    Depth = 8; 
    PixelHeight = 1280; 
    PixelWidth = 1024; 
    "{JFIF}" =  { 
     DensityUnit = 0; 
     IsProgressive = 1; 
     JFIFVersion =   (
      1, 
      0, 
      1 
     ); 
     XDensity = 1; 
     YDensity = 1; 
    }; 
} 

IsProgressive = 1意味着它是一個漸進/隔行JPEG。你可以檢查這樣的值:

CFDictionaryRef JFIFDictionary = (CFDictionaryRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyJFIFDictionary); 

CFBooleanRef isProgressive = (CFBooleanRef)CFDictionaryGetValue(JFIFDictionary, kCGImagePropertyJFIFIsProgressive); 

if(isProgressive == kCFBooleanTrue) 
    NSLog(@"It's a progressive JPEG"); 
相關問題