Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Convert Images Using Terminal on macOS

Image conversion is a common task that can be necessary for various reasons, such as optimizing images for web use, converting formats for compatibility, or simply resizing for different devices. On macOS, this can be efficiently achieved using built-in tools via the Terminal. This article will guide you through the process of converting images using the sips and imagemagick commands, which are powerful utilities available on macOS.

Examples:

Using sips (Scriptable Image Processing System)

The sips command is a built-in tool on macOS that allows you to perform basic image manipulations directly from the Terminal.

Converting an Image Format

To convert an image from PNG to JPEG:

sips -s format jpeg input.png --out output.jpg

Resizing an Image

To resize an image to a width of 800 pixels while maintaining the aspect ratio:

sips -Z 800 input.jpg --out output_resized.jpg

Using ImageMagick

ImageMagick is a more advanced tool that can handle a wide range of image processing tasks. It is not installed by default on macOS, but it can be easily installed using Homebrew.

Installing ImageMagick

First, install Homebrew if you haven't already:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then, install ImageMagick:

brew install imagemagick

Converting an Image Format

To convert an image from PNG to JPEG using ImageMagick:

convert input.png output.jpg

Resizing an Image

To resize an image to a width of 800 pixels while maintaining the aspect ratio:

convert input.jpg -resize 800x output_resized.jpg

Batch Conversion

To convert all PNG files in a directory to JPEG:

mogrify -format jpg *.png

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.