0
私は現在、ユーザがモーダル画面から画像をトリミングし、そのデータとしてcanvas
を用いimg
要素にトリミングされた画像を通過することを可能にするページに取り組んでいます。 img
のsrc
属性はdata:image/png:base64 ...
で始まる文字のこのランダムな束を持っています。私は何をしたい私は最終的に/ SAVEを打つ私の登録フォームでを送信すると、この画像は、新しい画像ファイルに変換し、指定したフォルダに保存されるということです。例えばimgのsrcをイメージに変換してフォルダに保存するにはどうすればよいですか?
$(document).ready(function() {
$uploadCrop = $('#cb').croppie({
enableExif: true,
viewport: {
width: 250,
height: 250,
/*type: 'circle'*/
},
boundary: {
width: 300,
height: 300
}
});
$('#file1').on('change', function() {
var reader = new FileReader();
reader.onload = function(e) {
$uploadCrop.croppie('bind', {
url: e.target.result
}).then(function(){
console.log('jQuery bind complete');
});
}
reader.readAsDataURL(this.files[0]);
});
//THIS OPENS A MODAL SCREEN THAT ALLOWS THE CROPPING OF SELECTED IMAGE
$('#cropBtn').on('click', function(e) {
$uploadCrop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (canvas) {
// This is the code that passes the result to another image file which will then be used to produce a new image file to save in to the directory for a particular user account profile photo.
$('.profilePic').attr('src', canvas);
});
});
});
あなたは '' php's gd2'ライブラリを使用することができます。ここ
は、私は、画像をトリミングしてimg
要素に渡すために使用されるコードです。 –