LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   viewing images in console?? (http://www.linuxquestions.org/questions/slackware-14/viewing-images-in-console-208051/)

marlor 07-21-2004 07:14 PM

viewing images in console??
 
hi people,

the topic is basically my question

is there a prog to view jpg, gif ... in console?

thanks in advance

Schrambo 07-21-2004 09:12 PM

Pretty much no. But if you can open an image up in another program though the CLI if your in a desktop enviroment like this

$ <name of program> image.jpg
example
$ kuickshow Screenshot.png

thats about it, sorry man.

bobtmasse 07-21-2004 11:11 PM

Try seejpeg. Works on more than JPEGs too:

gif, ppm, bmp, tga.

tank728 07-21-2004 11:45 PM

I think mplayer might be able to display images in console.

-tank

keefaz 07-22-2004 07:53 AM

Hello, I did program an image viewer utility in SDL as an exercice, it can display image in console (assuming framebuffer is set)
require :
SDL (provided by sdl official slackware package)
SDL_image (you can get it here : LinuxPackages

Save it as view_image.c
Compile it as :
gcc -o view_image view_image.c `sdl-config --libs` -lSDL_image
Code:

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <stdio.h>
#include <stdlib.h>

static SDL_Surface *screen;

void usage( void )
{
        printf("Usage: view_image image_file\n");
        printf("Display an image. Press <ESC> to exit\n");
}

int main(int argc, char * argv[])
{
        SDL_Surface *image;
    SDL_Rect dest;
        SDL_Event event;
        Uint8 *keys;

        char image_path[255];
        int image_type;
       
        if(argc == 1) {
                usage();
                exit(1);
        }
       
        strcpy(image_path, argv[1]);

        if(SDL_Init(SDL_INIT_VIDEO) != 0) {
                printf("can't init SDL video: %s\n", SDL_GetError());
                return 1;
        }

        atexit(SDL_Quit);

        screen = SDL_SetVideoMode(0, 0, 0, SDL_SWSURFACE);
       
    image = IMG_Load( image_path );
    if ( image == NULL ) {
        fprintf(stderr, "Couldn't load %s: %s\n",
                        image_path, SDL_GetError());
        return 0;
    }
       
        screen = SDL_SetVideoMode(image->w, image->h, 0, SDL_SWSURFACE );

    dest.x = 0;
    dest.y = 0;
    dest.w = image->w;
    dest.h = image->h;
    SDL_BlitSurface(image, NULL, screen, &dest);

    SDL_UpdateRects(screen, 1, &dest);
       
        while ( SDL_WaitEvent(&event) >= 0 ) {
                keys = SDL_GetKeyState(NULL);
                if (event.type == SDL_QUIT || keys[SDLK_ESCAPE] == SDL_PRESSED  ) {
                        SDL_FreeSurface(image);
                        exit(0);
                }
        }
        return 0;
}

So to view an image in console, just type : ./view_image <image_name>

seaelf 07-22-2004 05:59 PM

image viewer in console
 
Howdy... have you tried zgv?
good luck
Neil


All times are GMT -5. The time now is 07:19 AM.