Home > Mobile >  cwebp, imagemagick and graphicsmagick converting to webp with rotation
cwebp, imagemagick and graphicsmagick converting to webp with rotation

Time:12-18

I have been converting images from jpg/ png to webp using libwebp library on Ubuntu using cwebp command, all is working fine until some images (may be in portrait format) are getting rotated by the conversion.

so, I tried using imagemgick and graphicmagick but both are doing the same thing as cwebp as internally for webp conversion both the tools are dependent on the same library.

I tried adding cli options as below but none of them is working.

cwebp -q 80 -metadata all inputfile -o outputfile

Seems like conversion is not able to preserve the headers, please suggest some workaround.

CodePudding user response:

JPG images have a flag in their header to specify how the image was taken by the camera. It specifies the rotation orientation of the camera. In Imagemagick you can use -auto-orient to properly correct the rotation according to the header flag in the EXIF data.

convert image.jpg -auto-orient rotated_image.jpg
  • Related