Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 65
Registered: ‎08-07-2013
My Device: Blackberry Torch 9800
My Carrier: Mobile App Development

How to crop the image using Blackberry 10 Webworks?

Hi All,

 

I have developed web application for Blackberry 10 using Ripple emulator and Blackberry webworks SDK 1.0.4.11. In that i have created the change profile picture page. After pick the image, i have converted the image as Base64 string using FileReader. while i have to give cropping option for selected image. Is there any possibility to crop the selected image. Please me. Thanks a lot in Advance.

 

With Regards,

Marimuthu_P

BlackBerry Development Advisor
Posts: 758
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: How to crop the image using Blackberry 10 Webworks?

Hello,

 

There's actually an imageCrop property you can use to do this, but I believe it's only available to you when you're using the FilePicker API.

 

More info @ https://developer.blackberry.com/html5/apis/v2_0/blackberry.invoke.card.html#jbo1385148823534

Developer
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: How to crop the image using Blackberry 10 Webworks?

Hi Chad,

 

How does the invoke function with crop enabled work? The example from the link you gave doesn't allow to crop the file actually. It just returns the file path right away.

//pick a file of picture with image crop enabled
    function invokeFileInPickerMode1() {
      var details = {
              mode: blackberry.invoke.card.FILEPICKER_MODE_PICKER,
              type: [blackberry.invoke.card.FILEPICKER_TYPE_PICTURE],
              imageCropEnabled: true
          };
      invokeFilePicker(details);
    }
BlackBerry Development Advisor
Posts: 758
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: How to crop the image using Blackberry 10 Webworks?

Hrmm, if imageCrop is set to true in the request (like the code snippet shows) it should be calling the picture crop tool automatically for you, then returning the cropped image path. :\

 

What OS version are you running on, and which device?

Developer
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: How to crop the image using Blackberry 10 Webworks?

Hi Chad,

I tried on Z30 10.2.1.2102 and on Q10 with no success. This is the code

//pick a file of picture with image crop enabled
function pickFile() {
  var details = {
          mode: blackberry.invoke.card.FILEPICKER_MODE_PICKER,
          type: [blackberry.invoke.card.FILEPICKER_TYPE_PICTURE],
          imageCropEnabled: true
      };
  invokeFilePicker(details);
}

function invokeFilePicker(details) {
         console.log(details);
         blackberry.invoke.card.invokeFilePicker(details, function (path) {
                  console.log(path);
                  alert("saved "+ path);
              },
              function (reason) {
                  alert("cancelled " + reason);
              },
              function (error) {
                  if (error) {
                      alert("invoke error "+ error);
                  } else {
                      console.log("invoke success " );
                  }
              }
          );
}

 console output

Object {mode: "Picker", type: Array[1], imageCropEnabled: true}

invoke success

["/accounts/1000/removable/sdcard/camera/IMG_20140223_152152.jpg"]

 

BlackBerry Development Advisor
Posts: 758
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: How to crop the image using Blackberry 10 Webworks?

I see the problem!

 

You should be using "imageCrop: true", not "imageCropEnabled...".

 

I tested it with your code and it worked perfect for me after the change was made.

Developer
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: How to crop the image using Blackberry 10 Webworks?

Thanks Chad. +1 like from me Smiley Happy
The documentation on the site needs to be fixed.
Developer
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: How to crop the image using Blackberry 10 Webworks?

Hi Chad,

 

I can't understand why but free crop selection is disabled in filepicker imageCrop: true for whatever reason. I can't understand what was the purpose to limit this if it's enabled in pictures app? You can't do much with a square crop. The whole feature is basically useless. I'm much disappointed in the API provided.