Dimension::withDirective

Get new image dimension with defined directive.

return Dimension
195539
public function withDirective($directive)
    {
        $newDimension = clone $this;

        if (in_array($directive, ['RATIO', 'UP', 'DOWN'])) {
            $newDimension->directive = $directive;
        }

        return $newDimension;
    }
1357284
function assetImageDimensions($height = null, $width = null) {
        $imageDimensions = [];
        if ($height) $imageDimensions['height'] = $height;
        if ($width) $imageDimensions['width'] = $width;
        if (count($imageDimensions)) $this->data['assetImageDimensions'] = $imageDimensions;
        return $this;
    }
226303
function dir(A) {
    if (A.shape.length !== 1) {
        throw new Error('A is not a 1D array');
    }
    return div(A, length(A));
}
172180
def image_shape(img):
    ''''''
    if hasattr(img, 'shape'):
        return (img.shape[1], img.shape[0])
    return (img.width, img.height)
1279167
function addDirectivesToJangular(directives) {
    _.each(directives, function (directive, directiveName) {
        jangular.addDirective(directiveName, directive);
    });
}
405154
function resolveWithDirective(resolve, source, directive, context, info) {
  source = source || ((info || {}).variableValues || {}).input_0 || {};
  let directiveConfig = info.schema._directives.filter(
    d => directive.name.value === d.name,
  )[0];

  let args = {};

  for (let arg of directive.arguments) {
    args[arg.name.value] = arg.value.value;
  }

  return directiveConfig.resolve(resolve, source, args, context, info);
}
45984
def resize(img, width, height):
    
    return img.resize((width, height), Image.ANTIALIAS)
512452
def get_image_dimension(self, url):
        
        w_h = (None, None)
        try:
            if url.startswith('//'):
                url = 'http:' + url
            data = requests.get(url).content
            im = Image.open(BytesIO(data))

            w_h = im.size
        except Exception:
            logger.warning("Error getting image size {}".format(url), exc_info=True)

        return w_h
69618
public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
	{
		$Width   = $oldWidth;  //Default, and flash require this
		$Height  = $oldHeight; //Default, and flash require this
		$oriSize = true;       //Attribute for images without conversion
		
		if ($newWidth > 0 && $newHeight > 0) 
		{
			$Width   = $newWidth;
			$Height  = $newHeight;
			$oriSize = false;
		}
		elseif ($newWidth > 0)
		{
			$Width   = $newWidth;
			$Height  = ceil($newWidth * $oldHeight / $oldWidth);
			$oriSize = false;
		}
		elseif ($newHeight > 0)
		{
			$Width   = ceil($newHeight * $oldWidth / $oldHeight);
			$Height  = $newHeight;
			$oriSize = false;
		}
		return array($Width,$Height,$oriSize);
	}
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())
630330
function ImageResize(filePath) {
	var image = this;
	var defDimensions = Q.defer();
	var defFormat = Q.defer();

	image.gm = gm(filePath)
		.size(function (err, value) {
			image.dimensions = value;
			defDimensions.resolve();
		})
		.format(function (err, value) {
			image.format = value;
			defFormat.resolve();
		});

	image.isLoaded = Q.all([defDimensions.promise, defFormat.promise]);
}
584523
public function getMetaImageResized($width = null, $height = null, $method = null)
    {
        if ($this->owner->hasMetaImage()) {
            
            return ImageTools::singleton()->resize(
                $this->owner->getMetaImage(),
                $this->owner->getMetaImageResizeWidth($width),
                $this->owner->getMetaImageResizeHeight($height),
                $this->owner->getMetaImageResizeMethod($method)
            );
            
        }
    }
1086332
def validate_dimensions
      return unless image?(self)

      manipulate! do |image|
        raise CarrierWave::IntegrityError, I18n.t("carrierwave.errors.image_too_big") if image.dimensions.any? { |dimension| dimension > max_image_height_or_width }
        image
      end
    end
565311
function getDirective(path) {
    for (let directive of path.node.directives) {
      let dirstr = directive.value.value
      if (dirstr.startsWith('use ')) {
        let uses = dirstr.substr(4).split(',').map((use) => use.trim())
        if (uses.indexOf('extensible') !== -1) {
          return 1
        }
        if (uses.indexOf('!extensible') !== -1) {
          return -1
        }
      }
    }
    return 0
  }
1270069
def create(self, width, height):
        
        return Image.new(self.mode, (width, height))
349300
function (src, x, y, width, height) {
		var obj = this.createElement('img')
			.attr({ src: src });

		if (arguments.length > 1) {
			obj.css({
				left: x,
				top: y,
				width: width,
				height: height
			});
		}
		return obj;
	}
129312
def new_image(cols, rows, *fill, &info_blk)
      self << Magick::Image.new(cols, rows, *fill, &info_blk)
    end