Coder Social home page Coder Social logo

cloudacy / native_exif Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 14.0 131 KB

A simple EXIF metadata reader/writer for Flutter.

License: MIT License

Kotlin 23.35% Ruby 6.70% Swift 28.28% Objective-C 2.11% Dart 39.56%
android flutter flutter-plugin ios

native_exif's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

native_exif's Issues

Example project doesn't work

Thanks for this package ๐Ÿ™Œ

I've just tried running the example project on an Android emulator and got the following errors in my logs

/Users/mos/IdeaProjects/temp/native_exif/example/android/app/src/debug/AndroidManifest.xml Error:
	android:exported needs to be explicitly specified for element <activity#com.cloudacy.native_exif_example.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for element <activity#com.cloudacy.native_exif_example.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 7s
Exception: Gradle task assembleDebug failed with exit code 1

Exif atributes only change in android emulator.

Hello, I'm having a problem where the image exif attributes only change in android emulator, but when I'm trying in a real smartphone (S20fe) the exif does not change or update.

Heres the code part:

final exif = await Exif.fromPath(imagefile);
debugPrint('Image file has been loaded');

final attributes = await exif.getAttributes();

await exif.writeAttribute('DateTimeOriginal', videoDate!);

if(location!=null) {
await exif.writeAttributes({
'GPSLatitude': lat,
'GPSLatitudeRef': latRef,
'GPSLongitude': lon,
'GPSLongitudeRef': lonRef,
});
}

debugPrint('Date time altered to:');
debugPrint(videoDate.toString());

debugPrint('Location altered to:');
debugPrint('$lat$latRef $lon$lonRef');

final result = await exif.writeAttributes(attributes!);
await exif.close();

debugPrint('Image attributes has been set');

EXIF data not being written to image

Hi there,
I want to add a custom EXIF data to image selected from gallery. This is the code I have written that sets the "UserComment" attribute to "logoboa".

final Exif exif = await Exif.fromPath("${storage.path}/logo.png");
await exif.writeAttribute("UserComment", "logoboa");
print(await exif.getAttributes());
await exif.close();

When I print using exif.getAttributes(), i find that the attribute has been set as seen below:
{UserComment: logoboa, ImageWidth: 0, ImageLength: 0, Orientation: 0}

Now when i load the image later, i see that the changes are not being made:

// get the image path
String path = _image!.path;
final Exif exif = await Exif.fromPath(path);
final data = await exif.getAttributes();
print(data);

The data printed does not contain "UserComment" attribute as seen below:
{ImageWidth: 0, ImageLength: 0, Orientation: 0}

Device being used is an Android Emulator. What am I doing wrong here?

[Documentation] Missing README.md

Hello,
I found this package on pub.dev but it seems that you forgot to modify the default README.md.
I almost overlooked this package because of this lack of informations on the package, so I think it would help it getting the popularity it deserves!
Regards.

Writing Exif Data to in-memory buffer

Hello,

I was wondering if it would be possible to write exif data directly to an in-memory buffer, instead of having to write the file (even temporarily) to storage. Something like

final exif = await Exif.fromBytes(imageBytes);
...
final newImage = await exif.getImageBytes();
await exif.close(); 

would be perfect.

Dependabot upgrading unwanted versions

Hello, I don't think its a good idea to let the dependabot to make changes on the android folder, the versions should only be increased when recommended by flutter.

in this example, it bumped the Kotlin version and its the only package that is requesting me to increment the Kotlin version on my app.

320de9c

the same can be said for the gradle version being increased just recently

d1ed3d0

GPSLatitude and GPSLongitude is not working

I use the below code to update the exif data of a picked image.

Position position = await _determinePosition();

final exif = await Exif.fromPath(_pickedImage!.path);
final file = File('${Directory.systemTemp.path}/temp.jpg');
final imageBytes = await _pickedImage!.readAsBytes();
await file.create();
await file.writeAsBytes(imageBytes);
final attributes = await exif.getAttributes();
final newExif = await Exif.fromPath(file.path);

attributes!['GPSLatitude'] = position.latitude.toString();
attributes['GPSLongitude'] = position.longitude.toString();
attributes['GPSLatitudeRef'] = "N";
attributes['GPSLongitudeRef'] = "E";

await newExif.writeAttributes(attributes);

But it did not add GPSLatitude and GPSLongitude data to the exif data. It only adds GPSLatitudeRef and GPSLongitudeRef.

I am using native_exif: ^0.2.0 package.

GPS coords not decoded when on mobile network

Good evening to everyone,
I'm using the following code to get an image from a remote address but a strange behaviour happens:
If the code is executed when the device is connected to a wireless network all it is working fine; otherwise if I use the normal 4g/5g network it simply doesn't work.

Could you give me some suggestion?
I'm using the latest version of this plugin (native_exif: ^0.4.0).

From my side I can say that:

  • I'm able to load the image showing it on the phone screen
  • I'm using the following solution to enable "http://*" connections: link

P.S. url = "http://65.108.239.148/verdeco/allegati/commesse/4107/223005/9_4107.jpg"

import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart' as path_provider;
import 'package:path/path.dart' as path_instance;

Future<ExifLatLong?> getImageCoords(String url) async 
{
    // Get image from url
    final response = await http.get(Uri.parse(url));

    // Get the image name
    final imageName = path_instance.basename(url);

    // Get the document directory path
    //final appDir = await path_provider.getApplicationDocumentsDirectory();
    final appDir = await path_provider.getApplicationSupportDirectory();

    // This is the saved image path
    // You can use it to display the saved image later
    final localPath = path_instance.join(appDir.path, imageName);

    // Downloading
    final imageFile = File(localPath);
    await imageFile.writeAsBytes(response.bodyBytes);

    // Extract exif
    var exif = await Exif.fromPath(localPath);
    var coords = await exif.getLatLong();
    await exif.close();
    await imageFile.delete();
    return coords;
  }

Exif data not read

Hello, I have a lot of images where exif data cannot be read by your plugin, although they are perfectly read by Finder on Mac. I have joined an example. Could you please help ?
20221206-095502-13352

Altitude value

I want to set the altitude value, await exif.writeAttribute("key", "value"); I tried with but it didn't work

Unable to Read and Write Exif Data.

Input Source:

sample

Exif Info:

Screenshot 2022-09-04 at 7 41 17 PM

Given:
Under More Info Section, Exif Tab is missing

Output:

While reading the EXIF data for the given Image, the Library throws the exception. i.e No Exif data was found on this image

PlatformException(READ_ERROR, No Exif data was found on this image., null, null)

Use Case :

I want to add custom info in User Comment key in exif data.

Video compatibility

Hey! I've been trying to use the exif reader with video but having no luck.
I've tried with multiple mp4 files, and some mov files.

It works fine with images I've tested with. Is it for images only?

The error I get is:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(READ_ERROR, Error while reading metadata from source, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
#2      Exif.getAttributes (package:native_exif/native_exif.dart:54:20)

How to change x and y pixel resolution and image width and height.

Using a similar library in NodeJS I am able to set the X/Y resolution and the image width and height. I can't seem to make this work with this library.

Code below is from https://github.com/hMatoba/piexifjs

zeroth[piexif.ImageIFD.XResolution] = [300, 1];
zeroth[piexif.ImageIFD.YResolution] = [300, 1];
zeroth[piexif.ImageIFD.ImageWidth] = 5;
zeroth[piexif.ImageIFD.ImageHeight] = 7;

This is what im trying below, are my tag names wrong?

await exif.writeAttributes({
    "ImageWidth": 5,
    "ImageHeight": 7,
    "PixelXDimension": [300, 1],
    "PixelYDimension": [300, 1],
  });

No Implementation Found For Method initPath

When I try to use the first command: final exif = await Exif.fromPath(picture!.path);
I get the following error:
E/flutter (10499): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method initPath on channel native_exif)
I have tried to run flutter clean and flutter pub get to no avail.

Latitude/longitude values are not parsable. latValue=0/1,0/1,0/1, latRef=, lngValue=0/1,0/1,0/1, lngRef=

await exif!.getLatLong() retuning null value

Future<ExifLatLong?> getLatLong() async {
final attributes = await getAttributes();
if (attributes == null) return null;

final latitude = attributes['GPSLatitude'];
final latitudeRef = attributes['GPSLatitudeRef'];
final longitude = attributes['GPSLongitude'];
final longitudeRef = attributes['GPSLongitudeRef'];
if (latitude is! double || latitudeRef is! String || longitude is! double || longitudeRef is! String) {
  return null;
}

return ExifLatLong(
  latitude: latitude * (latitudeRef == 'S' ? -1 : 1),
  longitude: longitude * (longitudeRef == 'W' ? -1 : 1),
);

}

This is coming in Android OS version - 14 device

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.