InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

ImageMagick tutorials

  • Install Imagemagick on Mac
  • Install Imagemagick on Ubuntu
  • Create animated gif using Mac preview
  • Create animated gif on command line
  • Edit animated gif speed
  • Find image width and ppi
  • Find image unique colors and bit depth
  • Resize image dimention
  • Compress images
  • Crop image
 
  • Home
  • > Tutorials
  • > Linux/Unix Command Line
  • > ImageMagick

How to compress screenshot images using imagemagick convert

By admin on Dec 4, 2015

Imagemagick convert can be used to compress and screenshot images by changing unique colors, image depth etc. Here are some ways to compress images created by taking screenshots on Mac. We’ll use the following image (img1.png) created using screen capture on Mac.
convert-compress-sample-image

convert – compress by reducing colors

Reduce colors to 256

$ convert img1.png +dither -colors 256 img2.png
$ stat -f "%N: %z bytes" img1.png  img2.png
img1.png: 47628 bytes
img2.png: 17881 bytes

Here is the output image (img2.png)
convert-compress-img2

Reduce colors to 128

$ convert img1.png +dither -colors 128 img3.png
$ stat -f "%N: %z bytes" img1.png  img3.png
img1.png: 47628 bytes
img2.png: 16231 bytes

Here is the output image (img3.png)
convert-compress-img3

convert – compress by reducing colors and depth

Reduce colors to 256 and depth to 8

$ convert img1.png +dither -colors 256 -depth 8 img4.png
$ stat -f "%N: %z bytes" img1.png  img4.png
img1.png: 47628 bytes
img2.png: 17382 bytes

Here is the output image (img4convert-compress-img4.png)

Final notes

Imagemagick convert with options +dither -colors 256 seems to be working well in most cases. It may be a good idea to keep this as your default. If you need higher compression in specific cases, you may want to explore multiple values of these options.

Suggested posts:

  1. How to check if a user has password on Linux
  2. Get image width and ppi using imagemagick identify on command line
  3. WordPress mysql query to get all custom keys and values for a post
  4. Bash check if file begins with a string
  5. How to create animated gif using Mac preview
  6. How to edit animated gif speed (FPS) using imagemagick convert
  7. Mac brew – how to relink installed binaries for a package
  8. Find used ports by an app on Android using Adb
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged ImageMagick, Linux, Linux/Unix Command Line, Mac, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress