Determine the size of a rotated (meta)image.
422122
def getRotatedSize(corners, angle):
    
    if angle:
        _rotm = fileutil.buildRotMatrix(angle)
        # Rotate about the center
        _corners = np.dot(corners, _rotm)
    else:
        # If there is no rotation, simply return original values
        _corners = corners

    return computeRange(_corners)
677919
def _initializeDimensions(self, inputData):
    
    if len(inputData.shape) == 2:
      self.imageHeight, self.numImages = inputData.shape
      self.imageWidth, self.numChannels = None, None

    elif len(inputData.shape) == 3:
      self.imageHeight, \
      self.imageWidth, \
      self.numImages = inputData.shape
      self.numChannels = None

    elif len(inputData.shape) == 4:
      self.imageHeight, \
      self.imageWidth, \
      self.numChannels, \
      self.numImages = inputData.shape

    else:
      raise ValueError("The provided image set has more than 4 dimensions.")
319520
def size(self):
        """"""
        if self._size and not self._pil_image:
            return self._size
        else:
            return self.pil_image.size
17961
private static int getScaleFactor(ImageMetadata metadata, int maxPixels) {
        int scale = 1;
        int scaledW = metadata.getW();
        int scaledH = metadata.getH();
        while (scaledW * scaledH > maxPixels) {
            scale *= 2;
            scaledH /= 2;
            scaledW /= 2;
        }
        return scale;
    }
31167
def get_image_size(self, image):
        
        if image['size'] is None:
            args = settings.THUMBNAIL_VIPSHEADER.split(' ')
            args.append(image['source'])
            p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            p.wait()
            m = size_re.match(str(p.stdout.read()))
            image['size'] = int(m.group('x')), int(m.group('y'))
        return image['size']
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]
1305944
def setSizeMetadata(self, size):
    
    assert((self.needMetadataUpdate(CoverImageMetadata.SIZE)) or
           (self.size == size))
    self.size = size
    self.check_metadata &= ~CoverImageMetadata.SIZE
191851
def is_scaled_full_image(self):
        
        return(self.region_full and
               self.size_wh[0] is not None and
               self.size_wh[1] is not None and
               not self.size_bang and
               self.rotation_deg == 0.0 and
               self.quality == self.default_quality and
               self.format == 'jpg')
325273
def set_image_dimensions(self, thumbnail):
        
        try:
            dimensions = getattr(thumbnail, 'dimensions', None)
        except models.ThumbnailDimensions.DoesNotExist:
            dimensions = None
        if not dimensions:
            return False
        self._dimensions_cache = dimensions.size
        return self._dimensions_cache
1197065
def image(self, size):
        
        assert(size[0])
        assert(size[1])
        return self._image.crop(box=self._crop_box(size))
376251
private long rotateMapHeight(long width, long height) {
    if (rotation != null && (rotation == ROTATE_90 || rotation == ROTATE_270)) {
      return width;
    }
    else {
      return height;
    }
  }
1050821
def _getphoto_originalsize(self,pid):
        
        logger.debug('%s - Getting original size from fb'%(pid))
        i=self.fb.get_object(pid)
        width=i['images'][0]['width']
        height=i['images'][0]['height']
        return (width,height)
536226
function getImageSize(fields) {

                if(fields.type!='image'){
                  return;
                }

                if(!fields.size){
                  return;
                }

                return probe(helpers.get_media(fields.location))
                  .then(function(size){
                    fields.image = {
                      width: size.width,
                      height: size.height
                    };
                  });
              }
519318
def get_minimum_size(self, data):
        """"""
        size = self.element.get_minimum_size(data)
        if self.angle in (RotateLM.NORMAL, RotateLM.UPSIDE_DOWN):
            return size
        else:
            return datatypes.Point(size.y, size.x)
437593
def resize_compute_width_height(fullfile,_megapixels):
    """"""

    img = Image.open(fullfile)
    width,height=img.size

    current_megapixels=width*height/(2.0**20)
    scale=sqrt(_megapixels/float(current_megapixels))

    logger.debug('A resize scale would be %f'%(scale))
    # Can't make bigger, return original
    if scale>= 1.0:
        logger.warning('Image is %0.1f MP, trying to scale to %0.1f MP - just using original!',
                current_megapixels,_megapixels);
        return width,height

    new_width=int(width*scale)
    new_height=int(height*scale)

    return new_width,new_height
258401
def calculate_origin_and_size(canvas_size, data_shape, image_canvas_mode, image_zoom, image_position) -> typing.Tuple[typing.Any, typing.Any]:
    """"""
    if data_shape is None:
        return None, None
    if image_canvas_mode == "fill":
        data_shape = data_shape
        scale_h = float(data_shape[1]) / canvas_size[1]
        scale_v = float(data_shape[0]) / canvas_size[0]
        if scale_v < scale_h:
            image_canvas_size = (canvas_size[0], canvas_size[0] * data_shape[1] / data_shape[0])
        else:
            image_canvas_size = (canvas_size[1] * data_shape[0] / data_shape[1], canvas_size[1])
        image_canvas_origin = (canvas_size[0] * 0.5 - image_canvas_size[0] * 0.5, canvas_size[1] * 0.5 - image_canvas_size[1] * 0.5)
    elif image_canvas_mode == "fit":
        image_canvas_size = canvas_size
        image_canvas_origin = (0, 0)
    elif image_canvas_mode == "1:1":
        image_canvas_size = data_shape
        image_canvas_origin = (canvas_size[0] * 0.5 - image_canvas_size[0] * 0.5, canvas_size[1] * 0.5 - image_canvas_size[1] * 0.5)
    elif image_canvas_mode == "2:1":
        image_canvas_size = (data_shape[0] * 0.5, data_shape[1] * 0.5)
        image_canvas_origin = (canvas_size[0] * 0.5 - image_canvas_size[0] * 0.5, canvas_size[1] * 0.5 - image_canvas_size[1] * 0.5)
    else:
        image_canvas_size = (canvas_size[0] * image_zoom, canvas_size[1] * image_zoom)
        canvas_rect = Geometry.fit_to_size(((0, 0), image_canvas_size), data_shape)
        image_canvas_origin_y = (canvas_size[0] * 0.5) - image_position[0] * canvas_rect[1][0] - canvas_rect[0][0]
        image_canvas_origin_x = (canvas_size[1] * 0.5) - image_position[1] * canvas_rect[1][1] - canvas_rect[0][1]
        image_canvas_origin = (image_canvas_origin_y, image_canvas_origin_x)
    return image_canvas_origin, image_canvas_size
544723
def resize(self):
        
        resized_size = self.get_resized_size()
        if not resized_size:
            return

        self.image = self.image.resize(resized_size, Image.ANTIALIAS)