with identify command I get some info about images and it looks like this
my_image.png PNG 154×78 154×78+0+0 8-bit DirectClass 946B 0.000u
0:00.000
the image size it is 154×78
but I do not know how to put this values in variables
w=154 #But I want this 154 to be somehow parsed...
h=78
Note this script for parsing should work for all kind of images not just for the .png extension
also if possible I want to know what is the 0+0 in this line 154×78+0+0
Thanks
This is a difficult case to write a regex for, since we don’t know if the file name will contain spaces or have an extension or not. Easier would be to use the
formatswitch foridentify:In bash, you’d write:
The
+0+0is the offset for the image,+0+0just means start at0on thexaxis, and0on theyaxis. You can read more in the imagemagick manual.Edited by Mark Setchell
The foregoing answer is perfectly good, and I didn’t want to add a competing answer, just a clarification, or minor improvement, that is too big for a comment…
As the OP is using
bash, he can get both the width and height in one go, without opening the image multiple times, like this:along with anything else, such as the colorspace and number of unique colours: