Called when a new image appears in the channel.
173063
def redo(self, channel, image):
        """"""
        if not self.gui_up:
            return
        # check if this is an image we received from IRAF or
        # one that was loaded locally.
        ct = image.get('ct', None)
        if ct is not None:
            # This image was sent by IRAF--we don't need to
            # construct extra fb information for it
            return

        n = self.channel_to_frame(channel.name)
        if n is None:
            return
        self.logger.debug("new image, frame is %d" % (n))
        fb = self.get_frame(n)
        newpath = image.get('path', 'NO_PATH')
        host = socket.getfqdn()
        newhost = image.get('host', host)
        # protocol has a bizarre 16-char limit on hostname
        newhost = newhost[:16]

        # this is just a placeholder so that IIS_RequestHandler will
        # report something in this buffer
        fb.buffer = array.array('B', ' ')

        # Update IRAF "wcs" info so that IRAF can load this image

        #print "filling wcs info"
        fb.ct = iis.coord_tran()
        image.set(ct=ct)

        # iis version 1 data
        fb.ct.valid = 1
        fb.ct.a = 1
        fb.ct.b = 0
        fb.ct.c = 0
        fb.ct.d = 1
        fb.ct.tx = 0
        fb.ct.ty = 0
        fb.ct.z1 = 0
        fb.ct.z2 = 1
        fb.ct.zt = iis.W_UNITARY
        fb.ct.format = ''
        fb.ct.imtitle = ''

        # iis version 1+ data
        fb.ct.region = 'image'
        #x1, y1, x2, y2 = fitsimage.get_datarect()
        #wd, ht = x2-x1, y2-y1
        #x1, y1, x2, y2 = x1+1, y1+1, x2+1, y2+1
        #fb.ct.sx, fb.ct.sy = float(x1), float(y1)
        wd, ht = image.get_size()
        fb.ct.sx, fb.ct.sy = float(1), float(1)
        fb.ct.snx, fb.ct.sny = wd, ht
        fb.ct.dx, fb.ct.dy = 1, 1
        fb.ct.dnx, fb.ct.dny = wd, ht

        # ref
        newref = "!".join([newhost, newpath])
        fb.ct.ref = newref

        # TODO: we shouldn't have to know about this here...
        if (fb and fb.ct.a is not None):
            wcs = "%s\n%f %f %f %f %f %f %f %f %d\n" % (
                fb.ct.imtitle, fb.ct.a, fb.ct.b, fb.ct.c, fb.ct.d,
                fb.ct.tx, fb.ct.ty, fb.ct.z1, fb.ct.z2, fb.ct.zt)
        else:
            wcs = "[NOSUCHWCS]\n"
        if (fb and fb.ct.sx is not None):
            mapping = "%s %f %f %d %d %d %d %d %d\n%s\n" % (
                fb.ct.region, fb.ct.sx, fb.ct.sy, fb.ct.snx, fb.ct.sny,
                fb.ct.dx, fb.ct.dy, fb.ct.dnx, fb.ct.dny, fb.ct.ref)
        else:
            mapping = ""
        fb.wcs = wcs + mapping
        self.logger.debug("filled wcs info")
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())
593632
function newChannel() {
  let chan = new Channel();
  let result = chan.send.bind(chan);
  result._inst = chan;
  return result;
}
1026958
def add_image_info_cb(self, gshell, channel, iminfo):
        """"""

        timestamp = iminfo.time_modified
        if timestamp is None:
            # Not an image we are interested in tracking
            return

        self.add_entry(channel.name, iminfo)
172763
function onImagesLoaded(images, callback) {
    var self = this,
        unloaded = images.length;

    if (unloaded === 0) {
      callback();
    }

    images.each(function () {
      // Check if image is loaded
      if (this.complete || this.readyState === 4 || this.readyState === 'complete') {
        singleImageLoaded();
      }
      // Force load the image
      else {
          // fix for IE. See https://css-tricks.com/snippets/jquery/fixing-load-in-ie-for-cached-images/
          var src = $(this).attr('src');
          $(this).attr('src', src + (src.indexOf('?') >= 0 ? '&' : '?') + new Date().getTime());
          $(this).one('load', function () {
            singleImageLoaded();
          });
        }
    });

    function singleImageLoaded() {
      unloaded--;
      if (unloaded === 0) {
        callback();
      }
    }
  }
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
182330
def add_image(self, im):
        
        for im_tmp in self.images:
            if im_tmp.kind == im.kind:
                self.images.remove(im_tmp)
                break
        self.images.append(im)
477443
def update_image(self):
        
        if self._image:
            self._image.set_cmap(self.get_cmap())
            _pylab.draw()
149641
function(callback) {
		this.history.push('create image');
		var buff = new Buffer(this.width * this.height * 4);
		buff.fill(0);
		this.data = buff;
		callback.call(this);
	}
739712
function loadImage ($imageElement, newSource, callback) {
        $imageElement.fadeOut(function () {
            $imageElement.attr("src", newSource);
            imgLoad($imageElement, function () {
                $imageElement.removeClass("loading");
                $imageElement.fadeIn();
                if (typeof callback === "function") {
                    callback();
                }
            });
        });
    }
947130
public function onBeforeWrite()
    {
        if (!$this->owner->isChanged('CurrentVersionID')) {
            return;
        }

        // Support new {@see Image::regenerateFormattedImages} method in 3.2
        if ($this->owner->hasMethod('regenerateFormattedImages')) {
            $this->owner->regenerateFormattedImages();
            return;
        }

        if ($this->owner->ParentID) {
            $base = $this->owner->Parent()->getFullPath();
        } else {
            $base = ASSETS_PATH . '/';
        }

        $resampled = "{$base}_resampled";
        if (!is_dir($resampled)) {
            return;
        }

        $files    = scandir($resampled);
        $iterator = new ArrayIterator($files);
        $filter   = new RegexIterator(
            $iterator,
            sprintf(
                "/([a-z]+)([0-9]?[0-9a-f]*)-%s/i",
                preg_quote($this->owner->Name)
            ),
            RegexIterator::GET_MATCH
        );

        // grab each resampled image and regenerate it
        foreach ($filter as $cachedImage) {
            $path      = "$resampled/{$cachedImage[0]}";

            //skip resampled image files that don't exist
            if (!file_exists($path)) {
                continue;
            }

            $size      = getimagesize($path);
            $method    = $cachedImage[1];
            $arguments = $cachedImage[2];

            unlink($path);

            // Determine the arguments used to generate an image, and regenerate
            // it. Different methods need different ways of determining the
            // original arguments used.
            switch (strtolower($method)) {
                case 'paddedimage':
                    $color = preg_replace("/^{$size[0]}{$size[1]}/", '', $arguments);
                    $this->owner->$method($size[0], $size[1], $color);
                    break;
                case 'resizedimage':
                case 'setsize':
                case 'croppedimage':
                case 'setratiosize':
                case 'croppedfocusedimage':
                    $this->owner->$method($size[0], $size[1]);
                    break;

                case 'setwidth':
                    $this->owner->$method($size[0]);
                    break;

                case 'setheight':
                    $this->owner->$method($size[1]);
                    break;

                default:
                    $this->owner->$method($arguments);
                    break;
            }
        }
    }
683838
def on_open(self, websocket):
        ''''''
        LOGGER.info('New websocket opened. Add client to %s on "%s" channel',
                    self.pubsub, self.channel)
        self.pubsub.add_client(self.client(websocket, self.channel))
1232945
def on_size(self, event):
        ''''''
        state = self.state
        self.need_redraw = True
        if state.report_size_changes:
            # tell owner the new size
            size = self.frame.GetSize()
            if size != self.last_size:
                self.last_size = size
                state.out_queue.put(MPImageNewSize(size))
162243
function Image() {
  if (!this) return new Image();

  this.url = null;

  EventEmitter.call(this);

  setTimeout(function timeout() {
    if (this.onerror) this.on('error', this.onerror);
    if (this.onload) this.on('load', this.onload);
  }.bind(this));
}
890715
def redo(self, channel, image):
        """"""
        chname = channel.name
        if image is None:
            # shouldn't happen, but let's play it safe
            return

        imname = image.get('name', 'none')
        iminfo = channel.get_image_info(imname)
        timestamp = iminfo.time_modified

        if timestamp is None:
            reason = iminfo.get('reason_modified', None)
            if reason is not None:
                self.fv.show_error(
                    "{0} invoked 'modified' callback to ChangeHistory with a "
                    "reason but without a timestamp. The plugin invoking the "
                    "callback is no longer be compatible with Ginga. "
                    "Please contact plugin developer to update the plugin "
                    "to use self.fv.update_image_info() like Mosaic "
                    "plugin.".format(imname))

            # Image somehow lost its history
            self.remove_image_info_cb(self.fv, channel, iminfo)
            return

        self.add_entry(chname, iminfo)
664866
def display(self, image):
        
        assert(image.size == self.size)

        self.image = self.preprocess(image).copy()
307684
function(img) {

      var self = this;

      if (!(img instanceof HTMLImageElement)) {
        cartodb.log.error("img should be an image");
        return;
      }

      this.imageOptions.size = [img.width, img.height];

      this.queue.add(function(response) {
        img.src = self._getUrl();
      });

    }