Page 1 of 1

Image manipulation in a console program

Posted: Tue Sep 16, 2008 9:11 pm
by mdp
I am coding a PB cgi that works on a x-less webserver, but internally uses image manipulation functions. It's a small GIS, to give the idea.

Having

Code: Select all

UseJPEGImageDecoder() : LoadImage(#myImage,"myEarthImage.jpg")
inside, produces:

Code: Select all

Gtk-WARNING **: cannot open display
The program stops there.

The GTK libraries are in place, only thing I'm not running is a X server.
I supposed image operation in a console only environment should be possible...

Can you help?

Posted: Wed Sep 17, 2008 8:18 pm
by Trond
It is only a warning, it shouldn't create further problems.

Posted: Wed Sep 17, 2008 9:53 pm
by mdp
Trond, try some

Code: Select all

OpenConsole()
UseJPEGImageDecoder()
PrintN("Will you see this?")
Sorry I'm not testing the above code right now (I just finished the GIS via javascript only - a language I love so much I just restarted smoking), but the concept is akin to the one tested yesterday. The program "stopped".
You will not see the output... Do you confirm?

Posted: Thu Sep 18, 2008 1:31 pm
by mdp
...I tried now.
The above code will actually work (sorry), but:

Code: Select all

OpenConsole()
UseJPEGImageDecoder()
CreateImage(0,100,100)
PrintN("Will you see this?")
Will not work, CreateImage() will cause the CannotOpenDisplay error.
On an abstract (non technical) evaluation that should be legitimate (I can operate on images for saving them, output them through MIME etc.). Is there anything I am missing?

Posted: Wed Apr 15, 2009 5:39 pm
by El_Choni
I have the same problem with LoadImage (PB Linux 4.30, Linux executable, CentOS 5.0 AMD 64): "Gtk-WARNING **: cannot open display"

Posted: Wed Apr 15, 2009 5:48 pm
by freak
There is no way around this in PB 4.30. PB Images are GdkPixmap objects which are actually managed by the X server, so without one you cannot create an image. 4.40 will use GdkPixbuf which is actually a client-side memory buffer. I am not sure though wether you can do without an X server then or not.

Posted: Wed Apr 15, 2009 5:57 pm
by El_Choni
Thanks, Freak. ;)

(Now I'll try to find what an X server is and wether I have it or not; I'm new to Linux) ;)

Posted: Wed Apr 15, 2009 7:15 pm
by walker
El_Choni wrote:Thanks, Freak. ;)

(Now I'll try to find what an X server is and wether I have it or not; I'm new to Linux) ;)
if you have a graphical environment (gnome, kde etc) you have an X-Server running ... :wink:

Posted: Thu Apr 16, 2009 9:52 am
by El_Choni
Ok, no X server. Apparently my server is running in a virtual box called Virtuozzo which won't even show me the name of a virtual graphic card.

My app needs to do mainly these tasks:

1. Download images from a remote web site.
2. Load those images.
3. Manipulate those images.
4. Upload manipulated images to a client.

My app doesn't actually need to render or show the images. So now I'll try to use libjpeg and libpng in order to be able to load images, manipulate them directly in memory and save them after.

Thanks for your help. ;)

Posted: Thu Apr 16, 2009 10:53 am
by DarkDragon
Try using Xvnc. I do so for some wine applications. But on servers you'd better have a firewall and block the port whenever you don't use it (You maybe also use it through vpn). And always use a password!

Posted: Thu Apr 16, 2009 11:13 am
by El_Choni
Thanks, but I'm afraid my host provider won't give me that option. ;)

Posted: Fri Apr 17, 2009 8:24 am
by bembulak
Optionally you could try to call "ImageMagick" via RunProgram, if it's installed, or any other external libs.

Posted: Fri Apr 17, 2009 1:44 pm
by El_Choni
Thank you, I'll try -I had given up libjpeg and was trying using Gdk directly.