ITunes를 통해 이미지를 2 개의 Ipad (IPAD1 및 IPAD2로 말하기)에 동기화했습니다. 그런 다음 ALAssetLibrary 블록을 사용하여 이미지를 검색하면 파일 크기가 2 개의 Ipads로 다릅니다.ALAsset 블록을 사용하여 검색 할 때 동일한 파일이 IPAD1 및 IPAD2에서 다른 크기로 나타남
(IPAD1 파일 크기 : 0.024059, IPAD2 파일 크기 : 0.024325).
왜 IPAD1과 IPAD2에서 같은 파일의 크기가 다른지 알 수 있습니까?
그러나 사파리 브라우저를 통해 IPAD1 및 IPAD2에 이미지를 저장 했으므로 ALAssetLibarary를 통해 검색 할 때 동일한 웹 페이지에서 이미지를 탭하면 Ipad1 및 Ipad2의 이미지와 동일한 파일 크기가됩니다.
저에게 알려주십시오 여러분의 소중한 제안 ....
사용
I am doing the image comparison in Ipad PhotoLibrary.
Whenever an Image transfer request is coming from another device, i have to test the image file exist in PhotoLibrary.
So mentor image request will have CRC code of the requested image which will uneque for the same image file and i am generating the CRC code for all my photoLibrary images and comparing it with the requested image CRC code.
So whenever these 2 CRC's are equal , i can easily identify the files are same.
내가 PhotoLibrary 이미지 검색에 사용되는 코드는 다음과 같습니다
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
NSLog(@"GOT ASSET, File size: %f", [rep size]/(1024.0f*1024.0f));
uint8_t* buffer = malloc([rep size]);
NSError* error = NULL;
NSUInteger bytes = [rep getBytes:buffer fromOffset:0 length:[rep size] error:&error];
if (bytes == [rep size])
{
defaultRepresentationData = [[NSData dataWithBytes:buffer length:bytes] retain];
CGImageRef iref = [rep fullResolutionImage];
UIImage *photLibraryImage = [UIImage imageWithCGImage:iref];
NSData *imageData = UIImagePNGRepresentation(photLibraryImage); //convert image into .png format.
const int imageCRC = [self CRCForImage:imageData]]; //getting CRC value for image data
NSLog([NSString stringWithFormat:@"@@@@@@@@ image CRC is:%u",imageCRC ]);
}
else
{
NSLog(@"Error '%@' reading bytes from asset: '%@'", [error localizedDescription]); //assetURL);
}
free(buffer);
// notifies the lock that "all tasks are finished"
};
//
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"NOT GOT ASSET");
};
NSURL *asseturl = [NSURL URLWithString:fileName];
ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
[assetslibrary assetForURL:asseturl resultBlock:resultblock failureBlock:failureblock];
}
NSLog (@ "GOT ASSET, 파일 크기 : % f", [rep 크기]/(1024.0f * 1024.0f)); 다른 장치에서 동일한 파일에 대해 다른 값을 인쇄합니다.
콘솔 로그 세부
는 'ipad1
GOT 자산, 파일 크기 : 0.024059 이미지 CRC가 : 2,659,650,838
ipad2에
GOT 자산, 파일 크기 : 0.024325 @@@@@@@@ 이미지 CRC는 다음과 같습니다 331,786,167
아이 패드 버전 세부
는 'ipad1 : 버전 : 4.2.1 (8C148) 모델 : MB292LL
IPAD2 : 버전 : 4.3.5 (8L1) 모델 : MB292LL
감사합니다.
두 개의 이미지가 동일하다는 것을 확인하기 위해 CRC 체크섬이 충분하지 않다고 덧붙이고 싶습니다. – JustSid
사실.비둘기 원리는 * n * 비트의 해시가 2 개 이상의 * n * 값을 구별 할 수 없으며 이미지의 길이가 거의 항상 32 비트를 초과한다는 것을 알려줍니다. 임의의 데이터 간의 충돌 위험이 예상보다 높습니다. –
@Jonathan Grynspan @ JustSid 나에게도 동일한 문제가 발견되었습니다. 또한 Ipad PhotoLibrary에서 이미지 비교를하고 있습니다. 이미지 전송 요청이 다른 장치에서 전송 될 때마다 PhotoLibrary에있는 이미지 파일을 테스트해야합니다. 그래서 어떻게 테스트 할 수 있습니까? Sender 디바이스에서 PhotoLibrary 이미지 파일을위한 Learner로 전송할 필요가있는 모든 이미지 세부 사항은 무엇입니까? – Sandeep