2014-06-06 4 views
9

Hi Ich benutze die phonegap Camera API auf iOS. Ich möchte Bilder im quadratischen 640x640-Format aufnehmen. Dies funktioniert gut, wenn ich den sourceType der Kamera verwende. Aber wenn ich diese targetWidth und targetHeight im sourceType für die Telefon-Bildbibliothek verwende, funktioniert es nur, wenn das Bild vollständig in das definierte Quadrat passt. Wenn das Bild aus der Bibliothek im Querformat aufgenommen wurde und die Höhe kleiner ist als die definierte Zielhöhe (640), wird das Bild nicht quadratisch und behält seine ursprüngliche Höhe bei. Ich habe ein schwarzes Boxen erwartet, das den leeren Raum ausfüllt, so dass es 640 sein wird. Das hapert nur, wenn ich die Kamera benutze und ein Landschaftsbild nehme und correctOrientation: 1 setze.Phonegap Camera API allowEdit, set image immer square

Hier ist mein Code für Kamera und Photolibrary

Kamera:

var options = { 
     quality: 49, 
     allowEdit : true, 
     targetWidth: 640, 
     targetHeight: 640, 
     correctOrientation: 1, 
     saveToPhotoAlbum: 1, 
     //destinationType: Camera.DestinationType.FILE_URI, 
     destinationType: navigator.camera.DestinationType.FILE_URI, 
     sourceType: 1,  // 0:Photo Library, 1=Camera, 2=Saved Photo Album 
     encodingType: 0  // 0=JPG 1=PNG 
    } 
    navigator.camera.getPicture(onSuccess,onFail,options, {limit:2}); 

Library:

var options = { 
     quality: 49, 
     allowEdit : true, 
     targetWidth: 640, 
     targetHeight: 640, 
     correctOrientation: 1, 
     //destinationType: Camera.DestinationType.FILE_URI, 
     destinationType: navigator.camera.DestinationType.FILE_URI, 
     sourceType: 0,  // 0:Photo Library, 1=Camera, 2=Saved Photo Album 
     encodingType: 0  // 0=JPG 1=PNG 
    } 
    navigator.camera.getPicture(onSuccess,onFail,options); 
+0

Haben Sie das jemals gelöst? Ich sehe das auch und es sieht wie ein Fehler für mich aus. –

Antwort

1
  • Ich schlage vor, Sie verwenden image-cropper-touch
  • ich auch in diesem Bug bekommen haben . Ich denke du wirst enttäuscht sein, benutze nur cordova-plugin-camera. Nachdem Sie das Bild erhalten haben, können Sie eine Funktion CropperImage hinzufügen.