Create the backgrround image
962718
private function createBackground()
    {

        imagefilledrectangle($this->im, 0, 0, $this->width, $this->height,
            $this->ink['black']);
    }
765555
function (size, background, foreground, format, text) {
    // Random.image( size, background, foreground, text )
    if (arguments.length === 4) {
      text = format
      format = undefined
    }
    // Random.image( size, background, text )
    if (arguments.length === 3) {
      text = foreground
      foreground = undefined
    }
    // Random.image()
    if (!size) size = this.pick(this._adSize)

    if (background && ~background.indexOf('#')) background = background.slice(1)
    if (foreground && ~foreground.indexOf('#')) foreground = foreground.slice(1)

    // http://dummyimage.com/600x400/cc00cc/470047.png&text=hello
    return 'http://dummyimage.com/' + size +
            (background ? '/' + background : '') +
            (foreground ? '/' + foreground : '') +
            (format ? '.' + format : '') +
            (text ? '&text=' + text : '')
  }
13526
def generateThumbnail(self):
        """"""
        image = pilImage.open(ROOT / self.source.name)
        box, width, height = cropBox(self.width, self.height)

        # Resize
        image.thumbnail((width, height), pilImage.ANTIALIAS)
        # Crop from center
        box = cropBox(*image.size)[0]
        image = image.crop(box)
        # save
        self.thumbnail = self.source.name.replace(self.hash, '__{}'.format(self.hash))
        image.save(ROOT / self.thumbnail.name)
307306
public function generateMaybeCroppedImage(Image_Backend $backend, $width, $height)
    {
        if ($width > 0 && $height > 0) {
            return $backend->croppedResize($width, $height);
        } elseif ($width > 0) {
            return $backend->resizeByWidth($width);
        } elseif ($height > 0) {
            return $backend->resizeByHeight($height);
        } else {
            return $backend;
        }
    }
374089
public java.awt.Image createAwtImage(Color foreground, Color background) {
        int f = foreground.getRGB();
        int g = background.getRGB();
        Canvas canvas = new Canvas();
        int barWidth = (int)x;
        if (barWidth <= 0)
            barWidth = 1;
        int barDistance = (int)n;
        if (barDistance <= barWidth)
            barDistance = barWidth + 1;
        int barShort = (int)size;
        if (barShort <= 0)
            barShort = 1;
        int barTall = (int)barHeight;
        if (barTall <= barShort)
            barTall = barShort + 1;
        int width = ((code.length() + 1) * 5 + 1) * barDistance + barWidth;
        int pix[] = new int[width * barTall];
        byte bars[] = getBarsPostnet(code);
        byte flip = 1;
        if (codeType == PLANET) {
            flip = 0;
            bars[0] = 0;
            bars[bars.length - 1] = 0;
        }
        int idx = 0;
        for (int k = 0; k < bars.length; ++k) {
            boolean dot = (bars[k] == flip);
            for (int j = 0; j < barDistance; ++j) {
                pix[idx + j] = ((dot && j < barWidth) ? f : g);
            }
            idx += barDistance;
        }
        int limit = width * (barTall - barShort);
        for (int k = width; k < limit; k += width)
            System.arraycopy(pix, 0, pix, k, width);
        idx = limit;
        for (int k = 0; k < bars.length; ++k) {
            for (int j = 0; j < barDistance; ++j) {
                pix[idx + j] = ((j < barWidth) ? f : g);
            }
            idx += barDistance;
        }
        for (int k = limit + width; k < pix.length; k += width)
            System.arraycopy(pix, limit, pix, k, width);
        Image img = canvas.createImage(new MemoryImageSource(width, barTall, pix, 0, width));
        
        return img;
    }
726229
def overlay(image, color):
    
    width, height = image.size
    im = Image.new("RGBA", (width, height), color)
    preview = Image.alpha_composite(image, im)
    return preview
621711
public void genImage() {
		if (image == null) {
			ImageBuffer buffer = new ImageBuffer(128,16);
			for (int i=0;i<128;i++) {
				Color col = getColorAt(i / 128.0f);
				for (int j=0;j<16;j++) {
					buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte());
				}
			}
			image = buffer.getImage();
		}
	}
541912
def addBorder(self, width, color=None):
		
		width = int(width/config.DOWNSAMPLING)
		if color==None:
			color = self.color
		layer = self.image.getActiveLayer().data
		colorRGBA = color.get_0_255()
		print('adding border'+str(colorRGBA)+str(width)+str(layer.shape))
		layer[0:width,:,0] = colorRGBA[0]
		layer[0:width,:,1] = colorRGBA[1]
		layer[0:width,:,2] = colorRGBA[2]
		layer[0:width,:,3] = colorRGBA[3]

		layer[:,0:width,0] = colorRGBA[0]
		layer[:,0:width,1] = colorRGBA[1]
		layer[:,0:width,2] = colorRGBA[2]
		layer[:,0:width,3] = colorRGBA[3]

		layer[layer.shape[0]-width:layer.shape[0],:,0] = colorRGBA[0]
		layer[layer.shape[0]-width:layer.shape[0],:,1] = colorRGBA[1]
		layer[layer.shape[0]-width:layer.shape[0],:,2] = colorRGBA[2]
		layer[layer.shape[0]-width:layer.shape[0],:,3] = colorRGBA[3]

		layer[:,layer.shape[1]-width:layer.shape[1],0] = colorRGBA[0]
		layer[:,layer.shape[1]-width:layer.shape[1],1] = colorRGBA[1]
		layer[:,layer.shape[1]-width:layer.shape[1],2] = colorRGBA[2]
		layer[:,layer.shape[1]-width:layer.shape[1],3] = colorRGBA[3]
621454
private void paintBackgroundTogetherIncrease(Graphics2D g, int width, int height) {
        Shape s = shapeGenerator.createScrollButtonTogetherIncrease(0, 0, width, height);

        dropShadow.fill(g, s);
        fillScrollBarButtonInteriorColors(g, s, isIncrease, buttonsTogether);
    }
1088298
def create(self, original, size, crop, options=None):
        
        if options is None:
            options = self.evaluate_options()
        image = self.engine_load_image(original)
        image = self.scale(image, size, crop, options)
        crop = self.parse_crop(crop, self.get_image_size(image), size)
        image = self.crop(image, size, crop, options)
        image = self.colormode(image, options)
        return image
533005
def composite(
    background_image,
    foreground_image,
    foreground_width_ratio=0.25,
    foreground_position=(0.0, 0.0),
):
    """"""

    if foreground_width_ratio <= 0:
        return background_image

    composite = background_image.copy()
    width = int(foreground_width_ratio * background_image.shape[1])
    foreground_resized = resize(foreground_image, width)
    size = foreground_resized.shape

    x = int(foreground_position[1] * (background_image.shape[1] - size[1]))
    y = int(foreground_position[0] * (background_image.shape[0] - size[0]))

    # TODO: warn if resulting coordinates are out of bounds?
    composite[y : y + size[0], x : x + size[1]] = foreground_resized

    return composite
852363
function(callback) {
      if (imagesPaths.length >= numberOfColumns * numberOfRows) return callback();

      var transparentImagePath = path.join(temporaryDirectoryPath, 'transparent.png');
      gm(width, height, '#00000000').write(transparentImagePath, function(error) {

        // Add as many as needed transparent images to the list of images
        var totalMissingImages = numberOfColumns * numberOfRows - imagesPaths.length;

        for (var i = 0; i < totalMissingImages; i++)
          imagesPaths.push(transparentImagePath);

        callback(error);
      });
    }
1121167
private void paintBackgroundSolid(Graphics2D g, JComponent c, int x, int y, int width, int height) {
        Color color = c.getBackground();

        if (type == CommonControlState.DISABLED) {
            color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 0x80);
        }

        Shape s = shapeGenerator.createRoundRectangle(x-2, y-2, width+4, height+4, CornerSize.BORDER);
        g.setPaint(color);
        g.fill(s);
        if (isPaintLineSeperators(c)) {
            paintLineSeparator(g, c, width, height);
        }
        
    }
337511
private BufferedImage create_BACKGROUND_Image(final int WIDTH, BufferedImage image) {
        if (WIDTH <= 0) {
            return null;
        }
        if (image == null) {
            image = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
        }
        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        switch (getFrameType()) {
            case SQUARE:
                BACKGROUND_FACTORY.createLinearBackground(WIDTH, WIDTH, getBackgroundColor(), getCustomBackground(), getModel().getTextureColor(), image);
                break;
            case ROUND:

            default:
                BACKGROUND_FACTORY.createRadialBackground(WIDTH, getBackgroundColor(), getCustomBackground(), getModel().getTextureColor(), image);
                break;
        }
        G2.dispose();

        return image;
    }
1348989
protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final int HEIGHT, BufferedImage image) {
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return UTIL.createImage(1, 1, Transparency.TRANSLUCENT);
        }

        if (image == null) {
            image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
        }
        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

        final int IMAGE_WIDTH = image.getWidth();
        final int IMAGE_HEIGHT = image.getHeight();

        // Draw the background image
        BACKGROUND_FACTORY.createLinearBackground(WIDTH, HEIGHT, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image);

        // Draw the custom layer if selected
        if (isCustomLayerVisible()) {
            G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null);
        }

        G2.dispose();

        return image;
    }
927673
def flatten(image, bgcolor=None):
        
        if bgcolor:
            background = PIL.Image.new('RGB', image.size, bgcolor)
            background.paste(image, mask=image.split()[3])
            return background

        return image.convert('RGB')
232268
function(callback) {
      var firstThumbnail;

      for (var i = 0; i < thumbnailsPaths.length; i++) {
        var thumbnailsPath = thumbnailsPaths[i].thumbnailPath;

        if (!firstThumbnail)
          firstThumbnail = gm(thumbnailsPath);
        else
          firstThumbnail.append(thumbnailsPath, horizontally);

        images.push({
          sprite: destinationPath,
          image: thumbnailsPaths[i].originalPath,
          x: horizontally ? width * i : 0,
          y: horizontally ? 0 : height * i
        });
      }
      firstThumbnail
        .quality(quality)
        .write(destinationPath, callback);
    }