1. Install ImageMagick on Windows 11
ImageMagick is a safe, widely used program that can edit images from the command line and from scripts.
1.1 Download ImageMagick
- Open your web browser (Edge, Chrome, whatever you use).
- In the address bar at the top, type:
https://imagemagick.org/script/download.php
and press Enter. - Scroll down until you see a section for Windows Binary Release.
- Look for something like:
ImageMagick-7.x.x-Q16-HDRI-win64-dll.exe(exact version may differ)
This version is the 64-bit installer for Windows. ImageMagick runs on x86 , x64 & arm64) or newer.
- Click that file to download it.
The browser will put it in your Downloads folder by default.
1.2 Run the installer
- Open File Explorer:
- Press
Windows key + E
or click the yellow folder icon on your taskbar.
- Press
- On the left side, click Downloads.
- Find the file that starts with
ImageMagick-7...and ends with.exe. - Double click it.
- If Windows asks “Do you want to allow this app to make changes?”, click Yes.
1.3 Important installer options
During installation, you will see some checkboxes. Look carefully for these and make sure they are checked:
- ✅ Add application directory to your system PATH
- ✅ Install legacy utilities (e.g. convert) (if you see this option)
If there are other options, you can leave them as default.
Click Next until it installs, then click Finish.
1.4 Check that ImageMagick is installed
- Press
Windows key + Ron your keyboard. - In the Run box, type:
cmd
and press Enter. This opens a black window called Command Prompt. - Copy the text:
magick -version - Then, in the Command Prompt, right click to paste (or ctrl+v)
- Press Enter.
If everything is correct, you should see some text with ImageMagick and version info.
If you see something like 'magick' is not recognized, then:
- Close that Command Prompt
- Restart your computer
- Try the same test again
Once magick -version works, you are ready for the next step.
2. Create the drag and drop script
We will create a small file called doc_clean.bat. When you drag images onto it, it will:
- Rotate them the right way (if your phone stored them sideways)
- Try to straighten slightly tilted pages
- Crop away extra background
- Adjust brightness and contrast so text is clearer
- Sharpen the text a bit
- Save a JPEG copy in the same folder with
_cleanedadded to the name
2.1 Make sure file extensions are visible
This step makes sure Windows shows .bat, .jpg, .png, etc.
- Open File Explorer.
- At the top, click the View menu.
- Hover over Show.
- Make sure File name extensions is checked.
- If it is not checked, click it to turn it on.
Now you will see extensions like .txt, .jpg, .png, .bat at the end of file names.
2.2 Open Notepad
- Click the Start button (Windows icon).
- Type
Notepad. - Click on Notepad to open it.
2.3 Paste the script
Copy all the text below, exactly as it is, then paste it into Notepad:
@echo off
:: doc_clean.bat
:: Drag one or more images onto this file to process them.
for %%F in (%*) do (
echo Processing: %%~fF
magick "%%~fF" ^
-auto-orient ^
-deskew 40%% ^
-trim +repage ^
-resize 2500x2500^> ^
-brightness-contrast 10x20 ^
-level 5%%,95%% ^
-sharpen 0x1.0 ^
-colorspace sRGB ^
-quality 90 ^
"%%~dpnF_cleaned.jpg"
)
echo Done.
pause
Important:
- Do not change anything inside this block unless you know why.
- The
^symbols at the ends of lines and the%%signs are important.
2.4 Save the file as a .bat script
- In Notepad, click File at the top left.
- Click Save As.
- Choose a location you can easily reach, for example: Desktop.
- At the bottom, there are two important boxes:
- File name: type
doc_clean.bat - Save as type: click the dropdown and choose All Files (.)
(Do not leave it as “Text Documents (*.txt)”)
- File name: type
- Click Save.
On your Desktop, you should now see a file named:
doc_clean.bat
If you see doc_clean.bat.txt, that means Windows still saved it as a text file. In that case:
- Right click the file.
- Click Rename.
- Delete the
.txtfrom the end, so it ends with.bat. - If Windows warns you about changing the extension, click Yes.
3. Test the script with one image
Let us test it with a single image first.
- Pick any folder where you have an image of a document. For example:
Pictures\Scansor wherever your photos are. - Make sure the image is something like
.jpgor.png.
Example:invoice_01.jpg.
Now:
- Arrange your windows so you can see:
- The folder with your image
- Your Desktop with
doc_clean.bat
- Click and hold on the image file.
Drag it on top ofdoc_clean.bat.
Release the mouse button when you are on top ofdoc_clean.bat.
You should see a black Command Prompt window pop up and show something like:
Processing: D:\Scans\invoice_01.jpg
...
Done.
Press any key to continue . . .
Press any key to close that window.
Now go back to the folder with your image. You should see a new file:
- Original:
invoice_01.jpg - New:
invoice_01_cleaned.jpg
Open the _cleaned version and check:
- It should be tighter around the document, less extra background.
- It should be brighter with more contrast.
- Text should look a bit sharper.
- It will always be a JPEG file.
4. Process several images at once
You can drag multiple images at the same time.
- Go to the folder with your images.
- Select several files:
- Click the first one, then hold
Ctrland click others,
or - Click one, then press
Ctrl + Ato select all in that folder.
- Click the first one, then hold
- With the group of images selected, click and drag them onto
doc_clean.bat.
The black window will list each file as it works. When it says Done, press any key to close it.
Every original file like:
scan_001.png
scan_002.jpg
scan_003.heic
will get a processed version in the same folder:
scan_001_cleaned.jpg
scan_002_cleaned.jpg
scan_003_cleaned.jpg
The originals are not deleted or changed.
5. How to add this into your routine
A simple way to work:
- Take photos of your documents with your phone.
- Transfer them to a folder on your PC, for example:
C:\Users\YourName\Pictures\DocsToProcess - Once they are in that folder:
- Select them all
- Drag them onto
doc_clean.baton your Desktop
- Use only the
_cleanedversions from now on.
If you like, you can later move doc_clean.bat to another location and create a shortcut, but leaving it on the Desktop is perfectly fine.
6. Optional tweaks (only if you want to adjust the look)
These changes are optional and only if you feel the images look too strong or too weak.
Open doc_clean.bat by:
- Right click
doc_clean.bat. - Click Edit. That will open it in Notepad.
You can change these parts inside the magick command:
-brightness-contrast 10x20- First number = brightness
- Second number = contrast
- If the image is too bright or too harsh, try
5x15or0x15.
-level 5%,95%- This pushes dark things darker and light things lighter.
- If text looks too blown out, try
10%,90%.
-sharpen 0x1.0- This sharpens the image.
- If it looks too crunchy, try
0x0.7or remove that line.
After any change, click File → Save in Notepad.
7. Common problems and fixes
Problem: When I drag an image onto doc_clean.bat, nothing happens.
Possible fixes:
- Make sure ImageMagick is installed and
magick -versionworks in Command Prompt. - Make sure the script really ends in
.batand not.bat.txt. - Make sure the line that starts with
magickis exactly as I gave it, including the^symbols at the ends of lines.
Problem: The window opens and immediately closes before I can read anything.
- This usually means there was an error, but it closed too fast.
- To see the message:
- Right click
doc_clean.bat. - Click Edit.
- At the very bottom, make sure the last line is:
pause
- Right click



