【问题标题】:How to convert my photos to webp format of Google in windows 8.1?如何在 Windows 8.1 中将我的照片转换为 Google 的 webp 格式?
【发布时间】:2014-08-20 11:29:55
【问题描述】:

我想将我的照片从 jpg、gif 和 png 转换为 WebP 格式。

当我尝试使用 CMD 来使用 cwebp 命令时,我收到了以下错误消息:

'cwebp' 未被识别为内部或外部命令, 可运行的程序或批处理文件。

我该怎么办?

我已经下载了所有需要的文件,例如libwebp-0.4.0-windows-x86.zipWebpCodecSetup.exe

即使我已经安装了 Visual Studio 来使用它的命令提示符,但还是没有用!有没有人可以帮助我?

还有一个问题:

有没有人知道有什么工具可以在不降低图像质量的情况下减小图像尺寸?

【问题讨论】:

  • 这个softeware解决的问题
  • 你为什么不提出并回答你的答案,让大家清楚@HoseinBL问题已经解决?
  • 我刚刚找到了一个 Webp GUI!
  • 好吧,我的意思是,在这个网站上,当您知道自己问题的答案时,建议您发布答案并接受它,以便每个人都可以看到问题已经解决。
  • 我不能!因为我的声誉分数低于 10 :(

标签: powershell image-processing cmd image-compression webp


【解决方案1】:

下载cwebp binaries (.exe) 并使用 PowerShell 运行:

# tip: on windows explorer shift + right-click a directory and copy its path
$dir = "path/to/photos/directory"

# get all files in the directory
$images = Get-ChildItem $dir

foreach ($img in $images) {
  # output file will be written in the same directory 
  # but with .webp extension instead of old extension
  $outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"

  C:\webp-converter\libwebp-0.6.1-windows-x64\bin\cwebp.exe $img.FullName -o $outputName
}

另见cwebp options

【讨论】:

  • 这不是愚人节玩笑,运行完美,如果确实将 bin 文件夹添加到 PATH(windows 环境变量)中,您只需键入 cwebp -q 75 -m 6 -af -f 50 -sharpness 0 -mt -v -progress $img.FullName -o $outputName 即可。
  • 如何使最后一个链接与路径中的空格一起使用?而不是C:\webp-converter\libwebp-0.6.1-windows-x64\bin\cwebp.exe $img.FullName -o $outputNameC:\Program Files\a lot of spaces in the path\bin\cwebp.exe $img.FullName -o $outputName。谢谢。
  • @EPurpl3 这可能会有所帮助:stackoverflow.com/questions/18537098/…
  • @pldg 我们如何递归地完成这项工作?我有一个包含许多带有图像的子文件夹的分支。
【解决方案2】:

从 Windows 命令行 (CMD) 将任何图像格式转换为 webp

this页面下载最新的webp版本

我下载了this包因为我的系统是32位windows 10

提取它并设置环境变量(按照以下步骤)

点击开始按钮输入“查看高级系统设置”并打开(win xp或win 7此步骤可能不同) 点击环境变量>用户变量>新建>变量名:路径变量值:C:\libwebp-1.0.2-windows-x86\bin

现在打开 CMD > 转到 Image 文件夹运行以下命令

cwebp -q 50 -m 6 -af -f 50 -sharpness 0 -mt -v -progress source_img.jpg -o converted.webp

【讨论】:

    【解决方案3】:

    从 Google 下载 cwebp binaries (.exe) 后,您可以使用 PowerShell 运行它。

    然后将 bin 目录添加到您将 cwebp 库解压缩到您的 Windows PATH 的位置。例如,这类似于C:\downloads\libs\LibWebP\bin。如果您不知道如何执行此操作,请搜索“如何向 Windows PATH 添加内容”。这是an example link

    如果您需要从当前目录遍历每个子目录,您可以在下面执行此操作,而不是将路径粘贴到脚本中的当前目录并对目录中的每个文件夹执行此操作。

    # get current directory
    $initpath = Get-Location
    # get all directories
    foreach($path in Get-Childitem) {
        if ($path.Attributes -eq "Directory") {
            set-location $path.FullName
              # get all files in the directory
              $images = Get-ChildItem $dir
    
              # loop through every image
              foreach ($img in $images) {
                # output file will be written in the same directory
                # but with .webp extension instead of old extension
                $outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"
    
                # since you have the cwebp bin folder in PATH just type the command
                # more options https://developers.google.com/speed/webp/docs/cwebp
                cwebp -q 75 -m 6 -af -f 50 -sharpness 0 -mt -v -progress $img.FullName -o $outputName
              }
        }
    }
    set-location $initpath
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-01
      • 2015-09-16
      • 2020-05-30
      • 2013-05-28
      • 2015-05-23
      • 1970-01-01
      • 2021-10-22
      相关资源
      最近更新 更多