Giter Club home page Giter Club logo

Comments (7)

btastic avatar btastic commented on August 15, 2024 1

Sorry for not being active as much as I would like to be.

from flutter_native_image.

btastic avatar btastic commented on August 15, 2024

Sorry for leaving you hanging. However, I don't quite understand your issue. Can you please provide sample code or something? Thank you

from flutter_native_image.

snadon avatar snadon commented on August 15, 2024

I'm having a similar issue.

My use case is simple:

  1. Take a picture
  2. Compress the picture
  3. Resize to create a thumbnail

At step 3, the generated file foo_compressed.jpg overwritten the first generated one from step 2. So if I upload in the background it ends up uploading the thumbnail twice.

Also, my first attempt to work around this didn't work. I copied the image under a sub-directory like /thumbnails but it still ended up overwriting. The generated foo_compressed.jpg file is written directly under /tmp without adding the sub-directory.

My second work around didn't work either. I named the thumbnail foo_t.jpg and the plugin ended up replacing _t.jpg with _compressed.jpg.

My third try worked! I named the thumbnail foo.thumb.jpg and the generated file ended up being foo.thumb_compressed.jpg.

Would it be convenient to add an optional parameter to compressImage like outputPath?

Also, what is the fastest way of duplicating an image with Flutter?

Thanks!

from flutter_native_image.

snadon avatar snadon commented on August 15, 2024

I just noticed that on Android the compressed file is something like _compressed4654761654884463391.jpg and not _compressed.jpg.

from flutter_native_image.

btastic avatar btastic commented on August 15, 2024

I'd like to have a look at that. Mind sharing a simplified version of code to understand the issue better?

from flutter_native_image.

stevenspiel avatar stevenspiel commented on August 15, 2024

@snadon It must be just an iOS issue, then.

@btastic something like this:

static String IMAGE_URL = 'https://i.dailymail.co.uk/i/pix/2015/09/01/18/2BE1E88B00000578-3218613-image-m-5_1441127035222.jpg'

void main() async {
  // get temp file path
  final String filePath = join((await getApplicationDocumentsDirectory()).path, 'foo.png');

  // download image to file
  File(filePath).writeAsBytesSync((await get(IMAGE_URL)).bodyBytes);

  // async compression
  List<File> compressedFiles = await Future.wait([
    FlutterNativeImage.compressImage(filePath, quality: 80),
    FlutterNativeImage.compressImage(filePath, quality: 40),
  ]);

  // ensure modified files have different paths
  assert(compressedFiles[0].path != compressedFiles[1].path); // currently failing on iOS
}

Even though the compression itself may be quick, if I wanted to do something like upload the files asynchronously, the compressedFile is overwritten.

from flutter_native_image.

stevenspiel avatar stevenspiel commented on August 15, 2024

opened #44 that fixes this

from flutter_native_image.

Related Issues (20)

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.