Search code examples
imagemagickgraphicsmagick

Converting images to a specific JPG quality


I want to convert image formats to JPG in a specific quality

The following command doesn't work for some reason , all i get is NULL

gm convert -quality 80 '/tmp/phpK31vNK' JPEG:'/tmp/phpK31vNK' && cat '/tmp/phpK31vNK'

However the following command works fine but graphicsmagick set the default quality which is 75

gm convert '/tmp/phpK31vNK' JPEG:'/tmp/phpK31vNK' && cat '/tmp/phpK31vNK'


Solution

  • Try:

    gm convert image1 -quality 60 JPEG:image2
    

    But if image1 is always a jpeg you can skip the JPEG: specification:

    gm convert image1 -quality 60 image2