本文整理汇总了Java中com.google.appengine.api.images.ImagesService类的典型用法代码示例。如果您正苦于以下问题:Java ImagesService类的具体用法?Java ImagesService怎么用?Java ImagesService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImagesService类属于com.google.appengine.api.images包,在下文中一共展示了ImagesService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convert
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public byte[] convert(byte[] image, String destType, boolean reverse) {
if (destType == null) {
throw new IllegalArgumentException("dest type is null.");
} else {
destType = destType.toLowerCase();
}
ImagesService.OutputEncoding encoding = null;
if ("png".equals(destType)) {
encoding = OutputEncoding.PNG;
} else if ("jpeg".equals(destType)) {
encoding = OutputEncoding.JPEG;
} else {
throw new UnsupportedOperationException("unsupported image encoding: " + destType);
}
ImagesService imagesService = ImagesServiceFactory.getImagesService();
Image bmp = ImagesServiceFactory.makeImage(image);
Transform t = (reverse) ? ImagesServiceFactory.makeVerticalFlip() : ImagesServiceFactory.makeCompositeTransform();
return imagesService.applyTransform(t, bmp, encoding).getImageData();
}
开发者ID:hidekatsu-izuno,项目名称:wmf2svg,代码行数:23,代码来源:ImageUtil.java
示例2: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
BlobKey blobKey = new BlobKey(req.getParameter("blobkey"));
String maxLengthString = req.getParameter("s");
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
if (maxLengthString == null || maxLengthString.isEmpty()) {
//res.sendRedirect(imagesService.getServingUrl(blobKey));
res.sendRedirect(imagesService.getServingUrl(servingUrlOptions));
}
else {
int maxLength = Integer.parseInt(maxLengthString);
//res.sendRedirect(imagesService.getServingUrl(blobKey, maxLength, false));
res.sendRedirect(imagesService.getServingUrl(servingUrlOptions.imageSize(maxLength)));
}
}
开发者ID:gfigueroa,项目名称:internet-radio-gae,代码行数:18,代码来源:ImageServlet.java
示例3: doPost
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
List<BlobKey> blobKeys = blobstoreService.getUploads(req).get("data");
BlobKey key = blobKeys.get(0);
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions servingOptions = ServingUrlOptions.Builder
.withBlobKey(key);
String servingUrl = imagesService.getServingUrl(servingOptions);
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType("application/json");
JSONObject json = new JSONObject();
json.put("servingUrl", servingUrl);
json.put("blobKey", key.getKeyString());
PrintWriter out = resp.getWriter();
out.print(json.toString());
out.flush();
out.close();
}
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:27,代码来源:Upload.java
示例4: RawAttachmentService
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Inject
public RawAttachmentService(BlobstoreService blobstoreService, ImagesService imagesService,
BlobInfoFactory blobInfoFactory,
@Flag(FlagName.ATTACHMENT_HEADER_BYTES_UPPER_BOUND) int headerBytesUpperBound,
RandomBase64Generator random64,
MetadataDirectory metadataDirectory) {
this.blobstoreService = blobstoreService;
this.imagesService = imagesService;
this.blobInfoFactory = blobInfoFactory;
this.headerBytesUpperBound = headerBytesUpperBound;
this.random64 = random64;
this.metadataDirectory = metadataDirectory;
}
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:14,代码来源:RawAttachmentService.java
示例5: resizeImage
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
public byte[] resizeImage(byte[] imageBlob, int width, int height) {
ImagesService imagesService = ImagesServiceFactory.getImagesService();
Transform resize = ImagesServiceFactory.makeResize(width, height);
Image oldImage = ImagesServiceFactory.makeImage(imageBlob);
Image newImage = imagesService.applyTransform(resize, oldImage);
imageBlob = newImage.getImageData();
return imageBlob;
}
开发者ID:opendatakit,项目名称:aggregate,代码行数:12,代码来源:ImageUtilImpl.java
示例6: MomentEndpoint
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public MomentEndpoint(UserDAO userDAO,
FriendDAO friendDAO,
MomentDAO momentDAO,
ImagesService imagesService,
GcmHelper gcmHelper) {
this.userDAO = userDAO;
this.friendDAO = friendDAO;
this.momentDAO = momentDAO;
this.imagesService = imagesService;
this.gcmHelper = gcmHelper;
}
开发者ID:AndrewJack,项目名称:moment-for-android-wear,代码行数:12,代码来源:MomentEndpoint.java
示例7: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setHeader("Cache-Control", "max-age=2592000");
String path = req.getPathInfo();
// long gameIdString = Long.parseLong(path.split("/", -1)[2]);
String account = req.getParameter("account");
// String fileName = path.split("/", -1)[3];
BlobKey bk = FilePathManager.getBlobKey(account, null, null, path);
if (bk != null) {
if (req.getParameter("thumbnail") == null) {
blobstoreService.serve(bk, resp);
} else {
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(bk);
options.imageSize(Integer.parseInt(req.getParameter("thumbnail")));
boolean crop = false;
if (req.getParameter("crop")!=null) {
crop = Boolean.parseBoolean(req.getParameter("crop"));
}
options.crop(req.getParameter("crop")!=null);
String thumbnailUrl =imagesService.getServingUrl(options);
resp.sendRedirect(thumbnailUrl);
}
} else {
resp.setStatus(404);
}
}
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:31,代码来源:UploadUserContentServlet.java
示例8: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setHeader("Cache-Control", "max-age=2592000");
String path = req.getPathInfo();
// long gameIdString = Long.parseLong(path.split("/", -1)[2]);
Long gameIdString = Long.parseLong(req.getParameter("gameId"));
// String fileName = path.split("/", -1)[3];
BlobKey bk = FilePathManager.getBlobKey(null, null, gameIdString, path);
if (bk != null) {
if (req.getParameter("thumbnail") == null) {
blobstoreService.serve(bk, resp);
} else {
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(bk);
options.imageSize(Integer.parseInt(req.getParameter("thumbnail")));
boolean crop = false;
if (req.getParameter("crop")!=null) {
crop = Boolean.parseBoolean(req.getParameter("crop"));
}
options.crop(req.getParameter("crop")!=null);
String thumbnailUrl =imagesService.getServingUrl(options);
resp.sendRedirect(thumbnailUrl);
}
} else {
resp.setStatus(404);
}
}
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:31,代码来源:UploadGameContentServlet.java
示例9: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String path = req.getPathInfo();
System.out.println(path);
String gameIdString = getFirstPath(path);
Long gameId = Long.parseLong(gameIdString);
path = "/"+getReminder(path);
BlobKey bk = FilePathManager.getBlobKey(null, null,gameId, path);
if (bk != null) {
if (req.getParameter("thumbnail") == null) {
blobstoreService.serve(bk, resp);
} else {
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(bk);
options.imageSize(Integer.parseInt(req.getParameter("thumbnail")));
boolean crop = false;
if (req.getParameter("crop")!=null) {
crop = Boolean.parseBoolean(req.getParameter("crop"));
}
options.crop(req.getParameter("crop")!=null);
String thumbnailUrl =imagesService.getServingUrl(options);
resp.sendRedirect(thumbnailUrl);
}
} else {
resp.setStatus(404);
}
}
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:31,代码来源:GameContentServlet.java
示例10: ServiceImageIO
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public ServiceImageIO(ImagesService imagesService) {
super();
this.imagesService = imagesService;
if (imagesService == null) {
throw new NullPointerException("images service must be non-null");
}
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:8,代码来源:ServiceImageIO.java
示例11: getIO
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public IO getIO(ImagesService imagesService) {
switch (this) {
case IMAGEIO: return new ImageIOIO();
case SANSELAN: return new SanselanIO();
case SERVICE: return new ServiceIO(imagesService);
default: return new NullIO();
}
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:9,代码来源:ServiceImageIO.java
示例12: getTransformedImage
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
private Image getTransformedImage() {
Assumption.assertNotNull(blobKey);
Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
CompositeTransform finalTransform = getCompositeTransformToApply();
OutputSettings settings = new OutputSettings(ImagesService.OutputEncoding.PNG);
return ImagesServiceFactory.getImagesService().applyTransform(finalTransform, oldImage, settings);
}
开发者ID:TEAMMATES,项目名称:teammates,代码行数:10,代码来源:StudentProfilePictureEditAction.java
示例13: processImage
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
private static Image processImage(InputStream inputStream, int maxWidthPx, int maxHeightPx)
throws IOException {
ImagesService imagesService = ImagesServiceFactory.getImagesService();
Image inputImage = ImagesServiceFactory.makeImage(IOUtils.toByteArray(inputStream));
Transform resize = ImagesServiceFactory.makeResize(maxWidthPx, maxHeightPx);
return imagesService.applyTransform(resize, inputImage);
}
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:8,代码来源:ImageUploadUtil.java
示例14: setGalleryAppImage
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
/**
* when an app is published/updated, we need to move the image
* that was temporarily uploaded into projects/projectid/image
* into the gallery image
* @param app gallery app
*/
private void setGalleryAppImage(GalleryApp app) {
// best thing would be if GCS has a mv op, we can just do that.
// don't think that is there, though, so for now read one and write to other
// First, read the file from projects name
boolean lockForRead = false;
//String projectImageKey = app.getProjectImageKey();
GallerySettings settings = loadGallerySettings();
String projectImageKey = settings.getProjectImageKey(app.getProjectId());
try {
GcsService gcsService = GcsServiceFactory.createGcsService();
//GcsFilename filename = new GcsFilename(GalleryApp.GALLERYBUCKET, projectImageKey);
GcsFilename filename = new GcsFilename(settings.getBucket(), projectImageKey);
GcsInputChannel readChannel = gcsService.openReadChannel(filename, 0);
InputStream gcsis = Channels.newInputStream(readChannel);
byte[] buffer = new byte[8000];
int bytesRead = 0;
ByteArrayOutputStream bao = new ByteArrayOutputStream();
while ((bytesRead = gcsis.read(buffer)) != -1) {
bao.write(buffer, 0, bytesRead);
}
// close the project image file
readChannel.close();
// if image is greater than 200 X 200, it will be scaled (200 X 200).
// otherwise, it will be stored as origin.
byte[] oldImageData = bao.toByteArray();
byte[] newImageData;
ImagesService imagesService = ImagesServiceFactory.getImagesService();
Image oldImage = ImagesServiceFactory.makeImage(oldImageData);
//if image size is too big, scale it to a smaller size.
if(oldImage.getWidth() > 200 && oldImage.getHeight() > 200){
Transform resize = ImagesServiceFactory.makeResize(200, 200);
Image newImage = imagesService.applyTransform(resize, oldImage);
newImageData = newImage.getImageData();
}else{
newImageData = oldImageData;
}
// set up the cloud file (options)
// After publish, copy the /projects/projectId image into /apps/appId
//String galleryKey = app.getImageKey();
String galleryKey = settings.getImageKey(app.getGalleryAppId());
//GcsFilename outfilename = new GcsFilename(GalleryApp.GALLERYBUCKET, galleryKey);
GcsFilename outfilename = new GcsFilename(settings.getBucket(), galleryKey);
GcsFileOptions options = new GcsFileOptions.Builder().mimeType("image/jpeg")
.acl("public-read").cacheControl("no-cache").build();
GcsOutputChannel writeChannel = gcsService.createOrReplace(outfilename, options);
writeChannel.write(ByteBuffer.wrap(newImageData));
// Now finalize
writeChannel.close();
} catch (IOException e) {
// TODO Auto-generated catch block
LOG.log(Level.INFO, "FAILED WRITING IMAGE TO GCS");
e.printStackTrace();
}
}
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:68,代码来源:GalleryServiceImpl.java
示例15: provideImagesService
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Provides
ImagesService provideImagesService() {
return ImagesServiceFactory.getImagesService();
}
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:5,代码来源:WalkaroundServerModule.java
示例16: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
//[START original_image]
// Read the image.jpg resource into a ByteBuffer.
FileInputStream fileInputStream = new FileInputStream(new File("WEB-INF/image.jpg"));
FileChannel fileChannel = fileInputStream.getChannel();
ByteBuffer byteBuffer = ByteBuffer.allocate((int)fileChannel.size());
fileChannel.read(byteBuffer);
byte[] imageBytes = byteBuffer.array();
// Write the original image to Cloud Storage
gcsService.createOrReplace(
new GcsFilename(bucket, "image.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(imageBytes));
//[END original_image]
//[START resize]
// Get an instance of the imagesService we can use to transform images.
ImagesService imagesService = ImagesServiceFactory.getImagesService();
// Make an image directly from a byte array, and transform it.
Image image = ImagesServiceFactory.makeImage(imageBytes);
Transform resize = ImagesServiceFactory.makeResize(100, 50);
Image resizedImage = imagesService.applyTransform(resize, image);
// Write the transformed image back to a Cloud Storage object.
gcsService.createOrReplace(
new GcsFilename(bucket, "resizedImage.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(resizedImage.getImageData()));
//[END resize]
//[START rotate]
// Make an image from a Cloud Storage object, and transform it.
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + bucket + "/image.jpeg");
Image blobImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
Transform rotate = ImagesServiceFactory.makeRotate(90);
Image rotatedImage = imagesService.applyTransform(rotate, blobImage);
// Write the transformed image back to a Cloud Storage object.
gcsService.createOrReplace(
new GcsFilename(bucket, "rotatedImage.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(rotatedImage.getImageData()));
//[END rotate]
// Output some simple HTML to display the images we wrote to Cloud Storage
// in the browser.
PrintWriter out = resp.getWriter();
out.println("<html><body>\n");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/image.jpeg' alt='AppEngine logo' />");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/resizedImage.jpeg' alt='AppEngine logo resized' />");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/rotatedImage.jpeg' alt='AppEngine logo rotated' />");
out.println("</body></html>\n");
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:63,代码来源:ImagesServlet.java
示例17: doGet
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
//[START original_image]
// Read the image.jpg resource into a ByteBuffer.
FileInputStream fileInputStream = new FileInputStream(new File("WEB-INF/image.jpg"));
FileChannel fileChannel = fileInputStream.getChannel();
ByteBuffer byteBuffer = ByteBuffer.allocate((int) fileChannel.size());
fileChannel.read(byteBuffer);
byte[] imageBytes = byteBuffer.array();
// Write the original image to Cloud Storage
gcsService.createOrReplace(
new GcsFilename(bucket, "image.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(imageBytes));
//[END original_image]
//[START resize]
// Get an instance of the imagesService we can use to transform images.
ImagesService imagesService = ImagesServiceFactory.getImagesService();
// Make an image directly from a byte array, and transform it.
Image image = ImagesServiceFactory.makeImage(imageBytes);
Transform resize = ImagesServiceFactory.makeResize(100, 50);
Image resizedImage = imagesService.applyTransform(resize, image);
// Write the transformed image back to a Cloud Storage object.
gcsService.createOrReplace(
new GcsFilename(bucket, "resizedImage.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(resizedImage.getImageData()));
//[END resize]
//[START rotate]
// Make an image from a Cloud Storage object, and transform it.
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/" + bucket + "/image.jpeg");
Image blobImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
Transform rotate = ImagesServiceFactory.makeRotate(90);
Image rotatedImage = imagesService.applyTransform(rotate, blobImage);
// Write the transformed image back to a Cloud Storage object.
gcsService.createOrReplace(
new GcsFilename(bucket, "rotatedImage.jpeg"),
new GcsFileOptions.Builder().mimeType("image/jpeg").build(),
ByteBuffer.wrap(rotatedImage.getImageData()));
//[END rotate]
// [START servingUrl]
// Create a fixed dedicated URL that points to the GCS hosted file
ServingUrlOptions options = ServingUrlOptions.Builder
.withGoogleStorageFileName("/gs/" + bucket + "/image.jpeg")
.imageSize(150)
.crop(true)
.secureUrl(true);
String url = imagesService.getServingUrl(options);
// [END servingUrl]
// Output some simple HTML to display the images we wrote to Cloud Storage
// in the browser.
PrintWriter out = resp.getWriter();
out.println("<html><body>\n");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/image.jpeg' alt='AppEngine logo' />");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/resizedImage.jpeg' alt='AppEngine logo resized' />");
out.println("<img src='//storage.cloud.google.com/" + bucket
+ "/rotatedImage.jpeg' alt='AppEngine logo rotated' />");
out.println("<img src='" + url + "' alt='Hosted logo' />");
out.println("</body></html>\n");
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:74,代码来源:ImagesServlet.java
示例18: convertFormatWithService
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public static byte[] convertFormatWithService(ImagesService imagesService, byte[] inputImageBytes, OutputEncoding outputFormat) {
Transform identity = ImagesServiceFactory.makeRotate(0);
Image image = ImagesServiceFactory.makeImage(inputImageBytes);
Image outputImage = imagesService.applyTransform(identity, image, outputFormat);
return outputImage.getImageData();
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:7,代码来源:ServiceImageIO.java
示例19: ServiceIO
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
public ServiceIO(ImagesService imagesService) {
this.imagesService = imagesService;
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:4,代码来源:ServiceImageIO.java
示例20: getImagesService
import com.google.appengine.api.images.ImagesService; //导入依赖的package包/类
private synchronized ImagesService getImagesService() {
if (imagesService == null) {
imagesService = ImagesServiceFactory.getImagesService();
}
return imagesService;
}
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:7,代码来源:ImagingDemoServlet.java
注:本文中的com.google.appengine.api.images.ImagesService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论