replace all system images with a thumbnail version of them (handy for all images inside a page part)
 for example, <%= content_fu(@page.content_for(:body), '96x96#c') %> converts all /system/images to a 96x96 cropped thumbnail
326751
def content_fu(content, thumbnail)
      content.gsub(%r{<img.+?src=['"](/system/images/.+?)/.+?/>}) do |img|
        begin
          sha = img.match(%r{/system/images/(.+?)/})[1]
          job = Dragonfly::Job.deserialize sha, Dragonfly.app(:refinery_images)

          image_fu Image.where(:image_uid => job.uid).first, thumbnail
        rescue Dragonfly::Serializer::BadString
          img
        end
      end
    end
109695
def render_thumbnail_tag(document, image_options = {}, url_options = {})
      link_to image_tag(thumbnail_url(document)), url_for_document(document)
    end
300808
def resize_program_image(img_url, img_size=300):
    '''
    
    '''
    match = re.match(r'.+/(\d+)x(\d+)/.+', img_url)
    if not match:
        _LOGGER.warning('Could not compute current image resolution of %s',
                        img_url)
        return img_url
    res_x = int(match.group(1))
    res_y = int(match.group(2))
    # aspect_ratio = res_x / res_y
    target_res_y = int(img_size * res_y / res_x)
    return re.sub(
        r'{}x{}'.format(res_x, res_y),
        r'{}x{}'.format(img_size, target_res_y),
        img_url)
1359345
def absolutize_page(content, base_url, current_url_parent)
      modified_content = ""
      content.each_line do |line|
        if line =~ /<script\s+.*src=["'']?(.*)["'].*/i then
          script_src = $1
          substitute_relative_path_in_src_line(line, script_src, base_url, current_url_parent)
        elsif line =~ /<link\s+.*href=["'']?(.*)["'].*/i then
          link_href = $1
          substitute_relative_path_in_src_line(line, link_href, base_url, current_url_parent)
        elsif line =~ /<img\s+.*src=["'']?(.*)["'].*/i then
          img_src = $1
          substitute_relative_path_in_src_line(line, img_src, base_url, current_url_parent)
        end

        modified_content += line
      end
      return modified_content
    end
917459
def thumbnail(self):
        
        if not self.status:
            return None

        images = self.status.images

        return images[0].url if images else None
484419
def thumbnail(self, path, height, width, quality=100, **kwargs):
        
        params = {'ec': 1,
                  'path': path,
                  'quality': quality,
                  'width': width,
                  'height': height}

        url = 'http://{0}/rest/2.0/pcs/thumbnail'.format(BAIDUPCS_SERVER)
        return self._request('thumbnail', 'generate', url=url, extra_params=params, **kwargs)
1028239
def image(link, title, alt_text)
      # add the querystring to the image
      if @image_parameters.present?
        prefix = link.include?('?') ? '&' : '?'
        link += "#{prefix}#{@image_parameters.to_query}"
      end
      # return a content tag
      content_tag(:img, nil, src: link.to_s, alt: alt_text, title: title)
    end
880797
def thumbnail_size(size_string = "0x0", crop = false)
      size = sizes_from_string(size_string)

      # only if crop is set do we need to actually parse the size string, otherwise
      # we take the base image size.
      if crop
        size[:width] = get_base_dimensions[:width] if size[:width].zero?
        size[:height] = get_base_dimensions[:height] if size[:height].zero?
        size = reduce_to_image(size)
      else
        size = get_base_dimensions
      end

      size = size_when_fitting({width: THUMBNAIL_WIDTH, height: THUMBNAIL_HEIGHT}, size)
      "#{size[:width]}x#{size[:height]}"
    end
775997
def thumbnail(self, dump_to=None):
        
        headers = {
            "Authorization": "token {}".format(self._client.token)
        }

        result = requests.get('{}/{}/thumbnail'.format(self._client.base_url,
                OAuthClient.api_endpoint.format(id=self.id)),
                headers=headers)

        if not result.status_code == 200:
            raise ApiError('No thumbnail found for OAuthClient {}'.format(self.id))

        if dump_to:
            with open(dump_to, 'wb+') as f:
                f.write(result.content)
        return result.content
1155771
def replace(self, photo_file, **kwds):
        
        result = self._client.photo.replace(self, photo_file, **kwds)
        self._replace_fields(result.get_fields())
836625
def url_for(**options):
    ''''''

    url_parts = get_url_parts(**options)
    image_hash = hashlib.md5(b(options['image_url'])).hexdigest()
    url_parts.append(image_hash)

    return "/".join(url_parts)
11541
def make_thumbnail(file, size, bbox=None):
    '''
    
    '''
    image = Image.open(file)
    if bbox:
        thumbnail = crop_thumbnail(image, size, bbox)
    else:
        thumbnail = center_thumbnail(image, size)
    return _img_to_file(thumbnail)
258988
def page_strip(page, versioned):
    
    # page strip filtering should be conditional
    page.pop('ResponseMetadata', None)
    contents_key = versioned and 'Versions' or 'Contents'
    contents = page.get(contents_key, ())

    # aggressive size
    if versioned:
        keys = []
        for k in contents:
            if k['IsLatest']:
                keys.append((k['Key'], k['VersionId'], True))
            else:
                keys.append((k['Key'], k['VersionId']))
        return keys
    else:
        return [k['Key'] for k in contents]

    if not contents:
        return page

    # Depending on use case we may want these
    for k in contents:
        k.pop('Owner', None)
        k.pop('LastModified', None)
        k.pop('ETag', None)
        k.pop('StorageClass', None)
        k.pop('Size', None)

    return page
350135
private function _mozifyImageReplacement()
	{
		//get the class
		$class = $this->getCssClassName();

		//build replacement html
		$replacement  = '<table width="' . $this->imageWidth . '" cellspacing="0" cellpadding="0" border="0" align="" moz="3" style="display:block;float:none" class="' . $class . '">';
		$replacement .= '<tbody>';
		$replacement .= '<tr>';
		$replacement .= '<td style="padding:0px 0px 0px 0px;" class="' . $class . '">';
		$replacement .= '<div class="' . $class . '" style="width:0px;height:0px;overflow:visible;float:left;position:absolute">';
		$replacement .= '<table cellspacing="0" cellpadding="0" class="' . $class . '">';
		$replacement .= '<tbody>';
		$replacement .= '<tr>';
		$replacement .= '<td background="' . $this->imageUrl . '"><div class="' . $class . '" style="width:' . $this->imageWidth . 'px;height:' . $this->imageHeight . 'px"></div></td>';
		$replacement .= '</tr>';
		$replacement .= '</tbody>';
		$replacement .= '</table>';
		$replacement .= '</div>';
		return $replacement;
	}
25959
def get_thumbnail(path, format='jpeg', size='w64h64')
      resp, body = content_request('/files/get_thumbnail', path: path, format: format, size: size)
      return FileMetadata.new(resp), body
    end
785558
def index
      @images = Cmtool::Image.all

      respond_to do |format|
        format.html # index.html.erb
        format.xml  { render :xml => @images }
        format.js
      end
    end
316248
def replace_from_url(self, photo, url, **kwds):
        
        result = self._client.post("/photo/%s/replace.json" %
                                   self._extract_id(photo),
                                   photo=url,
                                   **kwds)["result"]
        return Photo(self._client, result)