Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXFJpeg populateImageData breaks some values in EXIF #10

Open
GoogleCodeExporter opened this issue Jul 20, 2015 · 1 comment
Open

EXFJpeg populateImageData breaks some values in EXIF #10

GoogleCodeExporter opened this issue Jul 20, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Read and populate metadata from jpg file (iOS SDK 4.3)
EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
[jpegScanner scanImageData: jpegData];
EXFMetaData* exifMetaData = jpegScanner.exifMetaData;
NSMutableData* newJpegData = [[NSMutableData alloc] init];
[jpegScanner populateImageData:newJpegData :exifMetaData];


What is the expected output? What do you see instead?
This shound not change any EXIF/JFIF etc value.
How ever it seems it breaks some values in metadata.
Wrong  values are in the following tags:
ApertureValue, FNumber, FocalLength, ShutterSpeedValue

Correct values are in:
ColorSpace, Exif version, Pixel X/Y dimension and few more

Missing values:
ExposureProgra, ISO, SUbkect Are

I also noticed that some values are moved to other tags:
FocalLength moved to FNumber
ApertureValue moved to ExposureTime





What version of the product are you using? On what operating system?
0.9




Original issue reported on code.google.com by [email protected] on 12 Apr 2011 at 12:04

@GoogleCodeExporter
Copy link
Author

Well, I fixed the problem. However it is not a real fix, but only workaround.

The problem was in file EXFMetaData.m, in function 
-(void) getDataFromMap: (NSDictionary*) dictionary :(NSMutableArray*) 
dataWriterArray: (UInt8**) bytes: (int) overflowOffset: (int) offsetBase

It calculates blockCount as:
int blockCount = (size *12 +2)  +4;
It is not OK, because if if tag is in unexpected format, is ignored, so the 
blockSize should be also decreased.


FIX:
Replace line 1431 in file XFMetaData.m:
int blockCount = (size *12 +2)  +4;
to:
int blockCount = [self getRealBlockCount:dictionary :sortedKeysArray];


And just over function 
-(void) getDataFromMap ...

add:
- (int) getRealBlockCount: (NSDictionary*) dictionary :(NSArray*) 
sortedKeysArray {
    int size = [sortedKeysArray count] ;
    int blockCount = (size *12 +2)  +4;
    for (int de =0;de <size;de++) {
        NSNumber *key = [sortedKeysArray objectAtIndex:de];
        id obj = [dictionary objectForKey:key];
        if (![obj isKindOfClass:[NSDictionary class]]) {
            EXFTag* tag = [self.keyedTagDefinitions objectForKey:key];
            id<EXFTagHandler> handler = [[self userKeyedHandlers] objectForKey:key];
            if (handler == nil) handler = [[self keyedHandlers] objectForKey:key];    
            if (handler == nil && tag.components <0) {
                if (![obj isKindOfClass:[NSData class]] && ![obj isKindOfClass:[NSString class]]){
                    // we have a problem here, don't count this tag to blockCount!
                    blockCount-=12;
                }
            }
        }
    }
    return blockCount;
}


Can anybody confirm that this problem really exists and my workaround really 
fixes it?

Original comment by [email protected] on 12 Apr 2011 at 9:10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant