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);
// This time we write to the channel directly
writeChannel.write(ByteBuffer.wrap(data));
// Now finalize
writeChannel.closeFinally();
//if(blobKey !=null) //delete the existing blob first -- GOT ERROR here....
// blobstoreService.delete(blobKey);
// Now read from the file using the Blobstore API
blobKey = fileService.getBlobKey(file);
String[] json = {blobKey.getKeyString()};
jsonRet = new Gson().toJson(json);
res.setContentType("application/json");
res.setCharacterEncoding("utf-8");
res.getWriter().write(jsonRet);