Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Resizing an image with options.storeImage = true is not working #13

Closed
razwasserstein opened this issue Dec 30, 2014 · 8 comments
Closed

Comments

@razwasserstein
Copy link

Hi,

When resizing an image with a file uri as a result (and not base64) the app CRASHES.
I have tried numerous options for the options.directory, and options.filename.. none worked. Eventually the result was the same - CRASH.

What am I doing wrong?
Is there a sample of a file uri as a result somewhere?

Thanks,
Doron

@RaananW
Copy link
Owner

RaananW commented Jan 1, 2015

Hi Doron,

I am currently not maintaining the code. I will find the time in the near future to update everything and make sure this plugin can be used with the newest phonegap/cordova version.
I keep this issue open and will update here as soon as I made some progress.

Best,
Raanan

@RaananW
Copy link
Owner

RaananW commented Jan 1, 2015

BTW - I believe the latest pull request solved this problem, please let me know if that was the problem!

@Heshyo
Copy link

Heshyo commented Jan 7, 2015

I tried the latest version on Android and it works perfectly with storeImage = true. I pass a native URL as argument (ie something like file:///storage/sdcard0/projectName/img/2015/01/06/imgName.jpg)
I do have one issue on Android with the default values though:
In imageresize.js:

storeImage: (typeof options.storeImage !== "undefined") ? options.storeImage : 0,
pixelDensity: (typeof options.pixelDensity !== "undefined") ? options.pixelDensity : 1,

In ImageResizePlugin.java

if (params.getBoolean("storeImage")) {}
if (params.getBoolean("pixelDensity")) {}

It's complaining about not being able to convert 0 or 1 into a boolean. I fixed it by specifying true of false for both options. I don't know about iOS, but it'd be best to have correct default values.

@tslater
Copy link

tslater commented Feb 25, 2015

I have the same issue... it should be true/false instead of 0/1, right?

@tslater
Copy link

tslater commented Feb 25, 2015

changed them
from

    var params = {
        data: imageData,
        width: width ? width : 0,
        height: height ? height : 0,
        format: options.format ? options.format : ImageResizer.FORMAT_JPG,
        imageDataType: options.imageType ? options.imageType : ImageResizer.IMAGE_DATA_TYPE_URL,
        resizeType: options.resizeType ? options.resizeType : ImageResizer.RESIZE_TYPE_MAX_PIXEL,
        quality: options.quality ? options.quality : 75,
        storeImage: (typeof options.storeImage !== "undefined") ? options.storeImage : 0,
        pixelDensity: (typeof options.pixelDensity !== "undefined") ? options.pixelDensity : 1,
        directory: options.directory ? options.directory : "",
        filename: options.filename ? options.filename : "",
        photoAlbum: (typeof options.photoAlbum !== "undefined") ? options.photoAlbum : 0
    };

to

    var params = {
        data: imageData,
        width: width ? width : 0,
        height: height ? height : 0,
        format: options.format ? options.format : ImageResizer.FORMAT_JPG,
        imageDataType: options.imageType ? options.imageType : ImageResizer.IMAGE_DATA_TYPE_URL,
        resizeType: options.resizeType ? options.resizeType : ImageResizer.RESIZE_TYPE_MAX_PIXEL,
        quality: options.quality ? options.quality : 75,
        storeImage: (typeof options.storeImage !== "undefined") ? options.storeImage : false,
        pixelDensity: (typeof options.pixelDensity !== "undefined") ? options.pixelDensity : true,
        directory: options.directory ? options.directory : "",
        filename: options.filename ? options.filename : "",
        photoAlbum: (typeof options.photoAlbum !== "undefined") ? options.photoAlbum : false
    };

and it seems to be working well.

before that I was getting Value 1 at pixelDensity of type java.lang.Integer cannot be converted to boolean errors on android. I haven't tested iOS yet.

@RaananW
Copy link
Owner

RaananW commented Feb 25, 2015

I was under the impression that the last pull twist actually fixed it. I still haven't got the chance to test it thoroughly. Sadly other things on the agenda keep me occupied :-)

@Heshyo
Copy link

Heshyo commented Feb 26, 2015

Yes using a boolean should work on iOS too:

bool storeImage = [[options objectForKey:@"storeImage"] boolValue];
bool accountForPixelDensity = [[options objectForKey:@"pixelDensity"] boolValue];

@tslater if you test on iOS please tell us if the rest works, because I had to modify some things for the plugin to work.

@RaananW
Copy link
Owner

RaananW commented Apr 13, 2015

I have updated the js file to send boolean values instead of numbers - 0b4fa1e
Should be working correctly now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants