Draw an image from a file on a canvas.
@param file The uploaded file.
@param $canvas The canvas (jQuery) object to draw on.
@param callback Function that is called when the operation has finished.
506326
function(file, $canvas, callback) {
            this.newImage();
            if (!file)
                return;

            var reader = new FileReader();
            reader.onload = function (fileReaderEvent) {
                image.onload = function () { readImageToCanvasOnLoad(this, $canvas, callback); };
                image.src = fileReaderEvent.target.result;      // The URL from FileReader

            };
            reader.readAsDataURL(file);
        }
834233
protected function openPng($file)
    {
        if (file_exists($file) && filesize($file)) {
            $this->resource = @imagecreatefrompng($file);
        } else {
            $this->resource = false;
        }
    }
1336320
public function processImage( $file, $width = null, $height = null, $mwidth = null, $mheight = null, $twidth = null, $theight = null ) {

		$dateDir	= date( 'Y-m-d' );
		$imageName	= $file->name;
		$imageExt	= $file->extension;
		$imageDir	= $file->directory;

		$uploadDir	= $this->uploadDir;

		$sourceFile	= "$imageDir/$imageName.$imageExt";
		$targetDir	= "$dateDir/$imageDir/";

		$imageUrl		= $targetDir . "$imageName.$imageExt";
		$imageMediumUrl	= $targetDir . "$imageName-medium.$imageExt";
		$imageThumbUrl	= $targetDir . "$imageName-thumb.$imageExt";

		// Update File Size in MB
		$fileContent	= file_get_contents( "$uploadDir/temp/$sourceFile" );
		$file->size		= number_format( strlen( $fileContent ) / 1048576, 8 );

		// Save Image
		$this->saveImage( $sourceFile, $targetDir, $imageUrl, $imageMediumUrl, $imageThumbUrl, $width, $height, $mwidth	 = null, $mheight = null, $twidth	 = null, $theight = null );

		// Update URL and Thumb
		$file->url = $imageUrl;

		if( $this->generateImageMedium ) {

			$file->medium = $imageMediumUrl;
		}

		if( $this->generateImageThumb ) {

			$file->thumb = $imageThumbUrl;
		}
	}
1248019
@Override
    public void onFileCreate(File file) {
        try {
            engine.addTemplate(context.getBundle(0), file.toURI().toURL());
        } catch (MalformedURLException e) {
            LOGGER.error("Cannot compute the url of file {}", file.getAbsolutePath(), e);
        }
    }
836558
function readFile(file, callback){

		// Run this sequentially
		sync(function(){
			// Create a new FileReader Object
			var reader = new FileReader();

			// Set an onload handler because we load files into it Asynchronously
			reader.onload = function(e){

				// Print onto Canvas
				callback( this.result );

				// Run the next one;
				sync();
			};

			reader.readAsDataURL(file);
		});
	}
986175
function onLoad(event) {
        var img = new Image();
        img.onload = utils.getDimensions(canvas, vm.$storage);
        img.src = event.target.result;
      }
193925
public void add(Image image) {
    assert !start || listener == null;
    ++total;
    image.addCallback(callback);
  }
889111
@SuppressWarnings("all")
	@Override
	protected void onDraw(final Canvas canvas) {
		super.onDraw(canvas);
		LOGGER.trace("Called Action Button onDraw");
		drawCircle(canvas);
		if (isRippleEffectEnabled()) {
			drawRipple(canvas);
		}
		if (hasElevation()) {
			drawElevation();
		}
		if (hasStroke()) {
			drawStroke(canvas);
		}
		if (hasImage()) {
			drawImage(canvas);
		}
		getInvalidator().invalidate();
	}
362648
protected function applyCallback($callbackName, \Upload\FileInfoInterface $file)
    {
        if (in_array($callbackName, array('beforeValidation', 'afterValidation', 'beforeUpload', 'afterUpload')) === true) {
            if (isset($this->$callbackName) === true) {
                call_user_func_array($this->$callbackName, array($file));
            }
        }
    }
957811
public function draw() {
        ob_start();
        imagepng($this->im);
        $bin = ob_get_contents();
        ob_end_clean();

        $this->setInternalProperties($bin);

        if (empty($this->filename)) {
            echo $bin;
        } else {
            file_put_contents($this->filename, $bin);
        }
    }
1051176
protected void drawStroke(Canvas canvas) {
		resetPaint();
		getPaint().setStyle(Paint.Style.STROKE);
		getPaint().setStrokeWidth(getStrokeWidth());
		getPaint().setColor(getStrokeColor());
		canvas.drawCircle(calculateCenterX(), calculateCenterY(), calculateCircleRadius(), getPaint());
		LOGGER.trace("Drawn the Action Button stroke");
	}
435516
function(file, callback) {
      if (any(hook('loading', file), haveStopped)) return
      if ('readFile' in main)
        return readFile(file)
      else if (this.hasXhr()) {
        var request = this.xhr()
        request.open('GET', file, false)
        request.send(null)
        if (request.readyState == 4 && 
           (request.status == 0 || 
            request.status.toString().charAt(0) == 2)) 
          return request.responseText
      }
      else
        error("failed to load `" + file + "'")
    }
1117512
public static function apply($file, $filters)
    {
        if( ! empty($filters) )
        { 
            $gd = self::getSingletonGDClass();

            $gd->canvas($file);
            
            foreach( $filters as $filter )
            {
                $method     = $filter[0];
                $parameters = $filter[1] ?? [];

                $gd->$method(...(array) $parameters);
            }
    
            $gd->generate(MimeTypeFinder::get($file), $file);
        }
    }
290530
function(images, callback) {
            var loaded = 0;
            images.forEach(function(src) {
                var image = new Image();
                image.onload = function() {
                    ++loaded;
                    loaded === images.length && callback();
                };
                image.src = src;
            });
        }
1339072
function loadJSON (file, callback) {
  loadText(file, function (err, data) {
    if (err) {
      callback(err, null)
    } else {
      var json = null
      try {
        json = JSON.parse(data)
      } catch (e) {
        return callback(e, null)
      }
      callback(null, json)
    }
  })
}
630765
void draw(Canvas canvas) {
        mCanvasRect.set(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight());
        switch (mShape) {
            case SHAPE_RECTANGLE:
                canvas.drawRect(mCanvasRect, mCanvasPaint);
                break;
            case SHAPE_OVAL:
                canvas.drawOval(mCanvasRect, mCanvasPaint);
                break;
            case SHAPE_STAR_3_VERTICES:
            case SHAPE_STAR_4_VERTICES:
            case SHAPE_STAR_5_VERTICES:
            case SHAPE_STAR_6_VERTICES:
                drawStar(canvas, mShape);
                break;
            case SHAPE_HEART:
                drawHeart(canvas);
                break;
        }
    }
1262513
function(svg, mine, callback) {
        svg = (new XMLSerializer()).serializeToString(svg);
        svg = 'data:image/svg+xml;charset=utf-8,' + encodeURI(svg);
        if (mine == 'image/svg+xml') {
            callback(null, svg);
            return;
        }
        var img = new Image();
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        img.onload = function() {
            canvas.width = img.width;
            canvas.height = img.height;
            ctx.drawImage(img, 0, 0);
            var dataURL = canvas.toDataURL(mine);
            callback(null, dataURL);
        };
        img.src = svg;
    }