RaananW / PhoneGap-Image-Resizer

Providing an image resizer plugin for phonegap projects on both Android and iOS
93 stars 89 forks source link

Phonegap + IOS + image gets saved in tmp directory #24

Closed rares-lupascu closed 8 years ago

rares-lupascu commented 8 years ago

Hi

this is the code i use in my phonegap app ... it saves the image in the tmp directory of the app i think so when i close the app and restart they are gone:

window.ImageResizer.resize(options,
  function(image) {
    console.log(image);
  }, function(data) {
    alert('failed');
  });
RaananW commented 8 years ago

Hi,

I will have hard time testing this, as I have no working iPhone or osx at the moment. I will make sure to test it the minute I get a device I can test on. If anyone else knows anything about it, jump right in :wink:

rares-lupascu commented 8 years ago

what i did is to move the image for the tmp folder inside my apps persistent storage folder ... all this on the succes callback function

rarutu

RaananW commented 8 years ago

So this is working? could you show the code you are using?

rares-lupascu commented 8 years ago
var url = "http://192.168.1.1:80/" + latestFileUri;
var fileName = latestFileUri.substring(latestFileUri.lastIndexOf("/") + 1);
var sTumbName = fileName.split('.');
sTumbName = sTumbName[0] + "_thumb." + sTumbName[1];
var filePath = window.rootFS.toURL() + window.mainDirectory + "/" + $scope.sCurrentDate + "/" + fileName;
var fileTransfer = new FileTransfer();
fileTransfer.download(url, filePath,
  function(entry) {
    var options = {
      uri: filePath,
      folderName: window.mainDirectory + "/" + $scope.sCurrentDate,
      quality: 90,
      width: 500,
      height: 250,
      storeImage: true,
      photoAlbum: true
    };
    window.ImageResizer.resize(options, function(image) {
      window.resolveLocalFileSystemURL(image, function(file) {
        window.rootFS.getDirectory(window.mainDirectory + "/" + $scope.sCurrentDate, { create: false }, function(destination) {
          file.moveTo(destination, sTumbName, function(response) {
            console.log('YEY');
          }, function(response) {
            console.log("not moved");
            console.log(response);
          });
        }, function(response) {
          console.log("could not open persistnet directory");
          console.log(response);
        })
      }, function(response) {
        console.log("could not find file");
        console.log(response);
      });
    }, function(data) {
      alert('failed');
    });
  }, function(error) {
    alert("download error source " + JSON.stringify(error));
  },true, { headers: {}}
);
Heshyo commented 8 years ago

I'm not seeing the resize method in https://github.com/RaananW/PhoneGap-Image-Resizer/blob/master/www/imageresize.js , am I missing something? For resizeImage, the options available are directory and filename.

rares-lupascu commented 8 years ago

my stupid mistake ... i was using an old version (or a different plugin) :/