GitHub 代码仓NGhebreial/flutter_exif_rotation

flutter_exif_rotation

NGhebreial/flutter_exif_rotation open-source repository details.

flutter_exif_rotation 项目封面
星标
29
复刻
77
最近推送(UTC)
2024年9月30日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Fix exif rotation for flutter

pub package

Flutter plugin that fixes the picture orientation for some devices. In some devices the exif data shows picture in landscape mode when they're actually in portrait. This plugin fixes the orientation for pictures taken with those devices.

Every version of Android is supported. iOS implemented by @Bhagatcliffex and currently supported

Android

Add this in your AndroidManifest.xml (you don't need these permissions in case when you manipulate files from internal storage only (file are stored inside the app's directory ( /data/data/{your package}/ )) )

Example
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_exif_rotation/flutter_exif_rotation.dart';
import 'package:image_picker/image_picker.dart';

void main() => runApp(MyApp());

/// The stateful widget
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

/// The class with the scaffold
class _MyAppState extends State<MyApp> {
  File _image;
  final picker = ImagePicker();

  Future getImage() async {
    final image = await picker.getImage(source: ImageSource.gallery);
    if (image != null && image.path != null) {
      File rotatedImage =
          await FlutterExifRotation.rotateImage(path: image.path);

      if (image != null) {
        setState(() {
          _image = rotatedImage;
        });
      }
    }
  }

  Future getImageAndSave() async {
    final image = await picker.getImage(source: ImageSource.gallery);
    if (image != null && image.path != null) {
      File rotatedImage =
          await FlutterExifRotation.rotateAndSaveImage(path: image.path);

      if (image != null) {
        setState(() {
          _image = rotatedImage;
        });
      }
    }
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Exif flutter rotation image example app'),
        ),
        body: new Center(
          child: _image == null
              ? new Text('No image selected.')
              : new Image.file(_image),
        ),
        persistentFooterButtons: <Widget>[
          new FloatingActionButton(
            onPressed: getImageAndSave,
            tooltip: 'Pick Image and save',
            child: new Icon(Icons.save),
          ),
          new FloatingActionButton(
            onPressed: getImage,
            tooltip: 'Pick Image without saving',
            child: new Icon(Icons.add),
          ),
        ],
      ),
    );
  }
}

Nadia Ghebreial GitHub avatar
GitHub 作者

Nadia Ghebreial ↗

Brussels, Belgium官方网站 ↗
语言DartKotlinRubySwiftObjective-CShellJava

此仓库发布的插件

使用的依赖

依赖清单 2 项

  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗