This filter uses a 9-patch to overlay the image.

@param imageUrl Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.
500154
public static String frame(String imageUrl) {
    if (imageUrl == null || imageUrl.length() == 0) {
      throw new IllegalArgumentException("Image URL must not be blank.");
    }
    return FILTER_FRAME + "(" + imageUrl + ")";
  }
208841
public static void installImageUrlHandler(ImageSource urlHandlerImageSource) {
		Assert.notNull(urlHandlerImageSource);

		Handler.urlHandlerImageSource = urlHandlerImageSource;

		try {
			// System properties should be set at JVM startup
			// Testcases in IDEA/Eclipse are at JVM startup, but not in Maven's
			// surefire...
			// TODO this entire implementation should be changed with a
			// java.net.URLStreamHandlerFactory instead.
			String packagePrefixList = System.getProperty("java.protocol.handler.pkgs");
			String newPackagePrefixList = null;
			String orgSpringFrameworkRichclientString = "org.springframework.richclient";
			if (packagePrefixList == null || packagePrefixList.equals("")) {
				newPackagePrefixList = orgSpringFrameworkRichclientString;
			}
			else if (("|" + packagePrefixList + "|").indexOf("|" + orgSpringFrameworkRichclientString + "|") < 0) {
				newPackagePrefixList = packagePrefixList + "|" + orgSpringFrameworkRichclientString;
			}
			if (newPackagePrefixList != null) {
				System.setProperty("java.protocol.handler.pkgs", newPackagePrefixList);
			}
		}
		catch (SecurityException e) {
			logger.warn("Unable to install image URL handler", e);
			Handler.urlHandlerImageSource = null;
		}
	}
445955
public void setUrlPattern(String filterURI) {
        // determine what type of filter uri we have and set the mapping type
        if (filterURI.equals("/"))
            mappingType = WebAppFilterManager.FMI_MAPPING_SINGLE_SLASH;
        else if (filterURI.startsWith("/") && filterURI.endsWith("/*")) {
            mappingType = WebAppFilterManager.FMI_MAPPING_PATH_MATCH;

            // go ahead and strip the /* for later matching
            filterURI = filterURI.substring(0, filterURI.length() - 2);
        } else if (filterURI.startsWith("*."))
            mappingType = WebAppFilterManager.FMI_MAPPING_EXTENSION_MATCH;
        // PK57083 START
        else if (WCCustomProperties.MAP_FILTERS_TO_ASTERICK && filterURI.equals("*")) {
            mappingType = WebAppFilterManager.FMI_MAPPING_PATH_MATCH;
            filterURI = "";
        }
        // PK57083 END
        else
            mappingType = WebAppFilterManager.FMI_MAPPING_EXACT_MATCH;

        this.urlPattern = filterURI;
    }
1071598
private void imageApiUsage() throws ApiException, IOException {
        LOG.info("The Image API usage.");
        Images api = retinaApisInstance.imageApi();
        
        
        LOG.info("Image API: getImageForExpression");
        try (ByteArrayInputStream inputStream = api.getImage(TEXT_1)) {
            //get image's stream;
            if (inputStream.read() == 0) {
                throw new IllegalStateException("A image stream cannot be received.");
            }
        }
        
        LOG.info("Image API: getOverlayImage");
        try (ByteArrayInputStream inputStream = api.compare(TEXT_1, TEXT_2)) {
            //get image's stream;
            if (inputStream.read() == 0) {
                throw new IllegalStateException("A image stream cannot be received.");
            }
        }
        
        LOG.info("Image API: getImageForBulkExpressions");
        List<Image> images = api.getImageBulk(TEXT_1, TERM_1);
        for (Image image : images) {
            LOG.info("Image: imageData size: " + image.getImageData().length);
        }
    }
1117164
@WorkerThread
    @Nullable
    public String createThumbnailForImage(String imagePath) {
        if (TextUtils.isEmpty(imagePath)) return null;

        File inFile = new File(imagePath);
        if (!inFile.exists()) return null;

        File thumbnailFile = randomPath(imagePath);
        if (thumbnailFile.exists()) return thumbnailFile.getAbsolutePath();

        Bitmap inBitmap = readImageFromPath(imagePath, THUMBNAIL_SIZE, THUMBNAIL_SIZE);
        if (inBitmap == null) return null;

        ByteArrayOutputStream compressStream = new ByteArrayOutputStream();
        inBitmap.compress(Bitmap.CompressFormat.JPEG, THUMBNAIL_QUALITY, compressStream);

        try {
            compressStream.close();
            thumbnailFile.createNewFile();

            FileOutputStream writeStream = new FileOutputStream(thumbnailFile);
            writeStream.write(compressStream.toByteArray());
            writeStream.flush();
            writeStream.close();
            return thumbnailFile.getAbsolutePath();
        } catch (Exception ignored) {
            return null;
        }
    }
1362779
public void setImageURI(@Nullable String uriString, @Nullable Object callerContext) {
    Uri uri = (uriString != null) ? Uri.parse(uriString) : null;
    setImageURI(uri, callerContext);
  }
1003651
function(imageIdentifier, shortUrl, callback) {
        var id = shortUrl instanceof ShortUrl ? shortUrl.getId() : shortUrl,
            url = this.getImageUrl(imageIdentifier).setPath('/shorturls/' + id),
            signed = this.getSignedResourceUrl('DELETE', url);

        request.del(signed, callback);
        return this;
    }
452109
def _filter_image(self, url):
        ""
        return reduce(lambda f, g: f and g(f), 
        [
            filters.AdblockURLFilter()(url),
            filters.NoImageFilter(),
            filters.SizeImageFilter(),
            filters.MonoImageFilter(),
            filters.FormatImageFilter(),
        ])
997121
function(fileId, imgOrCanvas, maxSize, fromServer, customResizeFunction) {
            var promiseToReturn = new qq.Promise(),
                fileOrUrl, options;

            if (this._imageGenerator) {
                fileOrUrl = this._thumbnailUrls[fileId];
                options = {
                    customResizeFunction: customResizeFunction,
                    maxSize: maxSize > 0 ? maxSize : null,
                    scale: maxSize > 0
                };

                // If client-side preview generation is possible
                // and we are not specifically looking for the image URl returned by the server...
                if (!fromServer && qq.supportedFeatures.imagePreviews) {
                    fileOrUrl = this.getFile(fileId);
                }

                /* jshint eqeqeq:false,eqnull:true */
                if (fileOrUrl == null) {
                    promiseToReturn.failure({container: imgOrCanvas, error: "File or URL not found."});
                }
                else {
                    this._imageGenerator.generate(fileOrUrl, imgOrCanvas, options).then(
                        function success(modifiedContainer) {
                            promiseToReturn.success(modifiedContainer);
                        },

                        function failure(container, reason) {
                            promiseToReturn.failure({container: container, error: reason || "Problem generating thumbnail"});
                        }
                    );
                }
            }
            else {
                promiseToReturn.failure({container: imgOrCanvas, error: "Missing image generator module"});
            }

            return promiseToReturn;
        }
1095007
private String compressImage(String imagePath, File destDirectory) {

        Bitmap scaledBitmap = null;

        BitmapFactory.Options options = new BitmapFactory.Options();

//      by setting this field as true, the actual bitmap pixels are not loaded in the memory. Just the bounds are loaded. If
//      you try the use the bitmap here, you will get null.
        options.inJustDecodeBounds = true;
        Bitmap bmp = BitmapFactory.decodeFile(imagePath, options);

        int actualHeight = options.outHeight;
        int actualWidth = options.outWidth;

//      max Height and width values of the compressed image is taken as 816x612

        float maxHeight = 816.0f;
        float maxWidth = 612.0f;
        float imgRatio = actualWidth / actualHeight;
        float maxRatio = maxWidth / maxHeight;

//      width and height values are set maintaining the aspect ratio of the image

        if (actualHeight > maxHeight || actualWidth > maxWidth) {
            if (imgRatio < maxRatio) {
                imgRatio = maxHeight / actualHeight;
                actualWidth = (int) (imgRatio * actualWidth);
                actualHeight = (int) maxHeight;
            } else if (imgRatio > maxRatio) {
                imgRatio = maxWidth / actualWidth;
                actualHeight = (int) (imgRatio * actualHeight);
                actualWidth = (int) maxWidth;
            } else {
                actualHeight = (int) maxHeight;
                actualWidth = (int) maxWidth;

            }
        }

//      setting inSampleSize value allows to load a scaled down version of the original image

        options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);

//      inJustDecodeBounds set to false to load the actual bitmap
        options.inJustDecodeBounds = false;

//      this options allow android to claim the bitmap memory if it runs low on memory
        options.inPurgeable = true;
        options.inInputShareable = true;
        options.inTempStorage = new byte[16 * 1024];

        try {
//          load the bitmap from its path
            bmp = BitmapFactory.decodeFile(imagePath, options);
        } catch (OutOfMemoryError exception) {
            exception.printStackTrace();

        }
        try {
            scaledBitmap = Bitmap.createBitmap(actualWidth, actualHeight, Bitmap.Config.ARGB_8888);
        } catch (OutOfMemoryError exception) {
            exception.printStackTrace();
        }

        float ratioX = actualWidth / (float) options.outWidth;
        float ratioY = actualHeight / (float) options.outHeight;
        float middleX = actualWidth / 2.0f;
        float middleY = actualHeight / 2.0f;

        Matrix scaleMatrix = new Matrix();
        scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);

        Canvas canvas = new Canvas(scaledBitmap);
        canvas.setMatrix(scaleMatrix);
        canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));

//      check the rotation of the image and display it properly
        ExifInterface exif;
        try {
            exif = new ExifInterface(imagePath);

            int orientation = exif.getAttributeInt(
                    ExifInterface.TAG_ORIENTATION, 0);
            Log.d("EXIF", "Exif: " + orientation);
            Matrix matrix = new Matrix();
            if (orientation == 6) {
                matrix.postRotate(90);
                Log.d("EXIF", "Exif: " + orientation);
            } else if (orientation == 3) {
                matrix.postRotate(180);
                Log.d("EXIF", "Exif: " + orientation);
            } else if (orientation == 8) {
                matrix.postRotate(270);
                Log.d("EXIF", "Exif: " + orientation);
            }
            scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0,
                    scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix,
                    true);
        } catch (IOException e) {
            e.printStackTrace();
        }

        FileOutputStream out = null;
        String resultFilePath = getFilename(imagePath, destDirectory);
        try {
            out = new FileOutputStream(resultFilePath);

            //  write the compressed bitmap at the destination specified by filename.
            scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 80, out);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        return resultFilePath;

    }
831626
private static ReuseResult loadBitmapReuseExact(ImageSource source, Bitmap dest) throws ImageLoadException {
        ImageMetadata metadata = source.getImageMetadata();
        boolean tryReuse = false;
        if (dest.isMutable()
                && dest.getWidth() == metadata.getW()
                && dest.getHeight() == metadata.getH()) {
            if (Build.VERSION.SDK_INT >= 19) {
                tryReuse = true;
            } else if (Build.VERSION.SDK_INT >= 11) {
                if (metadata.getFormat() == ImageFormat.JPEG || metadata.getFormat() == ImageFormat.PNG) {
                    tryReuse = true;
                }
            }
        }

        if (tryReuse) {
            return source.loadBitmap(dest);
        } else {
            return new ReuseResult(loadBitmap(source), false);
        }
    }
344198
def watermark(img, mark, position=(0, 0), opacity=1, scale=1.0, tile=False,
              greyscale=False, rotation=0, return_name=False, **kwargs):
    """"""

    if opacity < 1:
        mark = reduce_opacity(mark, opacity)

    if not isinstance(scale, tuple):
        scale = determine_scale(scale, img, mark)

    mark = mark.resize(scale, resample=Image.ANTIALIAS)

    if greyscale and mark.mode != 'LA':
        mark = mark.convert('LA')

    rotation = determine_rotation(rotation, mark)
    if rotation != 0:
        # give some leeway for rotation overlapping
        new_w = int(mark.size[0] * 1.5)
        new_h = int(mark.size[1] * 1.5)

        new_mark = Image.new('RGBA', (new_w, new_h), (0,0,0,0))

        # center the watermark in the newly resized image
        new_l = int((new_w - mark.size[0]) / 2)
        new_t = int((new_h - mark.size[1]) / 2)
        new_mark.paste(mark, (new_l, new_t))

        mark = new_mark.rotate(rotation)

    position = determine_position(position, img, mark)

    if img.mode != 'RGBA':
        img = img.convert('RGBA')

    # make sure we have a tuple for a position now
    assert isinstance(position, tuple), 'Invalid position "%s"!' % position

    # create a transparent layer the size of the image and draw the
    # watermark in that layer.
    layer = Image.new('RGBA', img.size, (0,0,0,0))
    if tile:
        first_y = int(position[1] % mark.size[1] - mark.size[1])
        first_x = int(position[0] % mark.size[0] - mark.size[0])

        for y in range(first_y, img.size[1], mark.size[1]):
            for x in range(first_x, img.size[0], mark.size[0]):
                layer.paste(mark, (x, y))
    else:
        layer.paste(mark, position)

    # composite the watermark with the layer
    return Image.composite(layer, img, layer)
1141074
function (url, callback) { // TODO (kangax): test callback
      fabric.util.loadImage(url, function(img) {
        this.overlayImage = img;
        callback && callback();
      }, this);
      return this;
    }
1148904
public BaseSliderView image(String url){
        if(mFile != null || mRes != 0){
            throw new IllegalStateException("Call multi image function," +
                    "you only have permission to call it once");
        }
        mUrl = url;
        return this;
    }
1023867
def watermark(self, image, options):
        
        watermark_img = options.get("watermark", settings.THUMBNAIL_WATERMARK)
        if not watermark_img:
            raise AttributeError("No THUMBNAIL_WATERMARK defined or set on tag.")
        watermark_path = find(watermark_img)
        if not watermark_path:
            raise RuntimeError("Could not find the configured watermark file.")
        if not os.path.isfile(watermark_path):
            raise RuntimeError("Set watermark does not point to a file.")

        if "cropbox" not in options:
            options["cropbox"] = None
        if "watermark_alpha" not in options:
            options["watermark_alpha"] = settings.THUMBNAIL_WATERMARK_OPACITY

        mark_sizes = options.get("watermark_size", settings.THUMBNAIL_WATERMARK_SIZE)
        if mark_sizes:
            try:
                options["watermark_size"] = parse_geometry(
                    mark_sizes, self.get_image_ratio(image, options)
                )
            except TypeError as e:
                raise TypeError(
                    "Please, update sorl-thumbnail package version to  >= 11.12b. %s"
                    % e
                )
        else:
            options["watermark_size"] = False

        if "watermark_pos" not in options:
            options["watermark_pos"] = settings.THUMBNAIL_WATERMARK_POSITION

        return self._watermark(
            image,
            watermark_path,
            options["watermark_alpha"],
            options["watermark_size"],
            options["watermark_pos"],
        )
1042942
public ContentPackageBuilder thumbnailImage(InputStream is) throws IOException {
    metadata.setThumbnailImage(IOUtils.toByteArray(is));
    return this;
  }
392701
function (url) {
            if (this.$.width) {
                url += ",width=" + ImageService.normalizeImageSize(this.$.width);
            }

            if (this.$.height) {
                url += ",height=" + ImageService.normalizeImageSize(this.$.height);
            }

            return url;
        }