Automatically set image
494819
def save(self, *args, **kwargs):
        """"""

        if not self.image:

            # Fetch image
            url = "http://img.youtube.com/vi/%s/0.jpg" % self.youtube_id
            response = None
            try:
                response = requests.get(url)
            except requests.exceptions.RequestException:
                # Nothing we can really do in this case
                pass

            if response is not None:
                # Jump through filesystem hoop to please photologue
                filename = self.youtube_id + '.jpg'
                filepath = os.path.join(mkdtemp(), filename)
                fp = open(filepath, 'wb')
                try:
                    fp.write(response.content)
                finally:
                    fp.close()

                # Check for a valid image
                image = None
                try:
                    image = Image.open(filepath)
                except IOError:
                    os.remove(filepath)

                if image is not None:
                    try:
                        # Overlay a play button if possible
                        video_play_image = \
                            preferences.GalleryPreferences.video_play_image
                        if video_play_image:
                            overlay = Image.open(video_play_image)
                            # Downsize image_overlay if it is larger than image
                            w1, h1 = image.size
                            w2, h2 = overlay.size
                            if w2 > w1 or h2 > h1:
                                ratio1 = w1 / float(h1)
                                ratio2 = w2 / float(h2)
                                if ratio1 > ratio2:
                                    resize_fract = h1 / float(h2)
                                else:
                                    resize_fract = w1 / float(w2)

                                overlay.resize(
                                    w2 * resize_fract,
                                    h2 * resize_fract,
                                    Image.ANTIALIAS
                                )

                            image.paste(
                                overlay,
                                (int((w1 - w2) / 2.0), int((h1 - h2) / 2.0)),
                                mask=overlay
                            )
                            image.save(filepath)

                        # Finally set image
                        image = File(open(filepath, 'rb'))
                        image.name = filename
                        self.image = image
                    finally:
                        os.remove(filepath)

        super(VideoEmbed, self).save(*args, **kwargs)
1354856
def set_widget(self, jp_imgw):
        
        super(ImageViewEvent, self).set_widget(jp_imgw)

        self.jp_evt = EventListener(source=jp_imgw)
        self.jp_evt.watched_events = [
            'keydown', 'keyup', 'mouseenter', 'mouseleave',
            'mousedown', 'mouseup', 'mousemove', 'wheel',
            'contextmenu'
        ]
        self.jp_evt.prevent_default_action = True

        self.jp_evt.on_dom_event(self._handle_event)
        self.logger.info("installed event handlers")

        return self.make_callback('map')
1167862
def setPixel(self, x, y, color):
        """"""
        return _fitz.Pixmap_setPixel(self, x, y, color)
138776
function setDivTag(image, img) {
  var setElemStyle = DOM.setStyle(image.element);
  setElemStyle('backgroundImage', 'url(' + img.src + ')');

  if (image.preserveAspectRatio) {
    var w, h;

    if (image.knownDimensions) {
      w = image.knownDimensions[0];
      h = image.knownDimensions[1];
    } else {
      w = img.width;
      h = img.height;
    }

    setElemStyle('backgroundSize', 'cover');

    if (image.isFlexible) {
      setElemStyle('paddingBottom', ((h / w) * 100.0) + '%');
    } else {
      setElemStyle('width', w + 'px');
      setElemStyle('height', h + 'px');
    }
  }
}
411938
def set_image(self, user, image_path):
        """"""
        _, ext = os.path.splitext(image_path)
        shutil.copy(image_path, self._custom_image_path(user, ext))
1018209
def set_image(self, img, bgr=False):
        ''''''
        if not self.is_alive():
            return
        if not hasattr(img, 'shape'):
            img = np.asarray(img[:,:])
        if bgr:
            img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        self.in_queue.put(MPImageData(img))
602990
def auto_orient
      manipulate! do |image|
        o = image.get('exif-Orientation').to_i rescue nil
        o ||= image.get('exif-ifd0-Orientation').to_i rescue 1
        case o
          when 1
            # Do nothing, everything is peachy
          when 6
            image.rot270
          when 8
            image.rot180
          when 3
            image.rot90
          else
            raise('Invalid value for Orientation: ' + o.to_s)
        end
        image.set_type GObject::GSTR_TYPE, 'exif-Orientation', ''
        image.set_type GObject::GSTR_TYPE, 'exif-ifd0-Orientation', ''
      end
    end
1040098
def _set_image(self, image):
        
        if image:
            self._image_cache = image
            self._dimensions_cache = image.size
        else:
            if hasattr(self, '_image_cache'):
                del self._cached_image
            if hasattr(self, '_dimensions_cache'):
                del self._dimensions_cache
1124658
def set_image(self, image = None):
        
        
        if image is None or type(image) is not int:
            raise KPError("Need a new image number")
        else:
            self.image = image
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
1140803
def center_image(self, img):
        """"""
        img.anchor_x = img.width // 2 # int
        img.anchor_y = img.height // 2
1159626
function setTokens(images, options, css) {
	return new Promise(function (resolve) {
		css.walkAtRules('lazysprite', function (atRule) {
			// Get the directory of images from atRule value
			var params = space(atRule.params);
			var atRuleValue = getAtRuleValue(params);
			var sliceDir = atRuleValue[0];
			var sliceDirname = sliceDir.split(path.sep).pop();
			var atRuleParent = atRule.parent;
			var mediaAtRule2x = postcss.atRule({name: 'media', params: resolutions2x.join(', ')});
			var mediaAtRule3x = postcss.atRule({name: 'media', params: resolutions3x.join(', ')});

			// Tag flag
			var has2x = false;
			var has3x = false;

			if (options.outputExtralCSS) {
				var outputExtralCSSRule = postcss.rule({
					selector: '.' + options.nameSpace + (atRuleValue[1] ? atRuleValue[1] : sliceDirname),
					source: atRule.source
				});

				outputExtralCSSRule.append({prop: 'display', value: 'inline-block'});
				outputExtralCSSRule.append({prop: 'overflow', value: 'hidden'});
				outputExtralCSSRule.append({prop: 'font-size', value: '0'});
				outputExtralCSSRule.append({prop: 'line-height', value: '0'});
				atRule.before(outputExtralCSSRule);
			}

			// Foreach every image object
			_.forEach(images, function (image) {
				// Only work when equal to directory name
				if (sliceDirname === image.dir) {
					image.token = postcss.comment({
						text: image.path,
						raws: {
							between: options.cloneRaws.between,
							after: options.cloneRaws.after,
							left: '@replace|',
							right: ''
						}
					});

					// Add `source` argument for source map create.
					var singleRule = postcss.rule({
						selector: '.' + options.nameSpace + image.selector,
						source: atRule.source
					});

					singleRule.append(image.token);

					switch (image.ratio) {
					// @1x
					case 1:
						atRuleParent.insertBefore(atRule, singleRule);
						break;
						// @2x
					case 2:
						mediaAtRule2x.append(singleRule);
						has2x = true;
						break;
						// @3x
					case 3:
						mediaAtRule3x.append(singleRule);
						has3x = true;
						break;
					default:
						break;
					}
				}
			});

			// @2x @3x media rule are last.
			if (has2x) {
				atRuleParent.insertBefore(atRule, mediaAtRule2x);
			}
			if (has3x) {
				atRuleParent.insertBefore(atRule, mediaAtRule3x);
			}

			atRule.remove();
		});
		resolve([images, options]);
	});
}
1085576
def set_thumbnail(self, thumbnail):
        ''''''
        self._thumbnail = thumbnail
        return self._listitem.setThumbnailImage(thumbnail)
536871
def _set(self, key, value, identity='image'):
        
        if identity == 'image':
            s = serialize_image_file(value)
        else:
            s = serialize(value)
        self._set_raw(add_prefix(key, identity), s)
1181614
def set_cover_image(self, data=None, input_file_path=None, scope='avatar/write',
                        content_type='application/octet-stream'):
        
        if input_file_path:
            with open(input_file_path, 'rb') as f:
                data = f.read()

        if not data:
            raise ValueError('Either the data of an image file or the path to an image file must be provided')

        return _post(
            token=self.oauth.get_user_token(scope),
            uri='/user/cover',
            data=data,
            content_type=content_type,
            )
519726
def setMeta(self, title=None, description=None):
        """"""
        method = 'flickr.photos.setMeta'

        if title is None:
            title = self.title
        if description is None:
            description = self.description
            
        _dopost(method, auth=True, title=title, \
               description=description, photo_id=self.id)
        
        self.__title = title
        self.__description = description
1310477
function () {
        var data = this.data;
        var targetEl = this.data.target;

        // Only set up once.
        if (targetEl.dataset.setImageFadeSetup) { return; }
        targetEl.dataset.setImageFadeSetup = true;

        // Create animation.
        targetEl.setAttribute('animation__fade', {
            property: 'material.color',
            startEvents: 'set-image-fade',
            dir: 'alternate',
            dur: data.dur,
            from: '#FFF',
            to: '#000'
        });
    }
1349042
def _set_query_image(self, page):
        
        pageimage = page.get('pageimage')
        thumbnail = page.get('thumbnail')

        if pageimage or thumbnail:
            if 'image' not in self.data:
                self.data['image'] = []

        if pageimage:
            self.data['image'].append({
                'kind': 'query-pageimage',
                'file': pageimage})

        if thumbnail:
            qthumb = {'kind': 'query-thumbnail'}
            qthumb.update(thumbnail)
            qthumb['url'] = thumbnail.get('source')
            del qthumb['source']
            qthumb['file'] = qthumb['url'].split('/')[-2]
            self.data['image'].append(qthumb)