DEV Community

jgngo
jgngo

Posted on

Imagemagick

Installation

https://imagemagick.org/script/download.php#windows

1. Converting all files to jpg

In a folder, convert all png, webp, gif files to jpg.

magick mogrify -format jpg *.png
magick mogrify -format jpg *.webp
magick mogrify -format jpg *.gif
Enter fullscreen mode Exit fullscreen mode

2. File renaming

In Powershell, this will rename all jpeg to jpg.

dir *.jpeg | rename-item -newname { [io.path]::ChangeExtension($_.name, "jpg") }
Enter fullscreen mode Exit fullscreen mode

3. Resizing all jpg files

This command "Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s)."

magick mogrify -resize '720x720>' *.jpg
Enter fullscreen mode Exit fullscreen mode

4. Optimize image size

This command will optimize all jpg images to Google Pagespeed recommendations.

magick mogrify -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB *.jpg
Enter fullscreen mode Exit fullscreen mode

Others

These are other commands that may be useful.

magick mogrify -resize 960x528 *.jpg
Enter fullscreen mode Exit fullscreen mode

This command resizes all of the .jpg files in your directory to a size of 960 pixels by 528 pixels. Perhaps the height isn’t as important as the width. You can simply enter:

magick mogrify -resize 960 *.jpg
Enter fullscreen mode Exit fullscreen mode

This will scale all of your images to a width of 960 pixels, the height will be scaled accordingly, preserving the aspect ratio.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay