[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Get the actual width/height of an image
From: |
Emanuel Berg |
Subject: |
Re: Get the actual width/height of an image |
Date: |
Mon, 14 Sep 2020 22:52:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Yuan Fu wrote:
> There doesn’t seem to be a function to get the
> aspect ratio of the image, or the actual pixel
> height/width of the image. So can I get
> this information?
For everything batch and graphics, use ImageMagick.
For the specific problem, you can use the command
identify(1) which is part of ImageMagick.
$ identify zhanna-friske.png
zhanna-friske.png PNG 1280x720 1280x720+0+0 8-bit sRGB 835952B 0.000u 0:00.000
You can then parse the output to answer an even more
specific question, e.g. what the height is:
#! /bin/zsh
pic-height () {
local img=$1
identify $img | awk '{print $3}' | cut -d 'x' -f 2
}
$ pic-height zhanna-friske.png
720
https://dataswamp.org/~incal/conf/.zsh/gfx
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal