imagemagick - nstask

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • imagemagick - nstask

    Hallo,

    ich will gern per nstask einen bald converter anstreben -

    mein problem ist wie ich die images richtig rein gebe - hat hier jemand einen tipp oder ein Idee ?

    Danke

    C-Quellcode

    1. -(id)init
    2. {
    3. if ([super init])
    4. {
    5. NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
    6. NSString* imageMagickPath = [bundlePath stringByAppendingPathComponent:@"/Contents/Resources/ImageMagick"];
    7. NSString* imageMagickLibraryPath = [imageMagickPath stringByAppendingPathComponent:@"/lib"];
    8. MAGICK_HOME = imageMagickPath;
    9. DYLD_LIBRARY_PATH = imageMagickLibraryPath;
    10. }
    11. return self;
    12. }
    13. -(void)composite
    14. {
    15. NSTask *task = [[NSTask alloc] init];
    16. NSLog(@"start");
    17. // the ImageMagick library needs these two environment variables.
    18. NSMutableDictionary* environment = [[NSMutableDictionary alloc] init];
    19. [environment setValue:MAGICK_HOME forKey:@"MAGICK_HOME"];
    20. [environment setValue:DYLD_LIBRARY_PATH forKey:@"DYLD_LIBRARY_PATH"];
    21. NSString* pwd = [[self class] pathFromUserLibraryPath:@"Moenster"];
    22. // executable binary path
    23. NSString* exe = [MAGICK_HOME stringByAppendingPathComponent:@"/bin/convert"];
    24. [task setEnvironment:environment];
    25. [task setCurrentDirectoryPath:pwd]; // pwd
    26. [task setLaunchPath:exe]; // the path to composite binary
    27. // these are just example arguments
    28. [task setArguments:[NSArray arrayWithObjects: @"/Users/michael/Downloads/big/001.png", @"/001.dds", nil]];
    29. [task launch];
    30. [task waitUntilExit];
    31. NSLog(@"end");
    32. }
    33. - (NSString *) pathFromUserLibraryPath:(NSString *)inSubPath
    34. {
    35. NSArray *domains = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
    36. NSString *baseDir= [domains objectAtIndex:0];
    37. NSString *result = [baseDir stringByAppendingPathComponent:inSubPath];
    38. return result;
    39. }
    Alles anzeigen