搜尋套件、儲存庫與 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),
          ),
        ],
      ),
    );
  }
}

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。