also, it is time to vacuum my desk again
Use file
for everyday summaries. Use ExifTool when you need to know everything.
The problem
I am once again puttering around with my site.
I have an image here.
I lived in this basement a few years ago
Do I need to resize it? Should find out how big it is first.
No I don’t mean file size. I mean geometry. How many pixels wide, and how many high? exa is nifty though. You should try it out.
I don’t want to leave my shell session to do it either. Sure that’s just stubbornness on my part. I could get the necessary information from my desktop’s file browser, but I type quicker than I click.
file
is everywhere
file
is a standard utility, which means it’s available on pretty much any Unix or Unix-like system you use. It works by matching a file’s internal details to entries in a magic
database and reporting its findings. magic
can be extended, though the details are beyond me for now.
basement-original.jpg
is a jpeg image. Yep, that checks out. Let’s see — 800x487. That looks like a geometry value. 800 pixels wide and 487 pixels high, if I remember the order right.
I want more detail, but this is all I can get from file
. That’s what ExifTool is for.
ExifTool knows everything
ExifTool lets me read and edit metadata for images, music, PDF, Word files, videos — a dizzying assortment of files are supported.
You can install ExifTool with the downloads listed on its site or using your favorite package manager.
Default usage returns every bit of information ExifTool thinks is relevant for the file type.
800 pixels wide, 487 pixels high. I remembered correctly! While I’m here, let’s look at ways to fine-tune the output.
We could cut down on the noise by specifying the fields or tags we want to see.
We could use -S
for more compact output focused less on tabular layout.
We could tell ExifTool to format its report for processing by CSV or JSON tools.
Hang on. I feel compelled to be a bit fancy.
Piping to xsv for aggregate information about site images.
Hm. I must have some icon files in there somewhere.
For more fun, point it at some music files. Heck, it will try to give useful information for text!
Here’s the file
output in comparison.
I could probably write some magic
configuration to get more information. But installing ExifTool was easier.
Good enough?
file
is universally available and gave me the details I needed today. ExifTool gives me everything I needed and then some. I’ll most likely keep it available on my systems.
And no, I’m not going to worry about resizing that image for now.
Got a comment? A question? More of a comment than a question?
Talk to me about this page on: mastodon
Added to vault 2024-01-15. Updated on 2024-02-02