我有从图像库中访问的图像。我想将此图像存储在数据库中,稍后重新调整大小并将其张贴到服务器。如果图像被压缩,是否可以告诉我是否会丢失EXIF数据?我的原始图像有EXIF数据。如果数据没有丢失。请指导,我怎么可以压缩和重新大小的图像iphone使用exif数据缩小图像的大小(以字节为单位)
0
A
回答
4
- 调整图像大小的回答
地块在这一领域,例如:在https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more
- 图片The simplest way to resize an UIImage?或更多的细节压缩
您可以使用UIImageJPEGRepresentation C函数,声明为...
NSData * UIImageJPEGRepresentation (
UIImage *image,
CGFloat compressionQuality
);
...您可以传递UIImage对象,并将范围0.0(最大压缩)的压缩质量设置为1.0(最佳质量)。
- EXIF损失
在https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more
0
见的答案,如果你想不失EXIF压缩的图像,首先你应该得到的图像的特性,以及数据UIImageJPEGRepresentation你得到不包含EXIF。
1:getoritatinal图像数据 2:压缩providerData 3:WITE EXIF压缩数据
- (void)setImagePropertyWith:(ALAsset *)asset
{
//get full imageData
ALAssetRepresentation * defaultRep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(defaultRep.size);
NSUInteger buffered = [defaultRep getBytes:buffer fromOffset:0.0 length:defaultRep.size error:nil];
NSData * data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
// compressData providerData
CGDataProviderRef jpegdata = CGDataProviderCreateWithCFData((CFDataRef)data);
CGImageRef imageRef = CGImageCreateWithJPEGDataProvider(jpegdata, NULL, YES, kCGRenderingIntentDefault);
UIImage * image = [UIImage imageWithCGImage:imageRef];
NSData* finaldata = UIImageJPEGRepresentation(image, 0.5);
//compressData with exif
finaldata = [self writeExif:(NSDictionary *)[self getPropertyOfdata:data] intoImage:finaldata];
}
- (CFDictionaryRef)getPropertyOfdata:(NSData *)data
{
CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)data, NULL);
if (imageSource == NULL) {
// Error loading image
return nil;
}
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)options);
NSLog(@"ori:%@",imageProperties);
return imageProperties;
// [self writeExif: (NSDictionary *)imageSource intoImageData:data];
}
+0
你忘了发布writeExif方法 – CGR 2017-11-22 22:18:36
相关问题
- 1. 以像素为单位调整字节数组图像的大小
- 2. 以字节为单位获取图像大小以检查不良图像
- 3. 如何使用ffmpeg以MB为单位缩小视频大小?
- 4. 使用javascript确定图像大小(以像素为单位)
- 5. 如何用Delphi以字节为单位获取图像的大小?
- 6. 固定大小像素字体的Emacs字体大小(以像素为单位)?
- 7. 使用jquery缩小图像大小?
- 8. 获取HTTPRequest/HTTPResponse头字节大小(以字节为单位)
- 9. php如何将文件大小从字节单位缩小到较大的单位而不用数字舍入
- 10. 如何用PHP和GD获取图像资源大小(以字节为单位)?
- 11. 如何确定PyTables数组的大小(以字节为单位)?
- 12. 如何计算以字节为单位的节点大小
- 13. 图像压缩的大小 - iPhone SDK
- 14. 表单大小以字节使用JavaScript?
- 15. 使用jQuery检测字体大小(以像素为单位)
- 16. 以字节为单位的已用内存。 Linux堆块大小
- 17. 以字节为单位的UTF-8字符串大小
- 18. 以字节为单位的字典大小
- 19. 以字节为单位测量字符串的大小php
- 20. 以像素为单位的字体大小和分数
- 21. 将iPhone摄像头图像缩小到应用程序图标大小 - 不仅仅是立体图像,而是以非常低的字节大小
- 22. BitmapFactory.decodeResource位图不以像素为单位的原始大小
- 23. 以像素为单位的图像大小,从Photoshop到网页
- 24. 以字节为单位给出的不准确的NSData大小
- 25. 以字节为单位的RSA签名的大小是多少?
- 26. 得到的NodeJS变量的大小以字节为单位
- 27. 以字节为单位的类的大小
- 28. 在iphone应用程序的图像视图中缩小图像大小
- 29. 使用iphone-exif EXIF数据
- 30. svn修订版的大小(以字节为单位)
感谢您的回答。 Wil看着它 – rakendu 2011-02-17 08:53:24