diff --git a/android/src/main/java/com/wwimmo/imageeditor/ImageEditor.java b/android/src/main/java/com/wwimmo/imageeditor/ImageEditor.java index 2800abeb..0c8f9fe6 100644 --- a/android/src/main/java/com/wwimmo/imageeditor/ImageEditor.java +++ b/android/src/main/java/com/wwimmo/imageeditor/ImageEditor.java @@ -204,32 +204,6 @@ public String getBase64(String format, boolean transparent, boolean includeImage return Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT); } - private String getMeasuredPosition(boolean cropToImageSize) { - MeasureToolEntity lastEntity = null; - for (int i = 0; i < mEntities.size(); i++) { - if (mEntities.get(i) instanceof MeasureToolEntity) { - lastEntity = (MeasureToolEntity) mEntities.get(i); - } - } - if (lastEntity != null) { - double scale = mBackgroundImage != null && cropToImageSize ? (double) mOriginalBitmapWidth / getWidth() : 1; - int pointsSize = lastEntity.getCurrentPoints().size(); - int[][] positions = new int[pointsSize][]; - for (int i = 0; i < pointsSize; i++) { - PointF position = lastEntity.getCurrentPoints().get(i); - int x = (int) (position.x * scale); - int y = (int) (position.y * scale); - positions[i] = new int[]{x, y}; - } - Map exifPositionData = new HashMap(); - exifPositionData.put("rmPoints", Arrays.deepToString(positions)); - String result = exifPositionData.toString().replace("=", ":"); - return result; - } else { - return null; - } - } - private Bitmap createImage(boolean transparent, boolean includeImage, boolean includeText, boolean cropToImageSize) { Bitmap bitmap = Bitmap.createBitmap( mBackgroundImage != null && cropToImageSize ? mOriginalBitmapWidth : getWidth(), @@ -610,7 +584,7 @@ public void save(String format, String folder, String filename, boolean transpar String path = createdFile.getPath(); this.onSaved(true, path); - this.updateExif(path, this.getMeasuredPosition(cropToImageSize)); + this.updateExif(path); success = true; } catch (Exception e) { @@ -630,15 +604,12 @@ public void save(String format, String folder, String filename, boolean transpar } - public void updateExif(String path, String position) { + public void updateExif(String path) { try { File originalFile = new File(currentFilePath); ExifInterface exif = new ExifInterface(path); exif.setAttribute(ExifInterface.TAG_IMAGE_UNIQUE_ID, originalFile.getName()); - if (position != null) { - exif.setAttribute(ExifInterface.TAG_USER_COMMENT, position); - } exif.saveAttributes(); } catch (Exception e) { Log.e("Update exif", "Failed to update exif!"); diff --git a/ios/RNImageEditor/RNImageEditor/RNImageEditor.m b/ios/RNImageEditor/RNImageEditor/RNImageEditor.m index 193f6ca9..c79626d3 100644 --- a/ios/RNImageEditor/RNImageEditor/RNImageEditor.m +++ b/ios/RNImageEditor/RNImageEditor/RNImageEditor.m @@ -558,33 +558,6 @@ - (UIImage*)createImageWithTransparentBackground: (BOOL) transparent includeImag } } -- (NSString*)getMeasuredPosition:(BOOL) cropToImageSize{ - MeasurementEntity* lastEntity = nil; - for (MotionEntity* entity in self.motionEntities) { - if ([entity class] == [MeasurementEntity class]){ - lastEntity = (MeasurementEntity *) entity; - } - } - if (lastEntity != nil) { - float scale = 1; - if (cropToImageSize == true) { - scale = _backgroundImage.size.width / self.bounds.size.width; - } - NSMutableArray* points = [lastEntity getPoints]; - NSMutableArray* positions = [NSMutableArray new]; - for (NSValue* value in points) { - CGPoint p = [value CGPointValue]; - int x = p.x * scale; - int y = p.y * scale; - NSString* position = [NSString stringWithFormat:@"[%d, %d]",x,y]; - [positions addObject:position]; - } - NSString* result = [NSString stringWithFormat:@"{rmPoints:[%@]}",[positions componentsJoinedByString:@","]]; - return result; - } - return nil; -} - - (void)saveImageOfType:(NSString*) type folder:(NSString*) folder filename:(NSString*) filename withTransparentBackground:(BOOL) transparent includeImage:(BOOL)includeImage includeText:(BOOL)includeText cropToImageSize:(BOOL)cropToImageSize { UIImage *img = [self createImageWithTransparentBackground:transparent includeImage:includeImage includeText:(BOOL)includeText cropToImageSize:cropToImageSize]; @@ -598,8 +571,8 @@ - (void)saveImageOfType:(NSString*) type folder:(NSString*) folder filename:(NSS if (error == nil) { NSURL *fileURL = [[tempDir URLByAppendingPathComponent: filename] URLByAppendingPathExtension: type]; NSData *imageData = [self getImageData:img type:type]; - NSString* measurementPosition = [self getMeasuredPosition:cropToImageSize]; - [self saveImageWithMetadata:imageData fileURL:fileURL withMeasurementPosition:measurementPosition]; + + [self saveImageWithMetadata:imageData fileURL:fileURL]; if (_onChange) { _onChange(@{ @"success": @YES, @"path": [fileURL path]}); @@ -617,7 +590,7 @@ - (void)saveImageOfType:(NSString*) type folder:(NSString*) folder filename:(NSS } } -- (void)saveImageWithMetadata:(NSData *)imageData fileURL:(NSURL*)fileURL withMeasurementPosition:(NSString*)measurementPosition +- (void)saveImageWithMetadata:(NSData *)imageData fileURL:(NSURL*)fileURL { NSString *originalFileName = [[_currentFilePath lastPathComponent] stringByDeletingPathExtension]; NSString *uniqueImageId = [self getUniqueImageId:originalFileName]; @@ -632,10 +605,6 @@ - (void)saveImageWithMetadata:(NSData *)imageData fileURL:(NSURL*)fileURL withMe [mutableExifDict setValue:uniqueImageId forKey:(NSString *)kCGImagePropertyExifImageUniqueID]; - if (measurementPosition != nil) { - [mutableExifDict setValue:measurementPosition forKey:(NSString *)kCGImagePropertyExifUserComment]; - } - [mutableMetadataDict setObject:mutableExifDict forKey:(NSString *)kCGImagePropertyExifDictionary]; NSMutableData *destData = [NSMutableData data]; diff --git a/package.json b/package.json index 0ae0f1fc..c22a079d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "type": "git", "url": "https://github.com/hoverinc/react-native-sketch-image" }, - "version": "0.8.50", + "version": "0.8.51", "description": "react-native-sketch-canvas allows you to draw / sketch on both iOS and Android devices and sync the drawing data between users. Of course you can save as image.", "author": "Terry Lin, Thomas Steinbrüchel", "main": "index.js",