Merge pull request #23189 from geekpi/translating

translated
This commit is contained in:
geekpi 2021-09-09 08:41:30 +08:00 committed by GitHub
commit 7dd0356e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 81 deletions

View File

@ -1,81 +0,0 @@
[#]: subject: "Resize an image from the Linux terminal"
[#]: via: "https://opensource.com/article/21/9/resize-image-linux"
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
[#]: collector: "lujun9972"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Resize an image from the Linux terminal
======
Shrink an image from your terminal with the ImageMagick convert command.
![Old camera blue][1]
ImageMagick is a handy multipurpose command-line tool for all your image needs. ImageMagick supports a variety of image types, including JPG photos and PNG graphics.
### Resizing images
I often use ImageMagick on my webserver to resize images. For example, let's say I want to include a photo of my cats on my personal website. The photo from my phone is very large, about 4000x3000 pixels, at 3.3MB. That's much too large for a web page. I use the ImageMagick convert tool to change the size of my photo so that I can include it on my web page. ImageMagick is a full suite of tools, one of the most common is the `convert` command.
The ImageMagick `convert` command uses this general syntax:
```
`convert {input} {actions} {output}`
```
To resize a photo called `PXL_20210413_015045733.jpg` to a more manageable 500-pixel width, type this:
```
`$ convert PXL_20210413_015045733.jpg -resize 500x sleeping-cats.jpg`
```
The new image is now only 65KB in size. 
![Sleeping cats][2]
Jim Hall, [CC BY-SA 4.0][3]
You can provide both width and height dimensions with the `-resize` option. But, by providing only the width, ImageMagic does the math for you and automatically retains the aspect ratio by resizing the output image with a proportional height.
### Install ImageMagick on Linux
On Linux, you can install ImageMagick using your package manager. For instance, on Fedora or similar:
```
`$ sudo dnf install imagemagick`
```
On Debian and similar:
```
`$ sudo apt install imagemagick`
```
On macOS, use [MacPorts][4] or [Homebrew][5].
On Windows, use [Chocolatey][6].
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/9/resize-image-linux
作者:[Jim Hall][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/jim-hall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-blue.png?itok=AsIMZ9ga (Old camera blue)
[2]: https://opensource.com/sites/default/files/sleeping-cats.jpg (Sleeping cats)
[3]: https://creativecommons.org/licenses/by-sa/4.0/
[4]: https://opensource.com/article/20/11/macports
[5]: https://opensource.com/article/20/6/homebrew-mac
[6]: https://opensource.com/article/20/3/chocolatey

View File

@ -0,0 +1,81 @@
[#]: subject: "Resize an image from the Linux terminal"
[#]: via: "https://opensource.com/article/21/9/resize-image-linux"
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
[#]: collector: "lujun9972"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
从 Linux 终端调整图像的大小
======
用 ImageMagick 的转换命令从你的终端收缩一张图像。
![Old camera blue][1]
ImageMagick 是一个方便的多用途命令行工具它能满足你所有的图像需求。ImageMagick 支持各种图像类型,包括 JPG 照片和 PNG 图形。
### 调整图像大小
我经常在我的网络服务器上使用 ImageMagick 来调整图像大小。例如,假设我想在我的个人网站上发一张我的猫的照片。我手机里的照片非常大,大约 4000x3000 像素,有 3.3MB。这对一个网页来说太大了。我使用 ImageMagick 转换工具来改变照片的大小这样我就可以把它放在我的网页上。ImageMagick 是一套完整的工具,其中最常用的是 `convert` 命令。
ImageMagick 的 `convert` 命令使用这样的一般语法:
```
`convert {input} {actions} {output}`
```
要将一张名为 `PXL_20210413_015045733.jpg` 的照片调整到一个更容易管理的 500 像素宽度,请输入:
```
`$ convert PXL_20210413_015045733.jpg -resize 500x sleeping-cats.jpg`
```
现在新图片的大小只有 65KB。
![Sleeping cats][2]
Jim Hall[CC BY-SA 4.0][3]
你可以用 `-resize` 选项同时提供宽度和高度尺寸。但是如果只提供宽度ImageMagic 就会为你做计算,并通过调整输出图像的高度比例来自动保留长宽比。
### 在 Linux 上安装 ImageMagick
在 Linux 上,你可以使用你的包管理器安装 ImageMagick。例如在 Fedora 或类似系统上:
```
`$ sudo dnf install imagemagick`
```
在 Debian 和类似系统上:
```
`$ sudo apt install imagemagick`
```
在 macOS 上,使用 [MacPorts][4] 或 [Homebrew][5]。
在 Windows 上,使用 [Chocolatey][6]。
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/9/resize-image-linux
作者:[Jim Hall][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/jim-hall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-blue.png?itok=AsIMZ9ga (Old camera blue)
[2]: https://opensource.com/sites/default/files/sleeping-cats.jpg (Sleeping cats)
[3]: https://creativecommons.org/licenses/by-sa/4.0/
[4]: https://opensource.com/article/20/11/macports
[5]: https://opensource.com/article/20/6/homebrew-mac
[6]: https://opensource.com/article/20/3/chocolatey