If you frequently work with scanned documents, PDFs, or JPEGs, file size and readability can be a challenge. ImageMagick is a powerful, free tool that allows you to resize, compress, and optimize images locally on Windows. With just a few commands, you can prepare your scans for applications, upload portals, or digital archiving.

Backup Your Originals
⚠️ Warning: Always make a copy of your files before batch processing. Files will be overwritten during batch processing.
Example in PowerShell:
Copy-Item "C:\Users\Max.Mustermann\Documents\Scans" "C:\Users\Max.Mustermann\Documents\Scans_backup" -Recurse
This ensures your original scans are safe in case you need them later.
Installing ImageMagick
The simplest way to install ImageMagick on Windows is via winget in context of administration account:
winget install ImageMagick.ImageMagick
After installation, open a new PowerShell and verify:
magick -version
You’re ready to start optimizing your images.
Recommended Settings for Document Images
When working with PDF files, it is often necessary to reduce their size as much as possible without losing important visual quality. Smaller PDFs are easier to store, easier to share, and faster to process. The following examples focus on generating compact PDFs by adjusting resolution, reducing image data, and optimizing compression parameters. These approaches help keep PDF files lightweight while still preserving a usable output.
For A4 scans or document images, the following settings generally provide a good balance between quality and file size:
- Format: JPEG
- Resolution: 150 dpi
- Dimensions: 1240 × 1754 px
- Quality: 80 percent
- Offline processing, local on your machine
These settings ensure that your text remains sharp while keeping file sizes small enough for web uploads or document management systems.
Converting and Optimizing JPEGs
If you have a folder full of JPEG scans, you can process them all at once with ImageMagick. In PowerShell, navigate to the folder and run:
magick mogrify -resize 1240x1754 -density 150 -quality 80 *.jpg
This command will:
- Resize all JPEGs to A4 dimensions
- Set the resolution to 150 dpi
- Apply JPEG compression at 80% quality
- Overwrite the originals (so make a backup if needed)
Converting PDFs to JPEGs
To use this script, Ghostscript must be installed on your system. You can download it from the official website https://www.ghostscript.com or follow the installation instructions in my Chocolatey guide. When processing PDFs, note that if a PDF contains multiple pages, the script will generate multiple JPEG files, each with a numbered suffix (e.g., _page_001.jpg, _page_002.jpg, etc.). It works best with PDFs that are already in A4 format; other page sizes may be cropped, and in those cases the resolution and page size settings (-g) should be adjusted.
foreach ($file in Get-ChildItem *.pdf) {
& "C:\Program Files\gs\gs10.06.0\bin\gswin64.exe" `
-dSAFER -dBATCH -dNOPAUSE `
-sDEVICE=jpeg -r150 -dJPEGQ=80 `
-g1240x1754 `
-sOutputFile="$($file.BaseName)_page_%03d.jpg" `
$file.FullName
}
- Each PDF becomes one JPEG
- Output filename matches the PDF, just with a
.jpgextension - Original PDFs are left intact
Optional Enhancements
ImageMagick offers extra options to improve the visual quality of scanned documents:
-normalize→ adjusts the image levels to make whites cleaner and contrasts sharper-despeckle→ removes small speckles or scan artifacts for a cleaner appearance
Conclusion
ImageMagick makes batch resizing and optimization of scanned documents easy, fast, and fully offline. With a few simple commands, you can prepare JPEGs and PDFs for any application, keeping file sizes small while maintaining readability. Optional enhancements like -normalize and -despeckle allow further refinement of your scans without complex editing software.