Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7490845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:46:36+00:00 2026-05-29T15:46:36+00:00

with identify command I get some info about images and it looks like this

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:46:37+00:00Added an answer on May 29, 2026 at 3:46 pm

    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 format switch for identify:

    identify -format '%w' filename.jpg
    3360
    identify -format '%h' filename.jpg
    1080
    

    In bash, you’d write:

    W=`identify -format '%w' filename.jpg`
    H=`identify -format '%h' filename.jpg`
    

    The +0+0 is the offset for the image, +0+0 just means start at 0 on the x axis, and 0 on the y axis. 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:

    read w h < <(identify -format "%w %h" filename.jpg)
    

    along with anything else, such as the colorspace and number of unique colours:

    read w h c u < <(identify -format "%w %h %[colorspace] %k" filename.jpg)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the command line equivalent of identify image.png to work in
How to identify the file has been created completely in c#.. Which command do
Can someone help me identify what the purpose of this unidentified syntax is. It
We need to identify and then process switch/case statements in code based on some
Is there a command to identify the name/type of current shell, the path to
I think this must be easy but I do not get it. Assume I
This is related to: Converting PDF to CMYK (with identify recognizing CMYK). Script (or
I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page,
I'm looking for a Git alternatives to svn info. Today I added some information
I'd like to get a full inventory of files in a workspace (roughly similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.