Intro
I was applying for New Zealand visa and my photo got rejected for exceeding the max size AND not meeting the min resolution at the same time 😅. After spending more than 2 seconds trying to form a thought, I decided to just google my problem and hope someone already has.

My first thought was to look for something to strip metadata from the image files. I found most stackoverflow/blogs recommend using exiftool, but I felt reluctant to install a new tool just for this. A couple searches later, I found that imagemagick can do the job. Thats good because I happen to have it installed from a past project.
Anyway here’s how I did it:
Enough talk, show me the code
Okay that should be enough words for SEO, here’s the code:
Setup
First you obviously need to have imagemagick installed, if you’re on a mac you can install it using brew:
brew install imagemagick
What you came here for
Then you can use the mogrify
command to strip metadata from the image files.:
mogrify -strip *.png
# Example output:# input.png PNG 995x956 995x956+0+0 8-bit TrueColorAlpha sRGB 938272B 0.040u 0:00.028# input.png PNG 995x956 995x956+0+0 8-bit TrueColorAlpha sRGB 938272B 0.160u 0:00.159
Don’t worry about the .png
this will work on file format as well.
This command will strip any profiles, comments, or these PNG chunks: (bKGD, cHRM, EXIF, gAMA, iCCP, iTXt, sRGB, tEXt, zCCP, zTXt, date) from the image files.
You can also use the -verbose
flag to see what is being stripped:
Some tips
mogrify -strip -verbose *.png
You can also use the -format
flag to convert the images to a different format, for example to convert all the images to webp:
mogrify -strip -format webp *.png
What if I want to keep the original files?
There’s also the convert
command to save the output in a different name:
convert input.png -strip output.png
Likewise it has both -verbose
and format
flags as well:
convert input.png -strip -verbose output.pngconvert input.png -strip -format webp output.webp
How do I check if the metadata has been stripped?
You can use the identify
command to check if the metadata has been stripped from the image files:
identify -verbose input.png
You should see that the metadata has been stripped from the image files, here’s an example:
Goodbye
That’s all! I hope this helps you strip metadata from image files using imagemagick. Oh and wish me luck on my visa application 🇳🇿.