Tag: alassetslibrary

UIImage的元数据字典没有得到IPTC密钥的值

在保存屏幕截图的同时,我正在尝试改变UIImage对象的元数据,用于自定义标题和图像描述。 导入的标题 #import <AssetsLibrary/AssetsLibrary.h> #import <ImageIO/ImageIO.h> #import <ImageIO/CGImageProperties.h> 在我的方法里面 NSData* dataOfImageFromGallery = UIImageJPEGRepresentation(imageToSave, 1.0); CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)dataOfImageFromGallery, NULL); NSMutableDictionary* metaData = (NSMutableDictionary *) CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(imageSource,0,NULL)); //–> metaData dictionary without ITPC key if (imageSource == NULL) { // Error loading image NSLog(@"ERROR while loading screenshot image: %@",error); return; } NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], […]

UIImage方向Swift

我已经编写了这个代码来使用Swift中的AVFoundation库来捕获图像: @IBAction func cameraButtonWasPressed(sender: AnyObject) { if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo){ stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection){ (imageSampleBuffer : CMSampleBuffer!, _) in let imageDataJpeg = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer) var pickedImage: UIImage = UIImage(data: imageDataJpeg)! let library = ALAssetsLibrary() library.writeImageToSavedPhotosAlbum(pickedImage.CGImage, metadata:nil, completionBlock:nil) } } } 它工作正常,但是当我去照片库图像显示逆时针旋转90度。 有人可以给我一个暗示,在哪里挖来解决这个问题?

如何从iOS的ALAsset获取video的缩略图图像?

我想从video中获取每帧的缩略图图像,然后将这些图像保存在可变数组图像中。 我想用这个图像作为animation播放。 NSURL* assetURL = [self.asset valueForProperty:ALAssetPropertyAssetURL]; NSDictionary* assetOptions = nil; AVAsset* myAsset = [[AVURLAsset alloc] initWithURL:assetURL options:assetOptions]; self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset]; int duration = CMTimeGetSeconds([myAsset duration]); for(int i = 0; i<duration; i++) { CGImageRef imgRef = [self.imageGenerator copyCGImageAtTime:CMTimeMake(i, duration) actualTime:NULL error:nil]; UIImage* thumbnail = [[UIImage alloc] initWithCGImage:imgRef scale:UIViewContentModeScaleAspectFit orientation:UIImageOrientationUp]; [thumbnailImages addObject:thumbnail]; } 我使用上面的代码来获取缩略图图像,但问题是如果有一个2秒的video,我只得到2个缩略图,但我想要20个缩略图(10个缩略图每秒)。 那么,如何使用CMTimeMake来获取每一秒的缩略图

保存生成的GIF到相机胶卷?

谢谢阅读。 我用这个问题的方法创build了一个GIF: 通过iOS创build和导出animationgif? 我试图使用唯一的方法,似乎可以将非JPG / PNG图像保存到相机胶卷, ALAssetLibrary的writeImageDataToSavedPhotosAlbum:metadata:completionBlock: 我将Gif保存到temp目录中,如下所示: NSString *exportPath = [NSTemporaryDirectory() stringByAppendingString:@"/animated.gif"]; NSURL *fileURL = [NSURL fileURLWithPath:exportPath isDirectory:NO]; 然后像这样访问NSData : NSData * gifData = [NSData dataWithContentsOfFile:fileURL.absoluteString]; GIF是创build的,因为我能够在UIImageView显示它,但是当我尝试保存它时,该方法返回成功(没有错误),但实际上并没有保存(返回NSURL * assetURL为NSURL * assetURL ,不会出现在相机胶卷中)。 我怎样才能让我的GIF成功保存到相机胶卷?

如何访问相册中保存的照片?

我在应用程序中使用代码将照片保存到自定义的相册中 [library saveImage:self.capturedImg toAlbum:@"FunCam" withCompletionBlock:^(NSError *error) { if (error!=nil) { NSLog(@"Big error: %@", [error description]); } }]; 现在我想检索保存到该相册的所有照片,当用户点击一些button,并显示他们像相机应用程序(iPhone上的默认应用程序)的视图显示 请帮我,我该怎么做? 提前致谢

我可以通过截图检测导入的ALAsset照片吗?

我有一个imagePickerController用于从库中导入照片到我的应用程序。 当在ALAssetsLibraryAssetForURLResultBlock ,我试图找出我在块中获得的ALAsset是作为屏幕截图拍摄的照片,还是照相机拍摄的“真正”照片。 我试图通过ALAsset的元数据字典,但找不到任何可能适合的标志/指示。 有人有主意吗?

ALAssetsLibrary获取相机胶卷

我使用ALAssetsLibrary枚举所有资产组 这是代码: ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) { if (group == nil) { // enumerated all albums.. } // I hot to check if group is Camera Roll ? }; [library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:enumerate failureBlock:nil]; 如何检查一些当前列举的是CameraRoll ? 编辑:正如我testing它始终是最后一个,使用这个枚举。 但是我不确定这是否是规则,有没有我错过的参考?

有没有人在后台线程中使用ALAssetsLibrary时遇到崩溃?

我有一个ios应用程序,它没有以这种方式在ios 5上崩溃,现在ios 6在4或5 bg / fg周期启动后一直崩溃。 我已经将问题追溯到ALAssetsLibrary enumerateGroupsWithTypes的调用(每当启动时,应用程序都会同步到底层的照片库)。 对enumerateGroupsWithTypes的调用是在通过调度队列调用的后台线程中完成的,因此即使用户在完成之前将应用程序发送给bg,同步代码也可以完成。 我收到的崩溃消息总是相同的: * __addContextToList_block_invoke_0()中的断言失败,/ SourceCache / PhotoLibraryServices / MobileSlideShow-1647.5/Sources/PLManagedObjectContext.m:1305 和 *由于未捕获exception'NSInternalInconsistencyException',原因:'上下文太多。 contextList中没有空格。 谷歌search这些错误消息还没有产生任何东西。 因为直到应用程序循环打开/closures至less5次,才会发生这种情况,我想这些程序块在完成后可能没有从苹果数据结构中正确删除? 预先感谢任何线索。 更新:经过更多调查后,这似乎与同步ALAssetsGroupLibrary相关。 当我只同步ALAssetsGroupSavedPhotos或者ALAssetsGroupLibrary中有0张照片时,崩溃不会发生。 如果我仅同步ALAssetsGroupLibrary,并且至less有1张照片,则会发生这种情况。

从IOS中的IPhone删除资产(图片或video)

我正在使用Iphone应用程序,我可以使用Assetslibrary枚举资产并将它们加载到表视图中。 用户可以删除应用程序中的一行(图片/video),但是如何直接从我的应用程序更新Iphone相册? 否则刷新,tableview将重新加载以前删除的资产。

ALAssetsLibrary太慢 – Objective-C

什么是从相机胶卷,保存的照片加载10-20全屏图像的快速方式? 我使用这个代码,但加载10张照片,我需要等待大约5-10秒。 我正在使用iPhone 4S。 ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { if(_savedPhotos.count>=11) *stop = YES; [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *needToStop) { NSLog(@"%d",index); if(_savedPhotos.count<11) { UIImage *image = [UIImage imageWithCGImage:result.defaultRepresentation.fullScreenImage]; [_savedPhotos addObject:image]; } else { *needToStop = YES; } }]; } failureBlock:^(NSError *error) { NSLog(@"%@",error.description); }];