Create different sizes of user photos.
517380
public function ProcessAvatars() {
      $UploadImage = new Gdn_UploadImage();
      $UserData = $this->SQL->Select('u.Photo')->From('User u')->Where('u.Photo is not null')->Get();
      
      // Make sure the avatars folder exists.
      if (!file_exists(PATH_UPLOADS.'/userpics'))
         mkdir(PATH_UPLOADS.'/userpics');
      
      // Get sizes
      $ProfileHeight = C('Garden.Profile.MaxHeight', 1000);
      $ProfileWidth = C('Garden.Profile.MaxWidth', 250);
      $ThumbSize = C('Garden.Thumbnail.Size', 40);
      
      // Temporarily set maximum quality
      SaveToConfig('Garden.UploadImage.Quality', 100, FALSE);
      
      // Create profile and thumbnail sizes
      foreach ($UserData->Result() as $User) {
         try {
            $Image = PATH_ROOT . DS . 'uploads' . DS . GetValue('Photo', $User);
            $ImageBaseName = pathinfo($Image, PATHINFO_BASENAME);            
            
            // Save profile size
            $UploadImage->SaveImageAs(
               $Image,
               PATH_UPLOADS.'/userpics/p'.$ImageBaseName,
               $ProfileHeight,
               $ProfileWidth
            );
            
            // Save thumbnail size
            $UploadImage->SaveImageAs(
               $Image,
               PATH_UPLOADS.'/userpics/n'.$ImageBaseName,
               $ThumbSize,
               $ThumbSize,
               TRUE
            );
         } catch (Exception $ex) { }
      }
   }
836369
def __make_thumbnail(self, width, height):
        
        (w, h) = self.size
        factor = max(
            (float(w) / width),
            (float(h) / height)
        )
        w /= factor
        h /= factor
        return self.get_image((round(w), round(h)))
1123267
def random_size_crop(src, size, min_area=0.25, ratio=(3.0/4.0, 4.0/3.0)):
    """"""
    h, w, _ = src.shape
    area = w*h
    for _ in range(10):
        new_area = random.uniform(min_area, 1.0) * area
        new_ratio = random.uniform(*ratio)
        new_w = int(new_area*new_ratio)
        new_h = int(new_area/new_ratio)

        if random.uniform(0., 1.) < 0.5:
            new_w, new_h = new_h, new_w

        if new_w > w or new_h > h:
            continue

        x0 = random.randint(0, w - new_w)
        y0 = random.randint(0, h - new_h)

        out = fixed_crop(src, x0, y0, new_w, new_h, size)
        return out, (x0, y0, new_w, new_h)

    return random_crop(src, size)
1293243
def photo_sizes
      @attrs.fetch(:photo_sizes, []).each_with_object({}) do |(key, value), object|
        object[key] = Size.new(value)
      end
    end
1239409
def get_user_profile_photos(self, *args, **kwargs):
        """"""
        return get_user_profile_photos(*args, **self._merge_overrides(**kwargs)).run()
87183
def resize(image, width=None, height=None, crop=False, namespace="resized"):
    
    return resize_lazy(image=image, width=width, height=height, crop=crop,
                       namespace=namespace, as_url=True)
843471
def resample_image(arr, max_size=400):
    """"""
    dim = np.max(arr.shape[0:2])
    if dim < max_size:
        max_size = dim
    x, y, _ = arr.shape
    sx = int(np.ceil(x / max_size))
    sy = int(np.ceil(y / max_size))
    img = np.zeros((max_size, max_size, 3), dtype=arr.dtype)
    arr = arr[0:-1:sx, 0:-1:sy, :]
    xl = (max_size - arr.shape[0]) // 2
    yl = (max_size - arr.shape[1]) // 2
    img[xl:arr.shape[0]+xl, yl:arr.shape[1]+yl, :] = arr
    return img
191241
def resize_bitmap(parent, _bitmap, target_height):
  '''
  
  '''
  image = wx.ImageFromBitmap(_bitmap)
  _width, _height = image.GetSize()
  if _height < target_height:
    return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  ratio = float(_width) / _height
  image = image.Scale(target_height * ratio, target_height, wx.IMAGE_QUALITY_HIGH)
  return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
102630
def from_size(cls, data, width, height):
        # type: (bytearray, int, int) -> ScreenShot
        

        monitor = {"left": 0, "top": 0, "width": width, "height": height}
        return cls(data, monitor)
1244955
def cropped_and_resized(size)
      normalized do |image|
        if record.cropped? || size != record.size
          image.crop(image_sizing.crop_geometry_string(size))
          image.resize(size)
        end
      end
    end
1182945
function resize(img, width=0, height=0, type='png', quality=0.75) {
    let mime
    switch(type.toLowerCase()) {
    case 'jpg':
    case 'jpeg':
    case 'image/jpeg':
        mime = 'image/jpeg'
        break
    case 'png':
    case 'image/png':
    default:
        mime = 'image/png'
    }
    return resizePromise(img, width, height).then(
        canvas => canvas2Blob(canvas, { type: mime, quality })
        //canvas => canvas2DataUrl(canvas, { type: mime, quality })
    )
}
827030
def create_thumbnail(img, width, height):
    
    size = (width, height)
    img.thumbnail(size)
    return img
1346314
def set_desired_size(self, width, height):
        """"""
        self._desired_size = (width, height)
        if not self._imgwin_set:
            self.set_window_size(width, height)
629070
def resize(self, width=None):
        
        (iw, ih) = self.size
        if width is None:
            width = min(iw, utils.term.width)
        elif isinstance(width, basestring):
            percents = dict([(pct, '%s%%' % (pct)) for pct in range(101)])
            width = percents[width]
        height = int(float(ih) * (float(width) / float(iw)))
        height //= 2
        self.img = self.img.resize((width, height))
917799
def reset!
      self.base_url = nil
      self.secure_base_url = nil
      self.backdrop_sizes = []
      self.logo_sizes = []
      self.logo_sizes = []
      self.poster_sizes = []
      self.profile_sizes = []
      self.still_sizes = []
      self.include_image_language = "en"
      self
    end
221034
def main(uid, password, photo, users_service, auth_service, photos_service):
    """"""
    user = users_service.get_user_by_id(uid)
    auth_service.authenticate(user, password)
    photos_service.upload_photo(user['uid'], photo)
1270069
def create(self, width, height):
        
        return Image.new(self.mode, (width, height))