Copy an image into user-specified directory, and emit
 a corresponding <tt>&lt;img&gt;</tt> element.

 If the user has not specified an image directory,
 then emit a <tt>&lt;div&gt;</tt> containing the
 file name.
355426
def process_draw_image( element, output_node )
      pic_name = element.attribute("#{@xlink_ns}:href").value
      if (@image_dir != nil) then
        img = emit_element( output_node, "img" )
        img.attributes["alt"] = pic_name

        # Get rid of everything before the last / in the filename
        base_name = pic_name;
        if ((pos = base_name.rindex('/')) != nil) then
          base_name = base_name[pos + 1 .. -1]
        end
        copy_image_file( pic_name, @image_dir, base_name )
        img.attributes["src"] = "#{@image_dir}/#{base_name}"
        width = element.parent.attribute("#{@svg_ns}:width")
        height= element.parent.attribute("#{@svg_ns}:height")
        if (width != nil && height != nil) then
          img.attributes["style"] = "width:#{width.value}; " +
            "height:#{height.value}"
        end
      else
        div = emit_element( output_node, "div" )
        div.add_text( pic_name )
      end
    end
843082
function image(filename) {
  if (!filename) return;
  var ext = filename.split('.')[filename.split('.').length - 1];
  return ~extensions.join().indexOf(ext);
}
503015
function insertImage(map) {
    let src = map.selectNode().image.src;

    if (src === "") {
        let value = prompt("Please enter your name", "example/img/material-icons/add.svg");

        if (value) {
            map.updateNode("imageSrc", value);
        }
    } else {
        map.updateNode("imageSrc", "");
    }
}
1248965
function copyFile (src, done) {
        var dest = path.join(outdir, path.relative(compiler.dirname, src))
        var dirname = utils.dirname(dest)

        if (dirname === dest) {
          copy(src, dest, compiler.dirname, done)
        } else {
          mkdirp(dirname, function (err) {
            if (err) return done(err)
            copy(src, dest, compiler.dirname, done)
          })
        }
      }
10579
def stage(self, startimage, newimage):
        
        client = utils.get_client()
        cprint('  Copying file from "%s:/%s" \n                 to "%s://%s/"'
               % (self.sourceimage, self.sourcepath, startimage, self.destpath),
               'blue')

        # copy build artifacts from the container if necessary
        cachedir = self._setcache(client)
        cacherelpath = os.path.relpath(cachedir, TMPDIR)

        # if cached file doesn't exist (presumably purged by OS), trigger it to be recreated
        if os.path.exists(cachedir) and not os.path.exists(os.path.join(cachedir, 'content.tar')):
            shutil.rmtree(cachedir)

        if not os.path.exists(cachedir):
            print(' * Creating cache at %s' % cacherelpath)
            container = client.containers.create(self.sourceimage)
            try:
                tarfile_stream, tarfile_stats = container.get_archive(self.sourcepath)
            except docker.errors.NotFound:
                raise errors.MissingFileError(
                        'Cannot copy file "%s" from image "%s" - it does not exist!' %
                        (self.sourcepath, self.sourceimage))

            # write files to disk (would be nice to stream them, haven't gotten it to work)
            tempdir = tempfile.mkdtemp(dir=BUILD_TEMPDIR)
            with open(os.path.join(tempdir, 'content.tar'), 'wb') as localfile:
                for chunk in tarfile_stream:
                    localfile.write(chunk)
            os.mkdir(cachedir)
            os.rename(tempdir, cachedir)
        else:
            print('  Using cached files from %s' % cacherelpath)

        # write Dockerfile for the new image and then build it
        dockerfile = 'FROM %s\nADD content.tar %s' % (startimage, self.destpath)
        with open(os.path.join(cachedir, 'Dockerfile'), 'w') as df:
            df.write(dockerfile)

        buildargs = dict(path=cachedir,
                         tag=newimage,
                         decode=True)
        utils.set_build_cachefrom(self.cache_from, buildargs, client)

        # Build and show logs
        stream = client.api.build(**buildargs)
        try:
            utils.stream_docker_logs(stream, newimage)
        except ValueError as e:
            raise errors.BuildError(dockerfile, e.args[0], build_args=buildargs)
633102
def copy_file(src, target):
    
    LOGGER.info("Copying {} to {}".format(src, target))
    shutil.copyfile(src, target)
    shutil.copymode(src, target)
1048546
public void saveImages( Element form )
                            throws IOException {
        List<Element> images = DomUtils.getElementsByTagName( form, "img" );
        int imageCount = 1;
        for ( Element image : images ) {
            if ( image.hasAttribute( "src" ) ) {
                String src = image.getAttribute( "src" );
                String imageFormat = parseImageFormat( src );
                String testName = System.getProperty( "TestName" );
                String imgName = parseImageName( testName );
                URL url = new URL( src );
                BufferedImage img = ImageIO.read( url );
                File file = createImageFile( imageCount, imageFormat, imgName );
                if ( !file.exists() ) {
                    file.getParentFile().mkdirs();
                }
                ImageIO.write( img, imageFormat, file );
                imageCount++;
            }
        }
    }
215129
function downloadImage(map) {
    map.exportAsImage(function (url) {
        let a = document.createElement("a");
        a.download = "example";
        a.href = url;
        a.click();
    }, "jpeg");
}
564236
def insert(exif, image, new_file=None):
    
    if exif[0:6] != b"\x45\x78\x69\x66\x00\x00":
        raise ValueError("Given data is not exif data")

    output_file = False
    # Prevents "UnicodeWarning: Unicode equal comparison failed" warnings on Python 2
    maybe_image = sys.version_info >= (3,0,0) or isinstance(image, str)

    if maybe_image and image[0:2] == b"\xff\xd8":
        image_data = image
        file_type = "jpeg"
    elif maybe_image and image[0:4] == b"RIFF" and image[8:12] == b"WEBP":
        image_data = image
        file_type = "webp"
    else:
        with open(image, 'rb') as f:
            image_data = f.read()
        if image_data[0:2] == b"\xff\xd8":
            file_type = "jpeg"
        elif image_data[0:4] == b"RIFF" and image_data[8:12] == b"WEBP":
            file_type = "webp"
        else:
            raise InvalidImageDataError
        output_file = True

    if file_type == "jpeg":
        exif = b"\xff\xe1" + struct.pack(">H", len(exif) + 2) + exif
        segments = split_into_segments(image_data)
        new_data = merge_segments(segments, exif)
    elif file_type == "webp":
        exif = exif[6:]
        new_data = _webp.insert(image_data, exif)

    if isinstance(new_file, io.BytesIO):
        new_file.write(new_data)
        new_file.seek(0)
    elif new_file:
        with open(new_file, "wb+") as f:
            f.write(new_data)
    elif output_file:
        with open(image, "wb+") as f:
            f.write(new_data)
    else:
        raise ValueError("Give a 3rd argument to 'insert' to output file")
1253942
def explicit_images(images, image_destination, rootname, config):
    
    log.info('Explicit image directory specified: {0}'.format(images))
    if '*' in images:
        images = images.replace('*', rootname)
        log.debug('Wildcard expansion for image directory: {0}'.format(images))
    try:
        shutil.copytree(images, image_destination)
    except:
        #The following is basically a recipe for log.exception() but with a
        #CRITICAL level if the execution should be killed immediately
        #log.critical('Unable to copy from indicated directory', exc_info=True)
        log.exception('Unable to copy from indicated directory')
        return False
    else:
        return True
223933
function(base) {
				var node = $(base).children('img:first');
				if (node.attr('src').substr(0, 5) !== 'data:') {
					node.attr('src', imgBase64(node, this.file.mime));
				}
			}
962052
public void copyResourceToDir(String path, String filename, String dir) {
		String fullpath = path + ProcessorConstants.SEPARATORCHAR + filename;
		messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript copy js : " + fullpath + " to : "+dir);
		try (Writer writer = getFileObjectWriter(dir, "org.ocelotds."+filename)) {
			bodyWriter.write(writer, OcelotProcessor.class.getResourceAsStream(fullpath));
		} catch (IOException ex) {
			messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + filename);
		}
	}
247553
public void takeScreenshot(String imageName) {
        if (browser.getName() == BrowserName.HTMLUNIT) {
            return;
        }
        try {
            // take a screenshot
            File srcFile;
            if (Property.isHubSet()) {
                WebDriver augemented = new Augmenter().augment(driver);
                srcFile = ((TakesScreenshot) augemented).getScreenshotAs(OutputType.FILE);
            } else {
                srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
            }
            // now we need to save the file
            FileUtils.copyFile(srcFile, new File(imageName));
        } catch (Exception e) {
            log.error("IO Error taking screenshot: " + e);
        }
    }
172046
function copyFiles(dir) {
    var files = fs.readdirSync(srcDir + dir);
    files.forEach(function(file) {
      var currentDir = dir + file;
      if (!regexExcludeFiles.test(currentDir)) {
        var stats = fs.statSync(srcDir + currentDir);
        if (stats.isDirectory()) {
          if (!fs.existsSync(publishDir + currentDir)) {
            fs.mkdirSync(publishDir + currentDir);
          }
          copyFiles(currentDir + "/");
        } else if (stats.isFile()) {
          var contents = fs.readFileSync(srcDir + currentDir);
          fs.writeFileSync(publishDir + currentDir, contents);
        }
      }
    });
  }
927066
def image_to_file(self, path):
        
        _LOGGER.debug("Writing image from %s to %s", self.name, path)
        response = self._cached_image
        if response.status_code == 200:
            with open(path, 'wb') as imgfile:
                copyfileobj(response.raw, imgfile)
        else:
            _LOGGER.error("Cannot write image to file, response %s",
                          response.status_code,
                          exc_info=True)
1037134
public String imageSubmit (String name, String value, String imagePath)
    {
        return fixedInput("image", name, value, "src=\"" + imagePath + "\"");
    }
76546
public static void writeHtmlImagePreloadJavaScript(String url, Appendable out) throws IOException {
		out.append("<script type='text/javascript'>\n"
				+ "  var img=new Image();\n"
				+ "  img.src=\"");
		// Escape for javascript
		StringBuilder javascript = new StringBuilder(url.length());
		encodeTextInJavaScript(url, javascript);
		// Encode for XML attribute
		encodeJavaScriptInXhtmlAttribute(javascript, out);
		out.append("\";\n"
				+ "</script>");
	}