Image manipulation in a console program

Linux specific forum
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Image manipulation in a console program

Post 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?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It is only a warning, it shouldn't create further problems.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post 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?
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post 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?
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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"
El_Choni
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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.
quidquid Latine dictum sit altum videtur
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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) ;)
El_Choni
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post 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:
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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. ;)
El_Choni
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post 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!
bye,
Daniel
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Thanks, but I'm afraid my host provider won't give me that option. ;)
El_Choni
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 576
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Optionally you could try to call "ImageMagick" via RunProgram, if it's installed, or any other external libs.
cheers,

bembulak
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Thank you, I'll try -I had given up libjpeg and was trying using Gdk directly.
El_Choni
Post Reply