cordova-plugin-image-resizer
cordova-plugin-image-resizer copied to clipboard
displaying resized image
i have a question about displaying a resized image
i'm doing this with cordova on android.
cordova has a property called cordova.file.applicationDirectory that maps to the uri file:///android_asset/
thru trial and error i have discovered android_asset contains the standard cordova directory named www
i have placed sample.jpg in www and referenced it in the following example
var options = {
uri: cordova.file.applicationDirectory + "www/sample.jpg",
folderName: "www",
filename: "resized.jpg",
quality: 90,
width: 32,
height: 32};
window.ImageResizer.resize(options,
function(image) {
alert("resize success");
var htmlToAppend = '<img src="www/resized.jpg" />';
$('#scaled').append(htmlToAppend);
},
function() {
alert("FAIL");
});
however, when this runs, no image displays.
what is the recommended way to reference a resized image?
I have to take a closer look on that
When I changed the first callback to:
function(image) {
alert("resize success");
var htmlToAppend = '<img src="'+image+'" />';
$('#scaled').append(htmlToAppend);
}
I got a scaled image to appear.
So, the image is scaling but folderName and filename appear to be ignored.
hrm okay, I think I have some time on Friday to look on all the Issus in that Repo. :)
Hello, It doesn't work on iOS that way. I tried to put in Image src the path received from the success callback, but it didn't work. Ended up with adding an option 'base64', which, if set to true, results in returning base64 string image representation. @JoschkaSchulz if you're ok with this approach, I can submit a PR.
@EternallLight it would be nice :)
Here you go!