Adding filesize to label?

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
jessicaC
Posts: 6
Joined: 2017-11-04T04:03:17-07:00
Authentication code: 1152

Adding filesize to label?

Post by jessicaC »

Hi everyone!

Is there a shortkey for filesize in imagemagic?

I currently add dimensions and filename for my label via the below code. But I'd also like to add filesize, if possible

Code: Select all

convert filename -set option:mylabel "%wx%h\n%f"...
I know it's possible with %b, but this way I get bytes. Any way to display size in MBs?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Adding filesize to label?

Post by snibgo »

IM will display the size in MB, if the file is large enough.

Code: Select all

f:\prose\PICTURES>%IM%convert toes.png -format %[size] info:
320KB

f:\prose\PICTURES>%IM%convert toes.png -format %b info:
320KB

f:\prose\PICTURES>%IM%convert AGA_1434_gms.tiff -format %b info:
174.1MB
snibgo's IM pages: im.snibgo.com
Post Reply