Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Oct 2014, 20:41
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to find image width x length?
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message

Joined: 21 Dec 2008
Posts: 1798
Location: अनुमोदना

PostPosted: Today, at 07:10    Post_subject:  How to find image width x length?  

Dear puppians,

Is there a native puppy command to get an image size? Width x Length
Or if not native, can someone please lead me to it?

Thanks a lot

Note: the "file" command won't work with. Jppg

PET Maker|WbarCC
Back to top
View user's profile Send_private_message 

Joined: 26 Oct 2011
Posts: 1078

PostPosted: Today, at 08:44    Post_subject:  

For BMP, GIF, JPG, TGA & TIF you could use exiv2 binary. I think it's present in all of Pups.
As for some other formats, here's a snippet I made some time ago that might be helpful:

[ "$FILENAME" ] || exit 1

FILENAME_TEMP=`echo "$FILENAME" | tr '[:upper:]' '[:lower:]'`

case ${FILENAME_TEMP##*.} in
    read X Y <<< `exiv2 "$FILENAME" 2>/dev/null | awk '/Image size/ {print $4,$6}'`
    read X Y <<< `file -b "$FILENAME" | awk -F',' '{split($2,a,"x"); print a[1]" "a[2]}'`
    read X Y <<< `file -b "$FILENAME" | cut -d ']' -f2 | cut -d '[' -f2 | awk -F',' '{print $1+1,$2+1}'`
    read X Y <<< `grep -m1 "\"" "$FILENAME" | tr -d "\"" | awk '{print $1,$2}'`
    X=`cat "$FILENAME" | tr -d ' \t' | grep -m1 -io "width=".[0-9]* | tr -cd '[[:digit:]]'`
    Y=`cat "$FILENAME" | tr -d ' \t' | grep -m1 -io "height=".[0-9]* | tr -cd '[[:digit:]]'`     
    read X Y <<< `grep -v '#' "$FILENAME" | grep -a -m2 .[0-9] | tail -1 | awk '{print $1,$2}'`
  *) echo "Not supported..."; exit 1

echo "$FILENAME: ${X}x${Y}"

Doesn't work with certain .ico files, but otherwise it's quite reliable...


[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send_private_message 
Official Dog Handler

Joined: 04 May 2005
Posts: 11118
Location: Arizona USA

PostPosted: Today, at 09:58    Post_subject:  

mtPaint shows the image size, at the bottom left corner. Right-click on the file, then choose Open with -> mtPaint.
Back to top
View user's profile Send_private_message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 140

PostPosted: Today, at 12:07    Post_subject:  

From your browser (Firefox), right-click on the picture and choose the option about view image info or something like that. Gives you the original dimensions and also that if scaled.
I found your picture is 80px × 62px. See screen shot

B.K. Johnson
Reread your post and realized you were looking for a command. So my suggestion may not be what you want, however, I am leaving the reply in case someone else finds it useful.
 Description   Output- right-click > View image info of your pic.
 Filesize   63.06 KB
 Viewed   49 Time(s)


Back to top
View user's profile Send_private_message 
ASRI éducation

Joined: 09 May 2009
Posts: 2532
Location: France

PostPosted: Today, at 16:14    Post_subject: Re: How to find image width x length?  

trio wrote:
Is there a native puppy command to get an image size? Width x Length

Hello Flash and B.K. Johnson.
Trio is not a novice.
It is probable that he is trying to develop a script.
Graphical interfaces are not going to help ...

Projet ASRI éducation => Association | Forum | Dépôt | Espace kids
Back to top
View user's profile Send_private_message Visit_website 

Joined: 30 Nov 2008
Posts: 2684
Location: Montenegro

PostPosted: Today, at 16:52    Post_subject:  

Not sure about native puppy command, but exiv2 can get image size from exif (not that every image has exif saved though)
EDIT: Googled and found an answer on stackoverflow that says that exiv2 will display size even if exif isn't saved, and I just tested it, see second output for image with no exif.

13 root:960px$ data=$(exiv2 IMG_5834-960.JPG)
14 root:960px$ echo "$data" | grep "^Image size"
Image size      : 640 x 960

1 root:IMG$ exiv2 2rVyRKI.jpg
File name       : 2rVyRKI.jpg
File size       : 600887 Bytes
MIME type       : image/jpeg
Image size      : 2576 x 1719
2rVyRKI.jpg: No Exif data found in the file

It would be interesting to know though.
If you want to embed image into gtkdialog there are <width></width> and <height></height> tags that will scale image of any size to given values.


Back to top
View user's profile Send_private_message Visit_website MSNM 

Joined: 12 Oct 2012
Posts: 441
Location: The other Mr. 305

PostPosted: Today, at 20:22    Post_subject:  

See 2005 script posted by Tomchuk


I only tested it on one JPG but it seemed to work fine.

Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0755s ][ Queries: 12 (0.0114s) ][ GZIP on ]