Returns next supported image-width
186536
public static function getResponsiveWidthStep($width, $widths)
    {
        foreach ($widths as $cachedWidth) {
            if ($width <= $cachedWidth) {
                return $cachedWidth;
            }
        }
        return end($widths);
    }
48707
function _getRectangleImageCoordinates(startHandle, endHandle) {
  return {
    left: Math.min(startHandle.x, endHandle.x),
    top: Math.min(startHandle.y, endHandle.y),
    width: Math.abs(startHandle.x - endHandle.x),
    height: Math.abs(startHandle.y - endHandle.y),
  };
}
1035600
def pixel_width(self):
        
        return self.zoom_factor * ((self._finish - self._start) / self._resolution)
848804
def next(self) -> mx.io.DataBatch:
        
        if not self.iter_next():
            raise StopIteration

        i, j = self.batch_indices[self.curr_batch_index]
        self.curr_batch_index += 1

        batch_size = self.bucket_batch_sizes[i].batch_size
        source = self.data.source[i][j:j + batch_size]
        target = self.data.target[i][j:j + batch_size]
        if self.preload_features:
            loaded_source = []  # type: List[np.ndarray]
            for k in source:
                loaded_source.append(self.loaded_source[k])
        else:
            loaded_source = self.data_loader(source)
        # zero pad features if not agree with expected shape
        loaded_source = zero_pad_features(loaded_source, self.image_size)
        loaded_source = mx.nd.array(loaded_source)

        label = [self.data.label[i][j:j + batch_size]]

        provide_data = [mx.io.DataDesc(name=self.source_data_name, shape=loaded_source.shape, layout=C.BATCH_MAJOR_IMAGE)]
        if self.with_text:
            provide_data += [mx.io.DataDesc(name=self.target_data_name, shape=target.shape, layout=C.BATCH_MAJOR)]
        provide_label = [mx.io.DataDesc(name=n, shape=x.shape, layout=C.BATCH_MAJOR) for n, x in
                         zip(self.label_names, label)]

        data = [loaded_source]
        if self.with_text:
            data += [target]
        return mx.io.DataBatch(data, label,
                               pad=0, index=None, bucket_key=self.buckets[i],
                               provide_data=provide_data, provide_label=provide_label)
374587
def _choose_width_fn(has_invisible, enable_widechars, is_multiline):
    """"""
    if has_invisible:
        line_width_fn = _visible_width
    elif enable_widechars:  # optional wide-character support if available
        line_width_fn = wcwidth.wcswidth
    else:
        line_width_fn = len
    if is_multiline:
        def width_fn(s): return _multiline_width(s, line_width_fn)
    else:
        width_fn = line_width_fn
    return width_fn
667297
def next(self):
        """"""
        batch = mx.nd.zeros((self.batch_size, self.size[1], self.size[0], 3))
        i = self.cur
        for i in range(self.cur, min(len(self.list), self.cur+self.batch_size)):
            str_img = open(self.root+self.list[i]+'.jpg').read()
            img = imdecode(str_img, 1)
            img, _ = random_crop(img, self.size)
            batch[i - self.cur] = img
        batch = mx.nd.transpose(batch, axes=(0, 3, 1, 2))
        ret = mx.io.DataBatch(data=[batch],
                              label=[],
                              pad=self.batch_size-(i-self.cur),
                              index=None)
        self.cur = i
        return ret
133474
def get_tile_image(imgs, tile_shape=None, result_img=None, margin_color=None):
    
    def resize(*args, **kwargs):
        # anti_aliasing arg cannot be passed to skimage<0.14
        # use LooseVersion to allow 0.14dev.
        if LooseVersion(skimage.__version__) < LooseVersion('0.14'):
            kwargs.pop('anti_aliasing', None)
        return skimage.transform.resize(*args, **kwargs)

    def get_tile_shape(img_num):
        x_num = 0
        y_num = int(math.sqrt(img_num))
        while x_num * y_num < img_num:
            x_num += 1
        return y_num, x_num

    if tile_shape is None:
        tile_shape = get_tile_shape(len(imgs))

    # get max tile size to which each image should be resized
    max_height, max_width = np.inf, np.inf
    for img in imgs:
        max_height = min([max_height, img.shape[0]])
        max_width = min([max_width, img.shape[1]])

    # resize and concatenate images
    for i, img in enumerate(imgs):
        h, w = img.shape[:2]
        dtype = img.dtype
        h_scale, w_scale = max_height / h, max_width / w
        scale = min([h_scale, w_scale])
        h, w = int(scale * h), int(scale * w)
        img = resize(
            image=img,
            output_shape=(h, w),
            mode='reflect',
            preserve_range=True,
            anti_aliasing=True,
        ).astype(dtype)
        if len(img.shape) == 3:
            img = centerize(img, (max_height, max_width, 3), margin_color)
        else:
            img = centerize(img, (max_height, max_width), margin_color)
        imgs[i] = img
    return _tile_images(imgs, tile_shape, result_img)
220207
function getImageNaturalSizes(image, callback) {
  var newImage = document.createElement('img');

  // Modern browsers (except Safari)
  if (image.naturalWidth && !IS_SAFARI) {
    callback(image.naturalWidth, image.naturalHeight);
    return newImage;
  }

  var body = document.body || document.documentElement;

  newImage.onload = function () {
    callback(newImage.width, newImage.height);

    if (!IS_SAFARI) {
      body.removeChild(newImage);
    }
  };

  newImage.src = image.src;

  // iOS Safari will convert the image automatically
  // with its orientation once append it into DOM
  if (!IS_SAFARI) {
    newImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
    body.appendChild(newImage);
  }

  return newImage;
}
455965
def _get_scaled_image(self, resource):
        
        image = self._get_image()
        original_width, original_height = resource.size

        k = image.size[0] / float(image.size[1])

        if image.size[0] >= image.size[1]:
            target_width = int(original_width * self.size)
            target_height = int(target_width / k)
        else:
            target_height = int(original_height * self.size)
            target_width = int(target_height * k)

        image = image.resize((target_width, target_height), Image.ANTIALIAS)

        return image
386556
function (x, y) {
        var i = (y * this.size.w + x) * this.bytes;
        var res = [this.image[i], this.image[i + 1], this.image[i + 2], this.image[i + 3]];
        return res;
    }
225453
function getImageNewAspectSizes(img, max_width, max_height) {
    var img_width = this.getImageWidth(img);
    var img_height = this.getImageHeight(img);
    if (img_width === 0 || img_height === 0) {
      throw new Error('Image width or height is 0 in BunnyImage.getImageNewAspectSizes().');
    }
    var ratio = Math.min(max_width / img_width, max_height / img_height);

    return {
      width: Math.floor(img_width * ratio),
      height: Math.floor(img_height * ratio)
    };
  }
531532
function get_margin_width() {
    //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator
    //for proper alignment of bullet image and text. Allow image to not fitting on left border.
    //This controls the extra indentation of text to make room for the bullet image.
    //Here use actual image size, not predefined bullet size 
    //return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + 
    //  2 * List_Bullet_Frame_Decorator::BULLET_PADDING;

    // Small hack to prevent indenting of list text
    // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. 
    if ( $this->_frame->get_style()->list_style_position === "outside" ||
         $this->_width == 0) 
      return 0;
    //This aligns the "inside" image position with the text.
    //The text starts to the right of the image.
    //Between the image and the text there is an added margin of image width.
    //Where this comes from is unknown.
    //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size?
    return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING;
  }
1294748
def show_images(self, size="small"):
        
        d = dict(small=256, med=512, thumb=100, full=1024)
        try:
            width = d[size]
        except KeyError:
            print("Allowed keys:", d.keys())
            return
        img_urls = [i._get_img_url(size) for i in self.obsids]
        imagesList = "".join(
            [
                "<img style='width: {0}px; margin: 0px; float: "
                "left; border: 1px solid black;' "
                "src='{1}' />".format(width, s)
                for s in img_urls
            ]
        )
        display(HTML(imagesList))
684192
def _get_image_size(self, maxcharno, maxlineno):
        
        return (self._get_char_x(maxcharno) + self.image_pad,
                self._get_line_y(maxlineno + 0) + self.image_pad)
310826
def retrieve_width(self, signum=None, frame=None):
        
        for method_name, args in self.strategies:
            method = getattr(self, "from_" + method_name)
            width = method(*args)
            if width and width > 0:
                self.width = width
                break # Found!
        os.environ["COLUMNS"] = str(self.width)
572984
def size_from_name(size, sizes):

    """"""

    by_name = [s for s in sizes if s.name == size]
    if len(by_name) > 1:
        raise Exception('more than one image named %s exists' % size)
    return by_name[0]
504443
public long getImageSize() {
    long x = 0, y = 0;
    if (tags.containsTagId(TiffTags.getTagId("ImageLength")))
      x = tags.get("ImageLength").getFirstNumericValue();
    if (tags.containsTagId(TiffTags.getTagId("ImageWidth")))
      y = tags.get("ImageWidth").getFirstNumericValue();
    return x * y;
  }