modifies this image
341717
def crop! params
      decode_all_scanlines

      x,y,h,w = (params[:x]||0), (params[:y]||0), params[:height], params[:width]
      raise ArgumentError, "negative params not allowed" if [x,y,h,w].any?{ |x| x < 0 }

      # adjust crop sizes if they greater than image sizes
      h = self.height-y if (y+h) > self.height
      w = self.width-x if (x+w) > self.width
      raise ArgumentError, "negative params not allowed (p2)" if [x,y,h,w].any?{ |x| x < 0 }

      # delete excess scanlines at tail
      scanlines[(y+h)..-1] = [] if (y+h) < scanlines.size

      # delete excess scanlines at head
      scanlines[0,y] = [] if y > 0

      # crop remaining scanlines
      scanlines.each{ |l| l.crop!(x,w) }

      # modify header
      hdr.height, hdr.width = h, w

      # return self
      self
    end
1031399
function() {
			var view = new wp.media.view.EditImage({
				controller: this,
				model: this.state().get( 'image' )
			}).render();

			this.content.set( view );

			view.loadEditor();
		}
1291900
def preprocess(self, image):
        
        image = super(max7219, self).preprocess(image)

        if self._correction_angle != 0:
            image = image.copy()
            for y in range(0, self._h, 8):
                for x in range(0, self._w, 8):
                    box = (x, y, x + 8, y + 8)
                    rotated_block = image.crop(box).rotate(self._correction_angle)
                    image.paste(rotated_block, box)
        if self.blocks_arranged_in_reverse_order:
            old_image = image.copy()
            for y in range(8):
                for x in range(8):
                    for i in range(self.cascaded):
                        image.putpixel((8 * (self.cascaded - 1) - i * 8 + x, y), old_image.getpixel((i * 8 + x, y)))

        return image
1081987
def update(self, newinfo):
        ''''''
        self.imgstr = newinfo.imgstr
        self.width = newinfo.width
        self.height = newinfo.height
        if self.imgpanel is not None:
            self.imgpanel.set_image(self.img())
1356191
private void updateImage() {
		if (!over) {
			currentImage = normalImage;
			currentColor = normalColor;
			state = NORMAL;
			mouseUp = false;
		} else {
			if (mouseDown) {
				if ((state != MOUSE_DOWN) && (mouseUp)) {
					if (mouseDownSound != null) {
						mouseDownSound.play();
					}
					currentImage = mouseDownImage;
					currentColor = mouseDownColor;
					state = MOUSE_DOWN;
					
					notifyListeners();
					mouseUp = false;
				}
				
				return;
			} else {
				mouseUp = true;
				if (state != MOUSE_OVER) {
					if (mouseOverSound != null) {
						mouseOverSound.play();
					}
					currentImage = mouseOverImage;
					currentColor = mouseOverColor;
					state = MOUSE_OVER;
				}
			}
		}

		mouseDown = false;
		state = NORMAL;
	}
737381
def img_opacity(image, opacity):
    
    # Validate parameters
    assert 0 <= opacity <= 1, 'Opacity must be a float between 0 and 1'
    assert os.path.isfile(image), 'Image is not a file'

    # Open image in RGBA mode if not already in RGBA
    im = Image.open(image)
    if im.mode != 'RGBA':
        im = im.convert('RGBA')
    else:
        im = im.copy()

    # Adjust opacity
    alpha = im.split()[3]
    alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
    im.putalpha(alpha)

    # Save modified image file
    dst = _add_suffix(image, str(str(int(opacity * 100)) + '%'), ext='.png')
    im.save(dst)
    return dst
1222242
def blit(self, image, x, y):
        """"""
        # adjust the position with the local bbox
        x += self.font_bbox[2] - self.bbox[2]
        y += self.font_bbox[3] - self.bbox[3]
        x += self.font_bbox[0] - self.bbox[0]
        y += self.font_bbox[1] - self.bbox[1]
        image[y:y+self.height, x:x+self.width] = self.bitmap * 255
1211474
def make_transparent(image):
    """"""
    data = image.copy().getdata()
    modified = []
    for item in data:
        if _check_pixel(item) is True:
            modified.append((255, 255, 255, 255))  # White transparent pixel
            continue
        modified.append(item)
    image.putdata(modified)
    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')
183410
function (px) {
        //if no px passed in, use stored location
        if (px != null) {
            this.px = px;
        }

        if (this.imageDiv != null) {
            if (this.px == null) {
                this.display(false);
            } else {
                if (this.calculateOffset) {
                    this.offset = this.calculateOffset(this.size);  
                }
                OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {
                    x: this.px.x + this.offset.x,
                    y: this.px.y + this.offset.y
                });
            }
        }
    }
1017824
def set_custom_image(user_context, app_id, image_path):
  """"""
  if image_path is None:
    return False

  if not os.path.exists(image_path):
    return False

  (root, ext) = os.path.splitext(image_path)
  if not is_valid_extension(ext):
    # TODO: Maybe log that this happened?
    return False
  # If we don't remove the old image then theres no guarantee that Steam will
  # show our new image when it launches.
  if has_custom_image(user_context, app_id):
    img = get_custom_image(user_context, app_id)
    assert(img is not None)
    os.remove(img)
  
  # Set the new image
  parent_dir = paths.custom_images_directory(user_context)
  new_path = os.path.join(parent_dir, app_id + ext)
  shutil.copyfile(image_path, new_path)
  return True
890443
function recolorImageWithCanvasContext(context, img, colorFunc) {
  if (!defined(context)) {
    throw new DeveloperError("No context for image recoloring.");
  }

  // Copy the image contents to the canvas
  context.clearRect(0, 0, context.canvas.width, context.canvas.height);
  context.drawImage(img, 0, 0);
  var image = context.getImageData(
    0,
    0,
    context.canvas.width,
    context.canvas.height
  );
  image = ImageryProviderHooks.recolorImage(image, colorFunc);
  return image;
}
796446
def modify(self, modification, parameters):
        
        for src in self:
            src.modify(modification, parameters)
1185255
def addImage(self, image, mask=None):
        '''
        
        '''
        self._last_diff = diff = image - self.noSTE

        ste = diff > self.threshold
        removeSinglePixels(ste)

        self.mask_clean = clean = ~ste

        if mask is not None:
            clean = np.logical_and(mask, clean)

        self.mma.update(image, clean)

        if self.save_ste_indices:
            self.mask_STE += ste

        return self
664866
def display(self, image):
        
        assert(image.size == self.size)

        self.image = self.preprocess(image).copy()
866314
def clearImg(self):
        """"""
        self.img.setImage(np.array([[0]]))
        self.img.image = None
45984
def resize(img, width, height):
    
    return img.resize((width, height), Image.ANTIALIAS)