GAE - 在服务器端获取图像宽度和高度
我正在使用像图库这样的应用程序。 这允许用户从他的计算机中选择文件并上传图像。上传图像后,该图像将显示在图库中。 我将图像保存在 blobstore 中,并通过 blobkey 获取它。 我想要获得缩略图(根据原始图像调整大小) 在服务器端,我尝试使用图像 api 根据其 blobkey 调整原始图像的大小,如下所示
public String getImageThumbnail(String imageKey) {
BlobKey blobKey = new BlobKey(imageKey);
Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
/*
* can not get width anf height of "oldImage"
* then I try to get imageDate of old Image to create a new image like this
*/
byte[] oldImageData = oldImage.getImageData();
Image newImage1 = ImagesServiceFactory.makeImage(oldImageData);
/*
* however
* oldImage.getImageData(); return null/""
* and cause the Exception when call this ImagesServiceFactory.makeImage(oldImageData)
*/
}
有没有人在服务器端使用过图像 api,请让我知道如何获取创建的图像的宽度和高度来自 blobkey 或 byte[]
I'm working with an application like an image gallery.
This allow user select file from his computer and upload the image. After upload the image, that image will be display in a gallery.
I save the image in blobstore, and get it by blobkey.
I wan to get a thumbnail image (that was resized from thre original image)
On server side, I try to use image api to resize te original one based on it's blobkey, like this
public String getImageThumbnail(String imageKey) {
BlobKey blobKey = new BlobKey(imageKey);
Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
/*
* can not get width anf height of "oldImage"
* then I try to get imageDate of old Image to create a new image like this
*/
byte[] oldImageData = oldImage.getImageData();
Image newImage1 = ImagesServiceFactory.makeImage(oldImageData);
/*
* however
* oldImage.getImageData(); return null/""
* and cause the Exception when call this ImagesServiceFactory.makeImage(oldImageData)
*/
}
Are there anyone had work with image api on server side, please let's me know how to get width and height of an image that create from a blobkey or an byte[]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢大家的阅读
我已经用这个解决了我的问题
Thanks all for reading
I've solved my problem using this
图像对象具有高度/重量详细信息:
Image object have height/weight details: