Google App Engine - 使用Image Service Factory进行大小调整时,图像清晰度降低

时间:2013-07-06 07:49:14

标签: java image google-app-engine resize factory

我正在使用Image service factory来使用Image Transform调整图像大小。

我正在做的是当他们选择多个图像时,我在Javascript中获取这些图像的图像数据并将其传递给服务器以将其转换为byte [],然后从中创建一个新图像并调整大小图像并获得最终调整大小的图像。

当我检查时,图像模糊不清。

我在这里提供了我的代码。检查一下,并告诉我哪里出错了。

由于

ImagesService imagesService = ImagesServiceFactory.getImagesService();
Image original = ImagesServiceFactory.makeImage(imageByteArray);
Transform resize1 = ImagesServiceFactory.makeImFeelingLucky();
Transform resize = ImagesServiceFactory.makeResize(width, height); 
CompositeTransform ct = ImagesServiceFactory.makeCompositeTransform();
ct = ct.concatenate(resize).concatenate(resize1);
Image newImage = imagesService.applyTransform(resize, original);
FileService fileService = FileServiceFactory.getFileService();
AppEngineFile file = fileService.createNewBlobFile(newImage.getFormat().toString());
FileWriteChannel writeChannels =fileService.openWriteChannel(file, true);
writeChannels.write(ByteBuffer.wrap(newImage.getImageData()));
writeChannels.closeFinally();
BlobKey croppedblobKey = fileService.getBlobKey(file);
String ImageUrl = imagesService.getServingUrl(ServingUrlOptions.Builder.withBlobKey(croppedblobKey));
System.out.println("badgeImageUrl::"+ImageUrl.trim());

0 个答案:

没有答案