Is there any command to check compression type of a file.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
punith8626
Posts: 16
Joined: 2016-12-29T05:13:36-07:00
Authentication code: 1151

Is there any command to check compression type of a file.

Post by punith8626 »

Hello,

Is there any command to check compression type of a file.
I have some files that are corrupted and i need to use alternative for this.How can I check whether images is looking at it without using convert command ?

Example:
I have a files with old JPEG compression type and I am not able to convert those files,Hence I need to use other convertors based on Image corrupted or not.

Could you help me on this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there any command to check compression type of a file.

Post by fmw42 »

IM can tell you the compression type if it can read the file using identify -verbose yourimage. Somewhere listed there will be the compression. Current versions of IM can tell you that more directly from %[compression]. See http://www.imagemagick.org/script/escape.php

But if IM cannot read the file due to its having an old JPEG format that libjpeg does not support, then it won't be able to tell you the compression. Perhaps you can use EXIFTOOL to tell you that information.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Is there any command to check compression type of a file.

Post by GeeMack »

fmw42 wrote: 2017-01-11T12:02:32-07:00Current versions of IM can tell you that more directly from %[compression]. See http://www.imagemagick.org/script/escape.php
That is how it's described under "Long Form Attribute Percent Escapes" at THIS link, but I'm using IM 7.0.4-3 on Windows 10 64, and when I run this command...

Code: Select all

magick example.jpg -format "%[compression]" info:
... it produces this warning...

Code: Select all

magick: unknown image property "%[compression]" @ warning/property.c/InterpretImageProperties/3822.
This command will still output the compression type for me...

Code: Select all

magick example.jpg -format "%[C]" info:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there any command to check compression type of a file.

Post by fmw42 »

Works fine for me on (Mac OSX SnowLeopard) IM 6.9.7.3 but fails in IM 7.0.3.4. So it seems to be an issue of not getting folded over to IM 7 or being lost in some recent release.

IM 6

Code: Select all

convert logo.tif -format "%[compression]" info:
JPEG

IM 7

Code: Select all

magick logo.tif -format "%[compression]" info:
magick: unknown image property "%[compression]" @ warning/property.c/InterpretImageProperties/3822.
Post Reply