Coder Social home page Coder Social logo

react-native-exif's Introduction

React Native Exif

All Contributors

An image exif reader

Installation

yarn add react-native-exif
react-native link

or

npm install react-native-exif --save
react-native link

Usage

getExif

import Exif from 'react-native-exif'

...

Exif.getExif('/sdcard/tt.jpg')
    .then(msg => console.warn('OK: ' + JSON.stringify(msg)))
    .catch(msg => console.warn('ERROR: ' + msg))

...

Exif.getExif('content://media/external/images/media/111')
    .then(msg => console.warn('OK: ' + JSON.stringify(msg)))
    .catch(msg => console.warn('ERROR: ' + msg))

...

Exif.getExif('assets-library://asset/asset.JPG?id=xxxx&ext=JPG')
    .then(msg => console.warn('OK: ' + JSON.stringify(msg)))
    .catch(msg => console.warn('ERROR: ' + msg))

Exif values

Value
ImageWidth
ImageHeight
Orientation
originalUri
exif

getLatLong

Fetch geo coordinates as floats.

...
Exif.getLatLong('/sdcard/tt.jpg')
    .then(({latitude, longitude}) => {console.warn('OK: ' + latitude + ', ' + longitude)})
    .catch(msg => console.warn('ERROR: ' + msg))
...

Version 0.1.0 add react-native 0.40 support

Contributors

Thanks goes to these wonderful people (emoji key):


francisco-sanchez-molina

๐Ÿ’ป

Kesha Antonov

๐Ÿ’ป

Olivier Collet

๐Ÿ’ป

hygkui

๐Ÿ’ป

EurekaO

๐Ÿ’ป

Colin Basnett

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

react-native-exif's People

Contributors

charlesps avatar cmbasnett avatar eurekao avatar francisco-sanchez-molina avatar hygkui avatar jtweaver avatar kesha-antonov avatar krunalsshah avatar lata2694 avatar mars-lan avatar ocollet avatar tjamescouch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-exif's Issues

why exif result has not model or other exif information in android?

why result only has ImageWidth,ImageHeight,Orientation? how to get others?

return NativeModules.ReactNativeExif.getExif(path).then(result => {
if (Platform.OS === 'android') {
return unifyAndroid(result)
} else {
return unifyIOS(result)
}
})
i find other result is null, such as model

3ks

Does this work with remote urls?

I'm currently trying to get exif data using a remote url but the promise is not being fulfilled.

Is this possible with the current library?

[iOS] Exif data is impoverished due to unnecessary translation step

There is an unnecessary translation step being taken that is eliminating a lot of EXIF data. The lines in question are:

The problem is that loading the image as a UIImage actually jettisons a lot of data for reasons only Apple knows, however this is a pretty succinct explanation as to why you shouldn't use this method to fetch EXIF data here. I'll paraphrase the key point though:

The full metadata in an image file can be far richer than the data obtained from a UIImage object derived from the file. If you want to retain all of the metadata, you need to read the file data object as data, not as UIImage.

Issues #7 and #10 are directly related to this problem.

The solution is to replace:

UIImage * myImage = [UIImage imageWithContentsOfFile: path];
NSData* pngData = UIImageJPEGRepresentation(myImage, 1.0);

with:

NSData* pngData = [NSData dataWithContentsOfFile: path];

As a nice side benefit, this also eliminates the need for the computationally expensive call to UIImageJPEGRepresentation.

react native 0.48.4 update issue

Hi,
we have updated react native to 0.48.4 and when i ran react-native run-android i see below error

A problem occurred configuring project ':react-native-exif'.
      > Could not resolve all dependencies for configuration ':react-native-exif:_debugPublishCopy'.
         > Could not find any version that matches com.facebook.react:react-native:0.47.+.
           Versions that do not match:
               0.20.1
               0.20.0
               0.19.1
               0.19.0
               0.18.0
               + 13 more
           Required by:
               Driver:react-native-exif:unspecified

package.json

"react-native": "^0.48.4",
"react-native-exif": "^0.1.5",

Orientation info

Hey there,

In the exif information, the orientation information returns one. But the picture seem to the left.
Is this orientation correct? Orientation information shouldn't be 6?

Cant read geolocation of image

Hey there!

Whatever i do when i try to get the location out of an Image then somehow there is no location data in my response. I have double checked if the image has a geolocation metadata with www.get-metadata.com just to be sure there is any metadata.

Any ideas why this happens?

Exif.getLatLong(absoluteImagePath)
  .then(({latitude, longitude}) => {console.warn('OK: ' + latitude + ', ' + longitude)})
  .catch(msg => console.warn('ERROR: ' + msg))

Error "TypeError: Cannot read property 'latitude' of undefined"

ENV:
react-native 0.53.0
react-native-exif 0.3.0
iOS / Simulator & real device

Exif.getExif() callback are not called

i get a bug on IOS , on android it work ( logs are displayed )
my problem is the getExif() don't call the callback, nothing happen.

my test code :

 import ImagePicker from "react-native-image-crop-picker"; // version "^1.2.2"
  import Exif from "react-native-exif";  // version "0.1.5"
 


testfromlib(){
  ImagePicker.openPicker({
    width: 300,
    height: 400,
    cropping: false
  }).then(image => {
    console.log(image); // this log me the image object : 
    /* log this :
      data  :  null
      exif  :  null
      filename  :  "IMG_0338.JPG"
      height  :  3264
      localIdentifier  :  "7388B8DC-A2B6-4ECD-B02E-7EC3432AECBC/L0/001"
      mime  :  "image/jpeg"
      path  :  "/private/var/mobile/Containers/Data/Application/27EA2F8F-039F-400F-B32A-836768451015/tmp/react-native-image-crop-picker/9AEA097A-6989-4D02-A775-FCF7E64D2747.jpg"
      size  :  8499929
      sourceURL  :  "file:///var/mobile/Media/DCIM/100APPLE/IMG_0338.JPG"
      width  :  2448
    */ 
    console.log("exif from "+ image.sourceURL);
    // log this : "exif from file:///var/mobile/Media/DCIM/100APPLE/IMG_0338.JPG" 
   
    Exif.getExif(image.sourceURL)
      .then(msg => {
        console.log("selected image exif", msg);              // NOT LOGGED  !
      }).catch(msg => console.log("ERROR: " + msg));   // NOT LOGGED  !
  });
}

from camera roll it work :

  testfromcamera(){
    ImagePicker.openCamera({
      width: 300,
      height: 400,
      cropping: false
    }).then(image => {
      console.log("exif from "+ image.path);
      //log this :  exif from /private/var/mobile/Containers/Data/Application/27EA2F8F-039F-400F-B32A-836768451015/tmp/react-native-image-crop-picker/EF3F7E1D-DE76-4D48-9C5A-AB80608095E1.jpg
      Exif.getExif(image.path)
        .then(msg => {
          console.log("selected image exif", msg);  // log is displayed           
        }).catch(msg => console.log("ERROR: " + msg));
    });
  }

what i'm trying to do is

  1. to let user to choose between taking a new shoot with camera or loading one from gallery,
  2. get the exif of the image
  3. crop the image

did i miss something in the testfromlib function ?

(Exif.getExif) TypeError: undefined is not an object

Hello, I am trying to use this library and I get the following error:
react-native: 0.51.0

TypeError: undefined is not an object (evaluating '_reactNative.NativeModules.ReactNativeExif.getExif')

These were the changes made during the Linking

MainActivity.java:

import com.devialab.exif.RCTExifPackage;

build.gradle:

import com.devialab.exif.RCTExifPackage;

settings.gradle:

include ':react-native-exif'
project(':react-native-exif').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exif/android')

Will this error come up when an image path is not correct?
Can this library support reading from a base64 string?

Feature Request: Write to MetaData

Great module and quite useful. I'm curious about extending this to make it possible to write to the metadata. For example, modify different elements of the EXIF or write to the IPTC metadata in keywords. REF: https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/IPTC.html How feasible would it be to extend this library or better to consider creating a different project?

I'd prefer to help on this project before writing my own code which would duplicate some of these functions like reading metadata.

getLatLong only returns positive values for lat and long

Exif.getLatLong() returns the absolute value of the latitude and longitude (ie. both positive and N lat and W long) and doesn't include the latitude and longitude direction. The other method, Exif.getExif() does return the N, E, S, W information, but I'm having the issue that it won't call the callback, see #14.

`react-native link` required?

Hi. I'm attempting to use this package while developing in Expo but it doesn't seem to work.

Cannot read property 'getExif'

Do we need to react-native link to use the package? Thanks.

Change import React/RCTBridgeModule to React/Base/RCTBridgeModule

When trying to use this project on iOS I get file not found at:

import <React/RCTBridgeModule.h>

In react-native-exif/ios/ReactNativeExif/ReactNativeExif.h we have an import:

#import <React/RCTBridgeModule.h>

But in recent versions of React Native the included file resides in /react-native/React/Base/RCTBridgeModule.h

I guess the fix would be to change from #import <React/RCTBridgeModule.h> to #import <React/Base/RCTBridgeModule.h>

Need java developer

Hi, @francisco-sanchez-molina Are you available for hire? I need some help with a java project and would like to support a developer that works in the open source community. Sorry to post this as an issue, but I was not sure of any other way to contact you.

File path when getting exif data

Hi, I just try your library but not really know how to access my file with exact filepath
image
My source code is in BottomSheet.js and the image that I want to get the exif data is photo.jpg in image folder.

Cannot read property of getExif

Getting the following error
screen shot 2017-08-29 at 10 12 51 am

It also seems when I do the following

import Exif from 'react-native-exif'

Export is not defined for Exif

Missing image results in promise never resolving on iOS

In my testing on iOS I noticed promises were not being resolved for my images (using ph:// prefix)

Digging deeper into the native code I found this code containing the resolve()

if (mySourceRef != NULL)
            {
                NSDictionary *exif = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL);
                CFRelease(mySourceRef);

                NSDictionary *mutableExif = [exif mutableCopy];
                [mutableExif setValue:path forKey:@"originalUri"];
                resolve(mutableExif);
            }

but if mySourceRef == NULL it is not handled and nothing is ever returned.

I am still looking into why my file paths are not working, but I think this error should be handled better regardless.

java.lang.IllegalArgumentException: filename cannot be null ( Image uploaded from camera )

Platform : Android
React Native version : 0.60.5
react-native-exif : 0.4.0

can not read the uri
uri: "content://com.demo.provider/external_files/Pictures/images/image-e2c35a06-561c-4d7a-bb84-cea653fc7bee.jpg"

please provide the solution..

if i choose the image from gallery than it is working perfectly but if i upload from camera than it gives error of java.lang.IllegalArgumentException: filename cannot be null

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

I get the following warning when upgrading from React Native 0.59.10 to 0.62.2:

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

I useimplementation project(':react-native-exif') in my Gradle file and still get this error. Do you have an idea what might cause this warning?

Read file from Camera roll (android)

Android 8.0

react-native: 0.55.4
react-native-exif: 0.3.0
react-native-image-picker: 0.26.10

Can't read like this uri content://

used

Example:

{ 
    "uri": "content://com.example.provider/app_images/Pictures/image-d0b54655-92ca-4fa4-8414-400b595c54d0.jpg" 
}

Error:

Error: java.lang.IllegalArgumentException: filename cannot be null

Can't build on Android - "Exif.java uses or overrides a deprecated API."

Thanks - this library has been a lifesaver for me for images losing their orientation when they get uploaded to our server via RNFetchBlob.

It builds fine on iOS in the same project.

...
:react-native-exif:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/farhan/code/ourpathrn/node_modules/react-native-exif/android/src/main/java/com/devialab/exif/RCTExifPackage.java:13: error: RCTExifPackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class RCTExifPackage implements ReactPackage {
       ^
Note: /Users/farhan/code/ourpathrn/node_modules/react-native-exif/android/src/main/java/com/devialab/exif/Exif.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:react-native-exif:compileReleaseJavaWithJavac FAILED

I'm on react-native-cli version 2.0.1, react-native version 0.45.1

Any ideas? If it's a simple Java fix, if someone can explain what to do, I'll do a PR...

error: package com.devialab does not exist

i get this error after installing the plugin and linking it with rnpm then running "react-native run-android"

D:\workspace\reacttest\android\app\src\main\java\com\iosreacttestplantnet2\MainActivity.java:4: error: package com.devialab does not exist
import com.devialab.exif.RCTExifPackage;
				   ^
1 error
:app:compileDebugJavaWithJavac FAILED

in the following folder i have the files Exif.java and RCTExifPackage.java

D:\workspace\reacttest\node_modules\react-native-exif\android\src\main\java\com\devialab\exif


content of RCTExifPackage.java :

package com.devialab.exif; ...
public class RCTExifPackage implements ReactPackage {...}

no exif on android

Hi,
on Android I'm not able to retrieve some metadata, which are available on iOS.
For example copyright info (I have added ExifInterface.TAG_COPYRIGHT to EXIF_ATTRIBUTES in Exif.java) is not available on Android, while it can be reached in response.exif['{IPTC}'].CopyrightNotice.
I know it's highly possible this problem is not connected with this library, but maybe someone is more common with ExifInterface and will have some solution.

[iOS] Major memory leak

There is a large memory leak in the core functionality of this library on iOS.

The lines in question state the following:

CGImageSourceRef mySourceRef = CGImageSourceCreateWithData((CFDataRef)pngData, NULL);

The image data is being copied to the new mySourceRef object, but the memory is never being released with CFRelease. The documentation for CGImageSourceCreateWithData specifically states that:

You are responsible for releasing this object using CFRelease.

There are two of these allocations, being performed on these lines:

https://github.com/francisco-sanchez-molina/react-native-exif/blob/master/ios/ReactNativeExif/ReactNativeExif.m#L45
https://github.com/francisco-sanchez-molina/react-native-exif/blob/master/ios/ReactNativeExif/ReactNativeExif.m#L101

Using this library on sets of images of any appreciable size will balloon the app's memory out immensely and make the app unusable.

Unable to extract exif from images with ph:// prefix on iOS

When trying to load image EXIF data on iOS this library is failing consistently.

This appears to be due to the native code using the deprecated ALAssetsLibrary.

There are many warnings when building for iOS related to this, eg.

'ALAssetsLibrary' is deprecated: first deprecated in iOS 9 - Use PHPhotoLibrary from the Photos framework instead [-Wdeprecated-declarations]

Edit: For what it's worth -- I've created a fork of the project with a hacky fix with the help of Github Copilot that resolves the issue for me. I do not know Objective-C though so who knows how good the AI generated code is! I'm not sure if it's worth creating a PR with that "fix". It probably needs to be reviewed by someone who understands the language.

Exif data missing GPS

I'm getting back the following data it's missing the GPS is this correct

{"ImageWidth":1125,"ImageHeight":1500,"Orientation":1,"originalUri":"/private/var/mobile/Containers/Data/Application/CCE342DF-CB0D-475E-8975-FEF1F42EA956/tmp/react-native-image-crop-picker/644D5A44-608F-45BB-A350-58DB27E2895F.jpg","exif":{"{JFIF}":{"DensityUnit":0,"YDensity":72,"XDensity":72,"JFIFVersion":[1,0,1]},"ProfileName":"sRGB IEC61966-2.1","{TIFF}":{"Orientation":1},"{Exif}":{"PixelYDimension":1500,"PixelXDimension":1125,"ColorSpace":1},"ColorModel":"RGB","PixelHeight":1500,"Depth":8,"Orientation":1,"originalUri":"/private/var/mobile/Containers/Data/Application/CCE342DF-CB0D-475E-8975-FEF1F42EA956/tmp/react-native-image-crop-picker/644D5A44-608F-45BB-A350-58DB27E2895F.jpg","PixelWidth":1125}}

And this is the image uri
/private/var/mobile/Containers/Data/Application/25E25800-C51F-44BE-BEDA-B9DA7CE4CEBA/tmp/react-native-image-crop-picker/26C6E09D-571F-4745-BBA4-ABB0FCCFE7DD.jpg

I'm using the react-native-image-crop-picker the image is stored in a temp folder maybe that is the issue.

Android createJSModules error on build

There is a method which must be implemented on latest version of ReactPackage in order to compile successfully.

This is the error during react-native run-android command

/node_modules/react-native-exif/android/src/main/java/com/devialab/exif/RCTExifPackage.java:13: error: RCTExifPackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class RCTExifPackage implements ReactPackage {

This is the expected fix to be implemented :

public List<Class<? extends JavaScriptModule>> createJSModules() {
            return Collections.emptyList();
        }

Regards.
Marcelo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.