hm21 / pro_image_editor

The pro_image_editor is a Flutter widget designed for image editing within your application. It provides a flexible and convenient way to integrate image editing capabilities into your Flutter project.
https://hm21.github.io/pro_image_editor/
BSD 3-Clause "New" or "Revised" License
137 stars 75 forks source link

[Bug]: Export and Import issue. After import content are getting cropped and size changed. #227

Closed RahajulAminRaju closed 1 month ago

RahajulAminRaju commented 1 month ago

Package Version

5.2.2

Flutter Version

3.26.0-0.1.pre • channel beta

Platforms

Android, Web

How to reproduce?

First off all when i export it was like this: 20240922-090816

but after import the image is getting cropped and sometime the image size/scale is getting bigger than what i saved. 20240922-090821

this was my code for export(I tried both json and map export but got save issue): IconButton( onPressed: () async { // Assuming ExportEditorConfigs and editor.exportStateHistory are predefined var history = await editor.exportStateHistory(

                                configs: const ExportEditorConfigs(

                                  // configs...
                                  exportPainting: true,
                                  exportText: true,
                                  exportCropRotate: false,
                                  exportFilter: true,
                                  exportEmoji: true,
                                  exportSticker: true,

                                  historySpan:
                                  ExportHistorySpan.current,

                                ),

                              );

                              // // Convert history to JSON
                              // var _historyJson =
                              // await history.toJson();

                              historyMapData = await history.toMap();

                              // setState(() async {
                              //   // historyJson = _historyJson;
                              // });

                            },
                            icon: const Icon(
                              Icons.send_to_mobile_outlined,
                              color: Colors.white,
                            ),
                          ),

                          **this is my import code:**
                          stateHistoryConfigs: StateHistoryConfigs(
          initStateHistory: ImportStateHistory.fromMap(
            // historyJson,
            historyMapData,

            configs: const ImportEditorConfigs(
               recalculateSizeAndPosition: true,
                // mergeMode: ImportEditorMergeMode.replace

            ),
          ),
        ),

Logs (optional)

No response

Example code (optional)

No response

Device Model (optional)

No response

hm21 commented 1 month ago

When importing/exporting stickers in your editor, it is important to set the boxfit property on your images to cover rather than contain. This step is essential because it allows the editor to capture the images correctly without cutting any part of it.

You can try this example to see if it works for you. If it doesn't work, please let me know it.

RahajulAminRaju commented 1 month ago

That didn't solve my problem. I've solve this like this way:

I have to save twice then i saved correctly. Firstly I've add all images for making a template. then export those > close the editor> open again and import the exported element > reedit and resize them > export again > now the issue is solved. if i import again it is save as i exported.

Thanks.

hm21 commented 1 month ago

It should be possible to export it correctly. Could you share the full code you're using for the image editor, including how you're handling the import/export process? I'd like to take a look at it to better understand the issue.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 3 days with no activity.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 5 days since being marked as stale.