搜索插件、代码仓与 APP 分类

插件详情v0.5.2

flutter_exif_rotation

Flutter 插件,可修复某些设备在横向拍摄时的照片方向。

AndroidiOS
近 30 天下载
4.8万
喜欢数
96
Pub 分数
150

安装插件

flutter pub add flutter_exif_rotation

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可自动纠正某些设备在横屏模式下拍摄照片时引起的图像方向问题。它读取图像的 EXIF 元数据以确定正确的旋转角度并应用该角度,确保图像无需手动调整即可正确显示。对于处理用户上传照片的应用程序而言,此功能尤其有用,因为方向一致性至关重要。该插件支持 Android 和 iOS 平台,并可无缝集成到现有的图像处理工作流程中。

适合场景

  • 修复移动摄像头拍摄的旋转图像
  • 确保画廊中图像显示的一致性
  • 自动化照片方向校正
  • 改进照片上传功能的用户体验
  • 直接从设备相机处理图像

主要特点

  • 读取 EXIF 方向数据
  • 根据元数据自动旋转图像
  • 支持 Android 和 iOS
  • 轻量且易于集成
  • 保持原始图像质量

适合对象

  • 图像画廊应用
  • 照片分享平台
  • 集成摄像头的应用程序
  • 需要精确图像渲染的应用程序
  • 需要自动方向修复的开发者

使用建议

  • 需要图像文件访问权限
  • 可能不适用于所有图像格式
  • 依赖于EXIF数据的存在
  • 仅限方向校正
  • 不适用于非图像文件

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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),
          ),
        ],
      ),
    );
  }
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。