質問編集履歴

2

再追記

2017/09/02 11:00

投稿

agepan
agepan

スコア66

test CHANGED
File without changes
test CHANGED
@@ -77,3 +77,161 @@
77
77
 
78
78
 
79
79
  ```
80
+
81
+
82
+
83
+ 【再追記】
84
+
85
+ プラグインのJavaScriptがあったので、コードを以下に掲載いたします。
86
+
87
+
88
+
89
+ 「画像のサイズを変更する幅(高さ/幅のいずれかが0の場合は、サイズに合わせてサイズが変更されます)他のアスペクト比を維持しながら、高さと幅の両方が0の場合、フルサイズイメージが返されます)」と書いてありますが、widthとheightを0にすると「FileError:5」と出て取得できません。
90
+
91
+ ```ここに言語を入力
92
+
93
+ /*global cordova,window,console*/
94
+
95
+ /**
96
+
97
+ * An Image Picker plugin for Cordova
98
+
99
+ *
100
+
101
+ * Developed by Wymsee for Sync OnSet
102
+
103
+ */
104
+
105
+
106
+
107
+ var ImagePicker = function() {
108
+
109
+
110
+
111
+ };
112
+
113
+
114
+
115
+ ImagePicker.prototype.OutputType = {
116
+
117
+ FILE_URI: 0,
118
+
119
+ BASE64_STRING: 1
120
+
121
+ };
122
+
123
+
124
+
125
+ ImagePicker.prototype.validateOutputType = function(options){
126
+
127
+ var outputType = options.outputType;
128
+
129
+ if(outputType){
130
+
131
+ if(outputType !== this.OutputType.FILE_URI && outputType !== this.OutputType.BASE64_STRING){
132
+
133
+ console.log('Invalid output type option entered. Defaulting to FILE_URI. Please use window.imagePicker.OutputType.FILE_URI or window.imagePicker.OutputType.BASE64_STRING');
134
+
135
+ options.outputType = this.OutputType.FILE_URI;
136
+
137
+ }
138
+
139
+ }
140
+
141
+ };
142
+
143
+
144
+
145
+ ImagePicker.prototype.hasReadPermission = function(callback) {
146
+
147
+ return cordova.exec(callback, null, "ImagePicker", "hasReadPermission", []);
148
+
149
+ };
150
+
151
+
152
+
153
+ ImagePicker.prototype.requestReadPermission = function(callback) {
154
+
155
+ return cordova.exec(callback, null, "ImagePicker", "requestReadPermission", []);
156
+
157
+ };
158
+
159
+
160
+
161
+ /*
162
+
163
+ * success - success callback
164
+
165
+ * fail - error callback
166
+
167
+ * options
168
+
169
+ * .maximumImagesCount - max images to be selected, defaults to 15. If this is set to 1,
170
+
171
+ * upon selection of a single image, the plugin will return it.
172
+
173
+ * .width - width to resize image to (if one of height/width is 0, will resize to fit the
174
+
175
+ * other while keeping aspect ratio, if both height and width are 0, the full size
176
+
177
+ * image will be returned)
178
+
179
+ * .height - height to resize image to
180
+
181
+ * .quality - quality of resized image, defaults to 100
182
+
183
+ * .outputType - type of output returned. defaults to file URIs.
184
+
185
+ * Please see ImagePicker.OutputType for available values.
186
+
187
+ */
188
+
189
+ ImagePicker.prototype.getPictures = function(success, fail, options) {
190
+
191
+ if (!options) {
192
+
193
+ options = {};
194
+
195
+ }
196
+
197
+
198
+
199
+ this.validateOutputType(options);
200
+
201
+
202
+
203
+ var params = {
204
+
205
+ maximumImagesCount: options.maximumImagesCount ? options.maximumImagesCount : 15,
206
+
207
+ width: options.width ? options.width : 0,
208
+
209
+ height: options.height ? options.height : 0,
210
+
211
+ quality: options.quality ? options.quality : 100,
212
+
213
+ allow_video: options.allow_video ? options.allow_video : false,
214
+
215
+ title: options.title ? options.title : 'Select an Album', // the default is the message of the old plugin impl
216
+
217
+ message: options.message ? options.message : null, // the old plugin impl didn't have it, so passing null by default
218
+
219
+ outputType: options.outputType ? options.outputType : this.OutputType.FILE_URI,
220
+
221
+ disable_popover: options.disable_popover ? options.disable_popover : false // Disable the iOS popover as seen on iPad
222
+
223
+ };
224
+
225
+
226
+
227
+ return cordova.exec(success, fail, "ImagePicker", "getPictures", [params]);
228
+
229
+ };
230
+
231
+
232
+
233
+ window.imagePicker = new ImagePicker();
234
+
235
+
236
+
237
+ ```

1

コードの追記

2017/09/02 11:00

投稿

agepan
agepan

スコア66

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,61 @@
19
19
 
20
20
 
21
21
  よろしくお願いいたします。
22
+
23
+
24
+
25
+ 追記:コードを追記します。
26
+
27
+ ```ここに言語を入力
28
+
29
+ function getImage() {
30
+
31
+ try{
32
+
33
+ window.imagePicker.getPictures(
34
+
35
+ function(results) {
36
+
37
+ var content = '';
38
+
39
+ for (var i = 0; i < results.length; i++) {
40
+
41
+ camera_success(results[i]); // 取得成功時にファイルを保存する関数を実行
42
+
43
+ }
44
+
45
+ }, function (error) {
46
+
47
+ alert('Error: ' + error);
48
+
49
+ }, {
50
+
51
+ //maximumImagesCount: 10, //取り込める最大枚数(Androidのみ)
52
+
53
+ title: '画像を選択',
54
+
55
+ //message: '取り込める枚数は最大10枚までです。',
56
+
57
+ width: 2000 // 高さを指定してなければ画像はこの幅を基準としたサイズにリサイズされる
58
+
59
+ //quality: 100 // サイズ変更された画像の品質(デフォルト100)
60
+
61
+ //outputType: imagePicker.OutputType.BASE64_STRING
62
+
63
+ }
64
+
65
+ );
66
+
67
+ } catch(e){
68
+
69
+ alert(e);
70
+
71
+
72
+
73
+ }
74
+
75
+ }
76
+
77
+
78
+
79
+ ```