我有從圖像庫中訪問的圖像。我想將此圖像存儲在數據庫中,稍後重新調整大小並將其張貼到服務器。如果圖像被壓縮,是否可以告訴我是否會丟失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