Minimalist command-line image viewer
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:
[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:
- Attachments
-
- simv3.zip
- Third and final (?) version
- (5.95 KiB) Downloaded 239 times
Last edited by 6502coder on Mon 22 Dec 2014, 04:07, edited 2 times in total.
-
- Posts: 902
- Joined: Mon 22 Jun 2009, 01:36
- Location: Philadelphia, PA
Re: Minimalist command-line image viewer
Much snipped.
puts it in about the middle of the 14" screen on this Dell Latitude E6410, Lucid Puppy 5.2.8.7
Yep, works fine, thank you!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.
Code: Select all
simv /usr/share/pixmaps/FBReader.png 600 400
Dell E6410: BusterPup, BionicPup64, Xenial, etc
Intel DQ35JOE, Dell Vostro 430
Dell Inspiron, Acer Aspire One, EeePC 1018P
Intel DQ35JOE, Dell Vostro 430
Dell Inspiron, Acer Aspire One, EeePC 1018P
- Dingo
- Posts: 1437
- Joined: Tue 11 Dec 2007, 17:48
- Location: somewhere at the end of rainbow...
- Contact:
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
dropbox 2GB free
OpenOffice for Puppy Linux
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.
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.
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
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).
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: Select all
#!/bin/sh
gtkdialog -s <<< '
<window decorated="false">
<pixmap><input file>'"$1"'</input></pixmap>
</window>'
- Attachments
-
- miniviewers.png
- (32.68 KiB) Downloaded 345 times
Last edited by MochiMoppel on Mon 22 Dec 2014, 11:58, edited 1 time in total.
I was just looking for the same thing myself and found it!MochiMoppel wrote:If anyone knows how to get rid of the border I would be grateful for a hint.
It's: <window margin="0" ... >
[src]
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
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
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: Select all
#!/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
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
A little cleaner:
Code: Select all
case $EXT in
jpg|png|... ) actions ;;
esac
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Hi, I'm whomever and I would love to subtract from itGeoffrey wrote:Passing it on to whomever wants to add to it.
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: Select all
#!/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
Shows the image as a icon on the taskbar, though it does throw a warning in terminal.MochiMoppel wrote:What does image-name="'$1'" do?
Code: Select all
(gtkdialog:30447): Gdk-WARNING **: gdk_window_set_icon_list: icons too large
Code: Select all
<window skip-taskbar-hint="true" margin="0" decorated="false">
Yeah my bad.<action> not needed here if you want the button to close the window
Code: Select all
[ "`file -ib "$1" | grep '^image'`" ]
pcx are "application/octet-stream; charset=binary"
xpm "text/x-c; charset=us-ascii"
Code: Select all
[ "`file -ib "$1" | grep '^image\|octet-stream\|x-c;'`" ]
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Doesn't work for meGeoffrey wrote:Shows the image as a icon on the taskbar, though it does throw a warning in terminalMochiMoppel wrote:What does image-name="'$1'" do?
Haven't seen a pcx for years and my browser doesn't support them. Downloaded a sample and it worked with the script. Mime type is image/x-pcx.That doesn't seem to work for all images,
pcx are "application/octet-stream; charset=binary"
xpm "text/x-c; charset=us-ascii"
It may not work for all image files, but let's be realistic: The script is a primitive personal tool. I don't expect it to cover much more than PNG,JPG,GIF...the ordinary stuff, and this it does well.