Package com.google.appengine.api.images

Examples of com.google.appengine.api.images.ImagesService


    /**
     * Deletes a URL that was previously generated by the blobKey
     */
    public static void deleteServingUrl(BlobKey blobKey) {
        ImagesService images = ImagesServiceFactory.getImagesService();
        images.deleteServingUrl(blobKey);
    }
View Full Code Here


    String jsonRet = null;

    if (width == null) { // first time
      BlobInfo info = new BlobInfoFactory().loadBlobInfo(blobKey);

      ImagesService imagesService = ImagesServiceFactory
          .getImagesService();

      // Try to fetch image data
      byte[] bytes;
      try {
        bytes = blobstoreService.fetchData(blobKey, 0, info.getSize());
      }
      catch ( Exception e){
        // If not possible, first resize to acceptable size
        Image bigImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
        Transform initialResize = ImagesServiceFactory.makeResize(1024, 4000);
        Image resizedImage = imagesService.applyTransform(initialResize, bigImage);
        bytes = resizedImage.getImageData();
      }
     
      // We now have an acceptable image for further processing 
      Image oldImage = ImagesServiceFactory.makeImage(bytes);

      Integer intWidth = oldImage.getWidth();
      Integer intHeight = oldImage.getHeight();

      // step 1: create new image with white background and center image
      // in middle; return;
      // create new image with white background and center image in
      // middle; return;
      // trying composite
      if (intWidth < targetWidth && intHeight < targetHeight) {
        status = "1";
        blobKey = getBlobKeyImage(
            blobKey,
            (setImageMiddle(intWidth, intHeight, oldImage,
                imagesService)).getImageData());
        // preparing returnJSON
        String[] json = { blobKey.getKeyString(), status };
        jsonRet = new Gson().toJson(json);

      }
      // step 2: rescale image to targetWidth
      else if (intWidth > targetWidth) {
        // if ( true) {
        Transform resize = ImagesServiceFactory.makeResize(targetWidth,
            4000);

        Image newImage = imagesService.applyTransform(resize, oldImage);
        // getting the new height
        intHeight = newImage.getHeight();
        intWidth = newImage.getWidth();
        if (intHeight > targetHeight) { // step3: cropping the image
          status = "3";
View Full Code Here

    Double dblX2 = Double.parseDouble(req.getParameter("x2")) / Double.parseDouble(req.getParameter("oriWidth"));
    Double dblY2 = Double.parseDouble(req.getParameter("y2")) / Double.parseDouble(req.getParameter("oriHeight"));;
    String jsonRet = null;
   
    BlobKey blobKey = new BlobKey(strBlobKey);
    ImagesService imagesService = ImagesServiceFactory.getImagesService();
    Image oldImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
    Transform crop = ImagesServiceFactory.makeCrop(dblX1, dblY1, dblX2, dblY2);
    Image newImage = imagesService.applyTransform(crop, oldImage);
    FileService fileService = FileServiceFactory.getFileService();
    AppEngineFile file = fileService.createNewBlobFile("image/jpg");
    byte[] data = newImage.getImageData();

    FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
View Full Code Here

TOP

Related Classes of com.google.appengine.api.images.ImagesService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.