Skip to content

Commit

Permalink
Edit Tags: Image subtitle with type, dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwells committed Feb 22, 2011
1 parent 83af073 commit aed9b50
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions Edit MPEG-4 Metadata Tags/AlbumArt.h
Expand Up @@ -39,6 +39,7 @@

@interface AlbumArt : NSManagedObject <NSPasteboardWriting> {
NSUInteger imageVersion;
NSString *imageTitle;
}

@property NSUInteger imageVersion;
Expand Down
41 changes: 41 additions & 0 deletions Edit MPEG-4 Metadata Tags/AlbumArt.m
Expand Up @@ -41,6 +41,13 @@ @implementation AlbumArt
@synthesize imageVersion;
@dynamic primitiveImageRepresentation;

- (void) dealloc
{
[imageTitle release];
imageTitle = nil;
[super dealloc];
}

- (void)setImageRepresentation:(NSData *)data {
[self willChangeValueForKey:@"imageRepresentation"];
[self setPrimitiveImageRepresentation:data];
Expand All @@ -56,6 +63,40 @@ - (NSString *)imageUID {
return [[[self objectID] URIRepresentation] description];
}

- (NSString *)imageSubtitle {
if (!imageTitle) {
NSUInteger artwork_type = [[self valueForKey:@"imageType"] unsignedIntegerValue];
NSString *imageType;
switch (artwork_type) {
case MP4_ART_JPEG:
imageType = @"JPEG";
break;
case MP4_ART_PNG:
imageType = @"PNG";
break;
case MP4_ART_BMP:
imageType = @"BMP";
break;
case MP4_ART_GIF:
imageType = @"GIF";
break;
default:
imageType = @"Image";
break;
}
// get image size
NSData *imageData = [self valueForKey:@"imageRepresentation"];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if (image) {
NSSize imageSize = [image size];
imageTitle = [NSString stringWithFormat:@"%@ (%.0f x %.0f)",imageType,imageSize.width,imageSize.height];
} else {
imageTitle = [NSString stringWithString:imageType];
}
}
return imageTitle;
}

- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard {
NSUInteger artwork_type = [[self valueForKey:@"imageType"] unsignedIntegerValue];
NSString *dataType = nil;
Expand Down
2 changes: 1 addition & 1 deletion Edit MPEG-4 Metadata Tags/English.lproj/main.xib
Expand Up @@ -1877,7 +1877,7 @@
<string key="NSFrameSize">{466, 98}</string>
<reference key="NSSuperview" ref="342699628"/>
<bool key="constrainsToOriginalSize">NO</bool>
<bool key="cellsHaveSubtitle">NO</bool>
<bool key="cellsHaveSubtitle">YES</bool>
<bool key="cellsHaveTitle">NO</bool>
<bool key="outlinesCells">NO</bool>
<bool key="shadowsCells">YES</bool>
Expand Down

0 comments on commit aed9b50

Please sign in to comment.