Convert normal image to webp file

@param src  nomal image path
@param dest webp file path
336850
public void toWEBP(String src, String dest) {
        toWEBP(new File(src), new File(dest));
    }
629690
public Sftp get(String src, String dest) {
		try {
			channel.get(src, dest);
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		return this;
	}
1053489
function extend(dest, src) {
    var result = dest;
    for(var n in src) {
        result[n] = src[n];
    }
    return result;
}
262839
public static function appendTo($src, $dest, $newline = false) {

        // Open the destination.
        $reader = @fopen($src, "r");
        if (false === $reader) {
            throw new FileNotFoundException($src);
        }

        // Open the destination.
        $writer = @fopen($dest, "a");
        if (false === $writer) {
            throw new IOException(sprintf("Failed to open \"%s\"", $dest));
        }

        // Append the source into destination.
        if (false === @file_put_contents($dest, $reader, FILE_APPEND)) {
            throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest));
        }

        // Append a new line.
        if (true === $newline && false === @file_put_contents($dest, "\n", FILE_APPEND)) {
            throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest));
        }

        // Close the files.
        if (false === @fclose($reader)) {
            throw new IOException(sprintf("Failed to close \"%s\"", $src));
        }
        if (false === @fclose($writer)) {
            throw new IOException(sprintf("Failed to close \"%s\"", $dest));
        }
    }
1191089
public static void drawTo(Bitmap src, Bitmap dest, int color) {
        clearBitmap(src, color);
        Canvas canvas = new Canvas(dest);
        canvas.drawBitmap(src, 0, 0, null);
        canvas.setBitmap(null);
    }
636806
public static void convert(File srcImageFile, File destImageFile) {
		Assert.notNull(srcImageFile);
		Assert.notNull(destImageFile);
		Assert.isFalse(srcImageFile.equals(destImageFile), "Src file is equals to dest file!");

		final String srcExtName = FileUtil.extName(srcImageFile);
		final String destExtName = FileUtil.extName(destImageFile);
		if (StrUtil.equalsIgnoreCase(srcExtName, destExtName)) {
			// 扩展名相同直接复制文件
			FileUtil.copy(srcImageFile, destImageFile, true);
		}

		ImageOutputStream imageOutputStream = null;
		try {
			imageOutputStream = getImageOutputStream(destImageFile);
			convert(read(srcImageFile), destExtName, imageOutputStream, StrUtil.equalsIgnoreCase(IMAGE_TYPE_PNG, srcExtName));
		} finally {
			IoUtil.close(imageOutputStream);
		}
	}
1186341
public static void copyFile(File src, File dest) throws IOException {

        if (src == null)
            throw new NullPointerException("Source must not be null");
        if (dest == null)
            throw new NullPointerException("Destination must not be null");
        if (!src.exists())
            throw new FileNotFoundException("Source '" + src + "' does not exist");
        if (!src.isFile())
            throw new IOException("Source '" + src + "' is not a file");
        if (dest.exists())
            throw new IOException("Destination '" + dest + "' is already exists");

        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(src).getChannel();
            out = new FileOutputStream(dest).getChannel();

            in.transferTo(0, in.size(), out);
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        if (src.length() != dest.length()) {
            throw new IOException("Failed to copy full contents from '" +
                src + "' to '" + dest + "'");
        }

        dest.setLastModified(src.lastModified());
    }
700072
protected function preserveAlpha($dest, $src)
    {
        $transparent = @imagecolortransparent($src);
        if (-1 != $transparent) {
            $color = @imagecolorsforindex($src, $transparent);
            $allocated = @imagecolorallocatealpha(
                            $dest
                            , $color['red']
                            , $color['green']
                            , $color['blue']
                            , $color['alpha']
            );
            @imagecolortransparent($dest, $allocated);
            @imagefill($dest, 0, 0, $allocated);
        }
    }
667279
public void toNormalImage(String src, String dest) {
        toNormalImage(new File(src), new File(dest));
    }
65359
public void decompress(ByteBuffer src, ByteBuffer dest) {
    final int destLen = getDecompressedLength(src, src.position());
    final int read = decompressor.decompress(src, src.position() + 4, dest, dest.position(), destLen);
    src.position(src.position() + 4 + read);
    dest.position(dest.position() + destLen);
  }
130733
@Override
    public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        BufferedImage image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), getRenderingHints()).filter(src, dest);

        Graphics2D g2d = dest.createGraphics();
        try {
            g2d.drawImage(image, 0, 0, null);
        }
        finally {
            g2d.dispose();
        }

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = -.0055;
            g.rotate(angle);

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

        }
        finally {
            g.dispose();
        }

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = (random.nextDouble() * .01) - .005;
            graphics.rotate(angle);
            graphics.fillRoundRect(4, 4, image.getWidth() - 8, image.getHeight() - 8, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        // Noise
        NoiseFilter noise = new NoiseFilter();
        noise.setAmount(20);
        noise.setDensity(1);
        noise.setMonochrome(true);
        foo = noise.filter(foo, foo);

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        float[] scales = new float[] {1, 1, 1, 1};
        float[] offsets = new float[] {80, 40, 0, 0};
        foo = new RescaleOp(scales, offsets, getRenderingHints()).filter(foo, foo);

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            g.setComposite(AlphaComposite.SrcOver);
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }
279709
private static function rmove($src, $dest){
    // If source is not a directory stop processing
    if(!is_dir($src)) {
      echo "Source is not a directory";
      return false;
    }

    // If the destination directory does not exist create it
    if(!is_dir($dest)) {
        if(!mkdir($dest,0777,true)) {
            // If the destination directory could not be created stop processing
            echo "Can't create destination path: {$dest}\n";
            return false;
        }
    }

    // Open the source directory to read in files
    $i = new \DirectoryIterator($src);
    foreach($i as $f) {
      #Skip useless files&folders
      if (self::isFileIgnored($f->getFilename())) continue;

      if($f->isFile()) {
        rename($f->getRealPath(), "$dest/" . $f->getFilename());
      } else if(!$f->isDot() && $f->isDir()) {
        self::rmove($f->getRealPath(), "$dest/$f");
        #unlink($f->getRealPath());
      }
    }
    #We could Remove original directories but don't do it
    #unlink($src);
  }
1009941
function (src, dest, content, fileObject) {
						var files = {};

						_.each(content, function (v, k) {
							var file = fileObject.orig.dest + '/' + k + '.json';

							files[file] = JSON.stringify(v);
						});

						return files;
					}
729436
public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        // Make image faded/washed out/red-ish
        // DARK WARM
        float[] scales = new float[] { 2.2f, 2.0f, 1.55f};
        float[] offsets = new float[] {-20.0f, -90.0f, -110.0f};

        // BRIGHT NATURAL
//        float[] scales = new float[] { 1.1f, .9f, .7f};
//        float[] offsets = new float[] {20, 30, 80};

        // Faded, old-style
//        float[] scales = new float[] { 1.1f, .7f, .3f};
//        float[] offsets = new float[] {20, 30, 80};

//        float[] scales = new float[] { 1.2f, .4f, .4f};
//        float[] offsets = new float[] {0, 120, 120};

        // BRIGHT WARM
//        float[] scales = new float[] {1.1f, .8f, 1.6f};
//        float[] offsets = new float[] {60, 70, -80};
        BufferedImage image = new RescaleOp(scales, offsets, getRenderingHints()).filter(src, null);

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = .0055;
            g.rotate(angle);

            // Scratches
            g.setComposite(AlphaComposite.SrcOver.derive(.025f));
            for (int i = 0; i < 100; i++) {
                g.setColor(random.nextBoolean() ? Color.WHITE : Color.BLACK);
                g.setStroke(new BasicStroke(random.nextFloat() * 2f));
                int x = random.nextInt(image.getWidth());

                int off = random.nextInt(100);
                for (int j = random.nextInt(3); j > 0; j--) {
                    g.drawLine(x + j, 0, x + off - 50 + j, image.getHeight());
                }
            }

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.75f));
            int focus = Math.min(image.getWidth() / 8, image.getHeight() / 8);
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.6f,
                    new Point(focus, focus),
                    new float[] {0, .3f, .9f, 1f},
                    new Color[] {new Color(0x99FFFFFF, true), new Color(0x00FFFFFF, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(-2, -2, image.getWidth() + 4, image.getHeight() + 4);

            g.rotate(-angle);

            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

            // Highlight
            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth(), image.getHeight()),
                    Math.max(image.getWidth(), image.getHeight()) * 1.1f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .75f, 1f},
                    new Color[] {new Color(0x00FFFFFF, true), new Color(0x00FFFFFF, true), Color.PINK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
        }
        finally {
            g.dispose();
        }

        // Noise
        NoiseFilter noise = new NoiseFilter();
        noise.setAmount(10);
        noise.setDensity(2);
        dest = noise.filter(dest, dest);

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = (random.nextDouble() * .01) - .005;
            graphics.rotate(angle);
            graphics.fillRoundRect(4, 4, image.getWidth() - 8, image.getHeight() - 8, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        noise.setAmount(20);
        noise.setDensity(1);
        noise.setMonochrome(true);
        foo = noise.filter(foo, foo);

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            if (dest.getTransparency() != Transparency.OPAQUE) {
                g.setComposite(AlphaComposite.Clear);
            }
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.setComposite(AlphaComposite.SrcOver);
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }
598789
public void copyFile(final RelativeResource src, final RelativeResource dest)
		throws IOException {
		if (src.equals(dest)) {
			return;
		}
		LOG.debug("复制文件从 {} 到 {}", src, dest);
		File srcFile = getResource(src).getFile();
		if (!srcFile.exists()) {
			throw new FileNotFoundException(srcFile.getAbsolutePath());
		}
		File destFile = getResource(dest).getFile();
		deleteOldFile(destFile);
		FileUtils.copyFile(srcFile, destFile);
	}
359856
function mapImages(imageMap, srcFolder, destFolder) {
  return through.obj(function(file, enc, cb) {
    // find the relative path to image. If any pipe has changed the filename,
    // it's the original is set in orgRelative, so we look at that first.
    var relativeFrom = file.orgRelative || file.relative;
    var relativeTo = path.join(destFolder, file.relative);
    imageMap[relativeFrom] = relativeTo;
    cb(null, file);
  });
}
769608
public function copy(PhingFile $src, PhingFile $dest)
    {
        global $php_errormsg;

        // Recursively copy a directory
        if ($src->isDirectory()) {
            $this->copyr($src->getAbsolutePath(), $dest->getAbsolutePath());
        }

        $srcPath = $src->getAbsolutePath();
        $destPath = $dest->getAbsolutePath();

        if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err.
            // Add error from php to end of log message. $php_errormsg.
            $msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $php_errormsg";
            throw new IOException($msg);
        }

        $dest->setMode($src->getMode());
    }