This is used for a second resize by imagemagick after resizing
 by kdu.
 No need to scale most resize operations (only percent)
 @param [Integer] factor to scale by
 @return [IIIF::Image::Size] a copy of self if factor is zero.
761961
def reduce(factor)
      case size
      when IIIF::Image::Size::Percent
        pct = size.percentage * 2**factor
        IIIF::Image::Size::Percent.new(pct)
      else
        size.dup
      end
    end
798947
public static void scaleArray(final double[] array, final double factor){
		for(int i = 0; i < array.length; i++){
			array[i] *= factor;
		}
	}
1103745
def upsample(self, factor):
        
        
        self.checkforpilimage()
        
        if type(factor) != type(0):
            raise RuntimeError, "Upsample factor must be an integer !"
        
        if self.verbose:
            print "Upsampling by a factor of %i" % factor
        self.pilimage = self.pilimage.resize((self.pilimage.size[0] * factor, self.pilimage.size[1] * factor))
        self.upsamplefactor = factor
        
        self.draw = None
1149319
public static int scale(Double factor, int pixel) {
        return rgb(
                (int) Math.round(factor * red(pixel)),
                (int) Math.round(factor * green(pixel)),
                (int) Math.round(factor * blue(pixel))
        );
    }
708172
def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
                       namespace="resized"):
    
    aspect = float(image.width) / float(image.height)
    crop = False

    if (aspect > ratio and upcrop) or (aspect <= ratio and not upcrop):
        crop = True

    return resize_lazy(image=image, width=width, height=height, crop=crop,
                       namespace=namespace, as_url=True)
332948
public Matrix4f scaleAround(float factor, float ox, float oy, float oz, Matrix4f dest) {
        return scaleAround(factor, factor, factor, ox, oy, oz, dest);
    }
558411
def get_conversion_factor(self, new_unit):
        
        uo_base, ofactor = self.as_base_units
        un_base, nfactor = Unit(new_unit).as_base_units
        units_new = sorted(un_base.items(),
                           key=lambda d: _UNAME2UTYPE[d[0]])
        units_old = sorted(uo_base.items(),
                           key=lambda d: _UNAME2UTYPE[d[0]])
        factor = ofactor / nfactor
        for uo, un in zip(units_old, units_new):
            if uo[1] != un[1]:
                raise UnitError("Units %s and %s are not compatible!" % (uo, un))
            c = ALL_UNITS[_UNAME2UTYPE[uo[0]]]
            factor *= (c[uo[0]] / c[un[0]]) ** uo[1]
        return factor
372823
public D multipliedBy(int factor) {

        switch (factor) {
            case -1:
                return this.inverse();
            case 1:
                return this.self();
            default:
                return this.with(MathUtils.safeMultiply(this.amount, factor));
        }

    }
378480
public void setFactor(int factor) {
        this.factor = factor = Math.max(-127, Math.min(127, factor));

        if (factor > 1) {
            baseFilter.setInRed(new IntRange(factor, 255 - factor));
            baseFilter.setInGreen(new IntRange(factor, 255 - factor));
            baseFilter.setInBlue(new IntRange(factor, 255 - factor));
            baseFilter.setInGray(new IntRange(factor, 255 - factor));

            baseFilter.setOutRed(new IntRange(0, 255));
            baseFilter.setOutGreen(new IntRange(0, 255));
            baseFilter.setOutBlue(new IntRange(0, 255));
            baseFilter.setOutGray(new IntRange(0, 255));
        } else {
            baseFilter.setInRed(new IntRange(-factor, 255 + factor));
            baseFilter.setInGreen(new IntRange(-factor, 255 + factor));
            baseFilter.setInBlue(new IntRange(-factor, 255 + factor));
            baseFilter.setInGray(new IntRange(-factor, 255 + factor));

            baseFilter.setOutRed(new IntRange(0, 255));
            baseFilter.setOutGreen(new IntRange(0, 255));
            baseFilter.setOutBlue(new IntRange(0, 255));
            baseFilter.setOutGray(new IntRange(0, 255));
        }
    }
280862
def ScaleLarger(self):
    """"""
    newfactor = self._zoomfactor + 0.1
    if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM:
      self._zoomfactor = newfactor
673649
private RectF getMatrixRectF() {
		Matrix matrix = scaleMatrix;
		RectF rect = new RectF();
		Drawable d = getDrawable();
		if (null != d) {
			rect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
			matrix.mapRect(rect);
		}
		return rect;
	}
922178
public static ListDouble rescale(final ListNumber data, final double factor, final double offset) {
        if (factor == 1.0)
            return add(data, offset);
        return new ListDouble() {

            @Override
            public double getDouble(int index) {
                return factor * data.getDouble(index) + offset;
            }

            @Override
            public int size() {
                return data.size();
            }
        };
    }
496362
def resize(self, size:Union[int,TensorImageSize]) -> 'ImagePoints':
        ""
        if isinstance(size, int): size=(1, size, size)
        self._flow.size = size[1:]
        return self
802202
def inspect
      use_dimension
      a = [Utils.num_inspect(@factor), @dim.inspect]
      a << "@name="+@name.inspect if @name
      a << "@expr="+@expr.inspect if @expr
      a << "@offset="+@offset.inspect if @offset
      a << "@dimensionless=true" if @dimensionless
      if @dimension_value && @dimension_value!=1
        a << "@dimension_value="+@dimension_value.inspect
      end
      s = a.join(",")
      "#<#{self.class} #{s}>"
    end
1167257
private function blur($gdImageResource, $blurFactor = 3)  
    {  
        // blurFactor has to be an integer  
        $blurFactor = round($blurFactor);  
  
        $originalWidth = imagesx($gdImageResource);  
        $originalHeight = imagesy($gdImageResource);  
  
        $smallestWidth = ceil($originalWidth * pow(0.5, $blurFactor));  
        $smallestHeight = ceil($originalHeight * pow(0.5, $blurFactor));  
  
        // for the first run, the previous image is the original input  
        $prevImage = $gdImageResource;  
        $prevWidth = $originalWidth;  
        $prevHeight = $originalHeight;  
  
        // scale way down and gradually scale back up, blurring all the way  
        for($i = 0; $i < $blurFactor; $i += 1)  
        {      
            // determine dimensions of next image  
            $nextWidth = $smallestWidth * pow(2, $i);  
            $nextHeight = $smallestHeight * pow(2, $i);  
  
            // resize previous image to next size  
            $nextImage = imagecreatetruecolor($nextWidth, $nextHeight);  
            imagecopyresized($nextImage, $prevImage, 0, 0, 0, 0,   
              $nextWidth, $nextHeight, $prevWidth, $prevHeight);  
  
            // apply blur filter  
            imagefilter($nextImage, IMG_FILTER_GAUSSIAN_BLUR);  
  
            // now the new image becomes the previous image for the next step  
            $prevImage = $nextImage;  
            $prevWidth = $nextWidth;  
            $prevHeight = $nextHeight;  
        }  
  
        // scale back to original size and blur one more time  
        imagecopyresized($gdImageResource, $nextImage,   
        0, 0, 0, 0, $originalWidth, $originalHeight, $nextWidth, $nextHeight);  
        imagefilter($gdImageResource, IMG_FILTER_GAUSSIAN_BLUR);  
  
        // clean up  
        imagedestroy($prevImage);  
  
        // return result  
        return $gdImageResource;  
    }
250129
final public function scaleImage($factor = 1)
	{
		// Scaling by a factor of 1 produces no changes, so do not scale if it is 1
		if (is_numeric($factor) and $factor !== 1) {
			$new_width  = round(abs($factor * $this->imageWidth()));
			$new_height = round(abs($factor * $this->imageHeight()));
			$this->_image_handle = imagescale($this->_image_handle, $new_width, $new_height);
		}

		return $this;
	}
1180795
def use_dimension
      return if @dim && @factor
      if @expr && @dim.nil?
        #puts "unit='#{@name}', parsing '#{@expr}'..." if Unit.debug
        unit = Unit.parse(@expr)
        case unit
        when Unit
          @dim = unit.dim
          @factor = unit.factor
          if @dim.nil? || @factor.nil?
            raise UnitError,"parse error : #{unit.inspect}"
          end
        when Numeric
          @factor = unit
          alloc_dim
        else
          raise UnitError,"parse error : #{self.inspect}"
        end
      else
        raise UnitError,"undefined unit?: #{self.inspect}"
      end
    end