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 Sun 05 Jul 2015, 19:36
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Graphics
Minimalist command-line image viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [18 Posts]   Goto page: 1, 2 Next
Author Message
6502coder

Joined: 23 Mar 2009
Posts: 149
Location: Western United States

PostPosted: Sun 21 Dec 2014, 17:47    Post subject:  Minimalist command-line image viewer  

Here's a tiny command-line program to display an image on the screen. The man page pretty much says it all:

[NOTE: this is out of date. The zip file has the latest man page]

NAME
simv - simple image viewer

SYNOPSIS
simv [filename [x-coord y-coord]]

DESCRIPTION
simv is a minimalist Gtk image viewer. It displays images and that's all -- no zooming, no scrolling, no resizing, no editing.

simv will attempt to open the named image file, and if successful it will render the image on the screen. The image is rendered without window ornamentation of any kind. You may specify the placement of the image by passing the optional x- and y-coordinates. (Keep in mind that your window manager may choose not to honor your request.)

Clicking anywhere on the image will close simv.

If the filename is "-" or begins with "-", the usage syntax is printed to stderr.

When called with no arguments, simv opens as a barebones GUI application.

NOTES
simv was created to address a need to be able to throw a "windowless" image up on the screen from a shell script. The GUI mode is merely a legacy from the original source code from which simv was adapted.

simv was compiled on Puppy 4.1.2 Retro and should work on pretty much any Puppy.

Zip file with the executable and man page:
simv3.zip
Description  Third and final (?) version
zip

 Download 
Filename  simv3.zip 
Filesize  5.95 KB 
Downloaded  85 Time(s) 

Last edited by 6502coder on Mon 22 Dec 2014, 00:07; edited 2 times in total
Back to top
View user's profile Send private message 
sheldonisaac

Joined: 21 Jun 2009
Posts: 495
Location: Philadelphia, PA

PostPosted: Sun 21 Dec 2014, 18:58    Post subject: Re: Minimalist command-line image viewer  

Much snipped.
6502coder wrote:
Here's a tiny command-line program to display an image on the screen. The man page pretty much says it all:

simv [filename [x-coord y-coord]]
Clicking anywhere on the image will close simv.

Yep, works fine, thank you!

Code:
simv /usr/share/pixmaps/FBReader.png 600 400

puts it in about the middle of the 14" screen on this Dell Latitude E6410, Lucid Puppy 5.2.8.7

_________________
Dell E6410: LuPu Super 2 & various Puppys;Dell D610: Windows XP, Puppy Linux 5.2, 'lina-lite;
Intel D865GBF: Windows XP, Puppy Linux 5.2;
Acer Aspire One: Windows XP, Puppy Linux 5.2; ASUS P5A: MS-Windows 98SE, Puppy Linux 2.14X
Back to top
View user's profile Send private message 
anikin

Joined: 10 May 2012
Posts: 656

PostPosted: Sun 21 Dec 2014, 19:07    Post subject:  

Works fine on DebianDog, thank you!
Last edited by anikin on Mon 22 Dec 2014, 23:52; edited 1 time in total
Back to top
View user's profile Send private message 
Dingo


Joined: 11 Dec 2007
Posts: 1426
Location: somewhere at the end of rainbow...

PostPosted: Sun 21 Dec 2014, 19:08    Post subject:  

where download the source code?
_________________
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux
Back to top
View user's profile Send private message Visit poster's website 
6502coder

Joined: 23 Mar 2009
Posts: 149
Location: Western United States

PostPosted: Sun 21 Dec 2014, 20:31    Post subject:  

@sheldonisaac

My bad. New version (2) uploaded, this should respect the x-y coords correctly.
Back to top
View user's profile Send private message 
6502coder

Joined: 23 Mar 2009
Posts: 149
Location: Western United States

PostPosted: Mon 22 Dec 2014, 00:09    Post subject:  

I have posted a 3rd (and final) version of simv, to address the following issue, which pertains only to the behavior of simv when you pass it a filename argument.

By default the image is rendered in a standard Gtk window, and therefore the window's placement is ultimately determined by the window manager. Even if you supply the optional x-y coords, these are only hints to the window manager. In practice, if the image is small enough to fit entirely on the screen at the specified position, the window manager will honor the request. But if the image is too large to fit entirely on the screen, then all bets are off, and it is up to the window manager to decide where to place the window.

On the other hand, window managers do not control the placement of Gtk "pop-up" windows. If you supply the x-y coords, these will be honored, even if the image will not fit entirely on the screen at the specified position. However, a pop-up window stays on top of all other windows. This may not be what you want.

So simv now has a "-p" option. This will cause the image to be rendered in a pop-up window instead of a regular window, with the pros and cons I have spelled out above.

Having exhausted my limited knowledge of Gtk, I should leave it to smarter folks to tinker with any further improvements! The source code is included in the zip file.
Back to top
View user's profile Send private message 
slavvo67

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

PostPosted: Mon 22 Dec 2014, 01:04    Post subject:  

Do you know what / how many formats this handles?

Thanks,

Slavvo67
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 713
Location: Japan

PostPosted: Mon 22 Dec 2014, 06:39    Post subject:  

It can get even tinier. Here is a minimalistic-as-can-be script I wrote a while ago.
Make a desktop icon linking to the script and drag&drop images on it
To move: Alt+drag mouse with left mouse button pressed
To close: Alt+F4
The only drawback: The small border around the image (see screenshot), no borders with simv. If anyone knows how to get rid of the border I would be grateful for a hint.
EDIT SFR solved the problem (see next post).
Code:
#!/bin/sh
gtkdialog -s <<< '
<window decorated="false">
<pixmap><input file>'"$1"'</input></pixmap>
</window>'
miniviewers.png
 Description   
 Filesize   32.68 KB
 Viewed   229 Time(s)

miniviewers.png


Last edited by MochiMoppel on Mon 22 Dec 2014, 07:58; edited 1 time in total
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1299

PostPosted: Mon 22 Dec 2014, 07:12    Post subject:  

MochiMoppel wrote:
If anyone knows how to get rid of the border I would be grateful for a hint.

I was just looking for the same thing myself and found it!
It's: <window margin="0" ... >
[src]

Greetings!

_________________
[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 
MochiMoppel


Joined: 26 Jan 2011
Posts: 713
Location: Japan

PostPosted: Mon 22 Dec 2014, 07:54    Post subject:  

SFR wrote:
It's: <window margin="0" ... >
[src]!

Great! Thank you!
I also like the linked specification: "Default value: 0" Laughing
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2380

PostPosted: Mon 22 Dec 2014, 08:39    Post subject:  

I wonder why you call it a command-line program, when it is obviously a graphical(X/GTK) program
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1794
Location: Queensland

PostPosted: Mon 22 Dec 2014, 11:41    Post subject:  

Slightly larger with more features.

Really needs to fit to screen if the image is larger than the screen res.

Passing it on to whomever wants to add to it.

Show image on a button, but it does have a border, click image to close, show icon preview and image name on taskbar.

Tested with these file types: png, jpg, bmp, gif, xpm, ppm, pgm, pbm, pnm, tga, pcx

Code:
#!/bin/sh
EXT="${1##*.}"
if [ "$EXT" = "png" ] || [ "$EXT" = "jpg" ] || [ "$EXT" = "bmp" ] \
|| [ "$EXT" = "gif" ] || [ "$EXT" = "xpm" ] || [ "$EXT" = "ppm" ] || [ "$EXT" = "pgm" ] \
|| [ "$EXT" = "pbm" ] || [ "$EXT" = "pnm" ] || [ "$EXT" = "tga" ] || [ "$EXT" = "pcx" ]; then
gtkdialog -s <<< '
<window title="'${1##*/}'" margin="0" decorated="false" image-name="'$1'">
<button>
<input file>"'$1'"</input>
</button>
<action type="exit">exit</action>
</window>'
else
echo "Usage: [File] png, jpg, bmp, gif, xpm, ppm, pgm, pbm, pnm, tga, pcx"; exit 0
fi

_________________
Carolina: Recent Repository Additions
Create strikethrough text HERE
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2380

PostPosted: Mon 22 Dec 2014, 14:39    Post subject:  

A little cleaner:
Code:
case $EXT in
  jpg|png|... ) actions ;;
esac
Back to top
View user's profile Send private message 
6502coder

Joined: 23 Mar 2009
Posts: 149
Location: Western United States

PostPosted: Mon 22 Dec 2014, 16:19    Post subject:  

MochiMoppel wrote:
It can get even tinier...


Nice! Good to know.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 713
Location: Japan

PostPosted: Mon 22 Dec 2014, 23:08    Post subject:  

Geoffrey wrote:
Passing it on to whomever wants to add to it.
Hi, I'm whomever and I would love to subtract from it Wink

I like the idea to sniff for image file type. If it's not an image file, my script would show an ugly default icon.
But checking extension is not reliable. Even with amigo's more elegant approach you can't catch all upper/lowercase variants, can't catch files with no extension at all and can't catch your brothers pr0n collection where nicepicXXX.jpg masquerades as nicepicXXX.txt. Therefore sniffing for the MIME type appears to me as a better approach.

What does image-name="'$1'" do?
<action> not needed here if you want the button to close the window

My stripped variant would look like this:
Code:
#!/bin/sh
if [ "`file -ib "$1" | grep '^image'`" ]; then
 gtkdialog -s <<< '
 <window title="'${1##*/}'" margin="0" decorated="false">
 <button> <input file>"'$1'"</input> </button>
 </window>'
fi
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [18 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Graphics
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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