Tag: image uploading

将图像发送到节点服务器并调用OCR microsoft vision API

我试图从Android设备发送一个图像(通过手机摄像头捕获)到一个nodeJS服务器,然后从那里调用微软OCR。 我的技术是,图像被压缩,得到字节数组,并使用HTTP POST方法发送到节点服务器,从节点服务器,从请求中获取字节数组并调用API。 这里是使用的过程:1)。 获取位图图像 2)。 创buildHTTP请求如下: HttpURLConnection conn = (HttpURLConnection)connectURL.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Cache-Control", "no-cache"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"title\""+ lineEnd); dos.writeBytes(lineEnd); ByteArrayOutputStream output = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 50, output); byte[] bufAry = output.toByteArray(); dos.write( bufAry, 0, bufAry.length); dos.writeBytes(lineEnd); […]

使用dropzone上传照片时显示错误

您好我有上传图像在jQuery中的问题。 当我uplaod图像,显示我的错误。 我如何解决这个问题? 我不能使用表单来dropzone,因为它是另一种forms。 错误: POST http:// localhost:3000 / upload 400(Bad Request) Object {error:Object} 代码的HTML <div class="dropzone" action="/upload" encType="multipart/form-data" method='post' id="id_dropzone" > <div class="dz-message"> ِDrop file here to upload </div> </div> 代码JQUERY $(document).ready(function(){ Dropzone.autoDiscover = false; $("#id_dropzone").dropzone({addRemoveLinks: true, autoQueue: true,paramName: "file", maxFilesize: 2, maxFiles: 1, success: function (file, response) { var imgName = response; file.previewElement.classList.add("dz-success"); […]

我可以使用node-gm调整内存中的图像大小,还是需要先将其保存起来?

我允许用户上传头像,但是我想在上传时调整头像的大小。 现在看起来,gm让我把它保存到磁盘之前,它resize。 当传入的请求进来时是否有可能调整它的大小? 像这样的东西: var readStream = fs.createReadStream(req.files['profile-picture']['path']); gm(req.files['profile-picture']['path'], 'img.jpg') .write('/path/to/directory/img.jpg', function (err) { if (!err) console.log('done'); });