WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Simple image viewer, which approach should I take?  (Read 7863 times)

Offline Chau

  • Newbie
  • *
  • Posts: 20
Simple image viewer, which approach should I take?
« on: December 13, 2017, 02:07:40 PM »
Hi guys

I am very new to the Tiny Core Linux distribution, but I really like the concepts with a small footprint and everything in RAM.

I have an old 1080p LCD monitor lying around and decided I would like to build a simple photo frame using an RPI. My idea is very basic, as soon as the system boots instead of showing the terminal it should show a slideshow of images. No user interface, no controls, just showing images from the SD card.

I have installed the 9.0.3 image and no matter which approach I take, I end up going nowhere. I have looked at the book and haven't found anything which made any bells ring. I think though, that this project would fit very well in the book.

I would like to avoid starting a window manager - don't need the user interface.

- So far I have tried going the python+tKinter way, but I end up with the "unable to open X server" error.
- I have tried simply using ImageMagick, but I face the same "unable to open X server" error.

I have installed xorg-server, but do I really have to run startx before being able to use anything which depends on X11?

- I tried the pygame/SDL way, but I didn't manage to install pygame.

Can any of you experienced guys gently push me in a direction where I won't face a dead end all the time? My programming experience is in MS Windows, so I am still in the very beginning of my Linux experience.

Regards, Casper

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Simple image viewer, which approach should I take?
« Reply #1 on: December 13, 2017, 02:49:48 PM »
There are framebuffer image viewers that do not require X, such as fbv. You may need to compile one in case there isn't one in the pi repos.
The only barriers that can stop you are the ones you create yourself.

Offline polikuo

  • Hero Member
  • *****
  • Posts: 758
Re: Simple image viewer, which approach should I take?
« Reply #2 on: December 14, 2017, 04:28:09 AM »
There are framebuffer image viewers that do not require X, such as fbv. You may need to compile one in case there isn't one in the pi repos.

To compile fbv from source:

Code: [Select]
## compile from source
tce-load -i compiletc libjpeg-turbo-dev libpng-dev git
git clone https://github.com/godspeed1989/fbv.git
cd fbv
./configure CFLAGS='-Os -pipe' CXXFLAGS='-Os -pipe' LDFLAGS='-Wl,-O1'
make
sudo make install
## make package
tar zcf /tmp/tmp.tgz /usr/local/man/man1/fbv.1.gz /usr/local/bin/fbv
mkdir /tmp/fbv-root
tar zxf tmp.tgz -C /tmp/fbv-root
strip fbv-root/usr/local/bin/fbv
sudo chown root:root /tmp/fbv-root
tce-load -i squashfs-tools
mksquashfs fbv-root/ fbv.tcz
echo libjpeg-turbo.tcz > fbv.tcz.dep
echo libpng.tcz >> fbv.tcz.dep
md5sum fbv.tcz > fbv.tcz.md5.txt
mv fbv.tcz* /etc/sysconfig/tcedir/optional/

[Edit]
I've never used fbv before,
it works when my Xserver is running,
but it doesn't seem to work without loading a Xserver.  :-\
« Last Edit: December 14, 2017, 04:53:52 AM by polikuo »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Simple image viewer, which approach should I take?
« Reply #3 on: December 14, 2017, 10:15:57 AM »
Hi polikuo
[Edit]
I've never used fbv before,
it works when my Xserver is running,
but it doesn't seem to work without loading a Xserver.  :-\
That's because you need some graphics capability to display images. The basic graphics framework under linux is called  X. Most
GUI toolkits such as GTK, QT, FLTK, etc. are built on or rely on  X  in some way. X provides only primitive functions, such as
creating windows, drawing lines, filling areas, loading and drawing fonts, etc. If you want buttons, text boxes, drop downs, and
other fancy stuff, you either use a GUI toolkit or create them all yourself directly in  X. Of course nobody in their right mind would
program directly in  X  these days. If you're interested, here's an example of a desktop clock I wrote using only  X:
http://forum.tinycorelinux.net/index.php/topic,13793.msg77139.html#msg77139

Offline Chau

  • Newbie
  • *
  • Posts: 20
Re: Simple image viewer, which approach should I take?
« Reply #4 on: December 14, 2017, 03:10:51 PM »
To compile fbv from source:

Code: [Select]
## compile from source
tce-load -i compiletc libjpeg-turbo-dev libpng-dev git
git clone https://github.com/godspeed1989/fbv.git
cd fbv
./configure CFLAGS='-Os -pipe' CXXFLAGS='-Os -pipe' LDFLAGS='-Wl,-O1'
make
sudo make install

Thanks for posting this! I already made it this far but it failed at the dependencies, because I didn't have any flags set up like you did.

[Edit]
I've never used fbv before,
it works when my Xserver is running,
but it doesn't seem to work without loading a Xserver.  :-\

What a shame, which brings me back to:

Do I have to run startX to be able to show an image on the monitor?

Ideally the PI should boot fast and immediately begin displaying images - not starting a window manager.

Quote from: Rich
That's because you need some graphics capability to display images.

What other options do I have or am I misunderstanding something completely with respect to X?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Simple image viewer, which approach should I take?
« Reply #5 on: December 14, 2017, 03:36:07 PM »
Hi Chau
An Xserver would be  Xvesa  or  Xorg,  you need one of those. You don't need to install a window manager. Yes, you do need to
run  startX  to start X.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Simple image viewer, which approach should I take?
« Reply #6 on: December 14, 2017, 04:10:53 PM »
I do use  fbv  in a loop for displaying a boot animation during ... boot.
So I'm positive it doesn't depend on a running X server in order to display images.
It doesn't support a hole lot of image formats though.
I'll see if I can provide more info in a couple of hours.
Download a copy and keep it handy: Core book ;)

Offline Chau

  • Newbie
  • *
  • Posts: 20
Re: Simple image viewer, which approach should I take?
« Reply #7 on: December 15, 2017, 07:23:42 AM »
I do use  fbv  in a loop for displaying a boot animation during ... boot.
So I'm positive it doesn't depend on a running X server in order to display images.
It doesn't support a hole lot of image formats though.
I'll see if I can provide more info in a couple of hours.

That is something I like to hear  8)

I'll appreciate if you have more information on the matter!

Offline NewUser

  • Full Member
  • ***
  • Posts: 169
Re: Simple image viewer, which approach should I take?
« Reply #8 on: December 15, 2017, 04:35:38 PM »
I don't know if the TC version is different, but this site give the supported images.  http://freshmeat.sourceforge.net/projects/fbv

Offline Chau

  • Newbie
  • *
  • Posts: 20
Re: Simple image viewer, which approach should I take?
« Reply #9 on: January 10, 2018, 02:59:31 PM »
I do use  fbv  in a loop for displaying a boot animation during ... boot.
So I'm positive it doesn't depend on a running X server in order to display images.
It doesn't support a hole lot of image formats though.
I'll see if I can provide more info in a couple of hours.

That is something I like to hear  8)

I'll appreciate if you have more information on the matter!

Finally I had time to get back to my project. I did a clean piCore install on my SD card and just downloaded, compiled and tried fbv and it works without the X-server.

Now my problem is that the image doesn't fill the entire screen in full screen. I am starting a new thread on that issue.

And last: Thanks for all your help!

Offline mbivol10

  • Newbie
  • *
  • Posts: 39
Re: Simple image viewer, which approach should I take?
« Reply #10 on: January 11, 2018, 11:39:37 AM »
Write directly to /dev/fb0 ;)

Offline Chau

  • Newbie
  • *
  • Posts: 20
Re: Simple image viewer, which approach should I take?
« Reply #11 on: January 14, 2018, 03:14:22 PM »
I do use  fbv  in a loop for displaying a boot animation during ... boot.
So I'm positive it doesn't depend on a running X server in order to display images.
It doesn't support a hole lot of image formats though.
I'll see if I can provide more info in a couple of hours.

Hi Misalf,

How do you set fbv to start during boot?

I have added the following line to /opt/bootlocal.sh:

Code: [Select]
/mnt/mmcblk0p2/fbv/fbv -s 50 -i -c /mnt/mmcblk0p2/images/*.jpg
and when I boot one image is displayed and then fbv stops. The image is still displaying but the cursor is blinking corresponding to the position where the cursor normally would be waiting if I hadn't added the line above. The above line works fine if I just type it after boot.

Can you tell why this happen?

Regards, Casper

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Simple image viewer, which approach should I take?
« Reply #12 on: January 14, 2018, 06:15:52 PM »
I have edited  core.gz , I believe  /etc/init.d/tc-config  in particular.
/opt/bootlocal.sh  runs much later, pretty much when the system is already up.
Sorry, I forgot about this. I'll post how I did it tomorrow in more detail.
Download a copy and keep it handy: Core book ;)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Simple image viewer, which approach should I take?
« Reply #13 on: January 15, 2018, 04:23:54 AM »
For a photo frame, you should have the command in tc's .profile.
The only barriers that can stop you are the ones you create yourself.

Offline Chau

  • Newbie
  • *
  • Posts: 20
Re: Simple image viewer, which approach should I take?
« Reply #14 on: January 25, 2018, 02:14:38 PM »
I have edited  core.gz , I believe  /etc/init.d/tc-config  in particular.
/opt/bootlocal.sh  runs much later, pretty much when the system is already up.
Sorry, I forgot about this. I'll post how I did it tomorrow in more detail.

I looked at the tc-config but I have no idea where to place my command.

For a photo frame, you should have the command in tc's .profile.

I tried this and it works. How early can I get my program to run after I boot the PI? If I put my command in tc-config would my program start faster?