Hallo Leute,
Ich habe ein Array mit URLs von Bildern und möchte diese Bilder als Tiff oder Icon mit verschiedenen Größen (gleiche Auflösung, dpi) speichern. Dazu habe ich mir folgendes überlegt:
Alles anzeigen
Allerdings resultiert das in Tiff Dateien, welche fünf mal die gleiche Größe enthalten.
Was mache ich falsch?
Gruß und Danke
Daniel
Ich habe ein Array mit URLs von Bildern und möchte diese Bilder als Tiff oder Icon mit verschiedenen Größen (gleiche Auflösung, dpi) speichern. Dazu habe ich mir folgendes überlegt:
Quellcode
- for (NSURL *url in urls) {
- NSImage *newIcon = [[NSImage alloc] init];
- NSString *fileName = [[url.path lastPathComponent] stringByDeletingPathExtension];
- // NSLog(@"Representations: %lu", newIcon.representations.count);
- NSImageRep *icon512 = [NSImageRep imageRepWithContentsOfURL:url];
- icon512.size = NSMakeSize(512, 512);
- icon512.pixelsHigh = 512;
- icon512.pixelsWide = 512;
- [newIcon addRepresentation:icon512];
- NSImageRep *icon256 = [NSImageRep imageRepWithContentsOfURL:url];
- icon256.size = NSMakeSize(256, 256);
- icon256.pixelsHigh = 256;
- icon256.pixelsWide = 256;
- [newIcon addRepresentation:icon256];
- NSImageRep *icon128 = [NSImageRep imageRepWithContentsOfURL:url];
- icon128.size = NSMakeSize(128, 128);
- icon128.pixelsHigh = 128;
- icon128.pixelsWide = 128;
- [newIcon addRepresentation:icon128];
- NSImageRep *icon32 = [NSImageRep imageRepWithContentsOfURL:url];
- icon32.size = NSMakeSize(32, 32);
- icon32.pixelsHigh = 32;
- icon32.pixelsWide = 32;
- [newIcon addRepresentation:icon32];
- NSImageRep *icon16 = [NSImageRep imageRepWithContentsOfURL:url];
- icon16.size = NSMakeSize(16, 16);
- icon16.pixelsHigh = 16;
- icon16.pixelsWide = 16;
- [newIcon addRepresentation:icon16];
- NSError *saveERROR;
- [[newIcon TIFFRepresentation] writeToFile: [[self applicationCustomIconsDirectory].path stringByAppendingFormat:@"%@.tiff", fileName] options:NSDataWritingAtomic error:&saveERROR];
- }
Allerdings resultiert das in Tiff Dateien, welche fünf mal die gleiche Größe enthalten.
Was mache ich falsch?
Gruß und Danke
Daniel
“I want to see an elephant hunt down a man for the sole purpose of collecting his teeth, while a chorus of typewriters sings songs that praises the bananas for their wisdom, leadership, and their high levels of potassium.” ― Jarod Kintz, I Want