473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Advice on sending images to clients over network

Hi all

This is not strictly a Python question, but as the system to which
relates is written in Python, hopefully it is not too off-topic.

I have an accounting/business application, written in client/server
mode. The server makes a connection to a database, and then runs a
continuous loop waiting for client connections, establishes a session
with the client, and responds to messages received from the client
until the client closes the connection. The client uses wxPython as
the gui. All the business logic is on the server - there is none at
all on the client side. It seems to be working quite well.

I now want to add the capability of displaying images on the client.
For example, if the application deals with properties, I want to
display various photographs of the property on the client. wxPython is
perfectly capable of displaying the image. My question is, what is the
best way to get the image to the client?

Assume that the images are stored in a directory on the server, or at
least accessible from the server, and that the database has a table
which stores the full path to each image, with the property id as a
reference.

My first thought was that the server would simply retrieve the path,
read the image, and send it to the client over the network, along with
all the other information. The problem with this is performance - I
may set up a page with 20 images to be displayed on the client, which
may take some time. I need the server to respond to client messages as
quickly as possible, so that it is ready to handle the next request.
The server is multi-threaded, so it will not block other threads, but
it may still result in sluggish performance.

My second thought was to send the path to the image down to the
client, and get the client to read the image directly. The problem
with this is that each client needs to be able to resolve the path to
the image directory. At present, all that the client requires is a
pointer to the client program directory, and a parameter giving it the
ip address and port number required to make a connection to the
server. It seems an extra administrative burden to ensure that each
client can access the image directory, especially if at a later date
it is decided to move the directory.

My third thought was to set up a separate 'image server'. It would be
another server program written in Python, listening on its own port
number, waiting for a client request for a particular image. It would
know where to find it, read it in, and send it to the client. Then all
the client needs to know is the ip address and port number.

It seems likely that a typical setup would start by storing the images
on the same machine as the database and the server program. If so,
there would be little difference between any of the above, as no
matter with method is used, the same machine ultimately has to read
the record from its own hard drive and send it down the network over
its own nic.

If at a later date it was decided that the volume of image handling
was slowing down the server process, one might well decide to move the
images to a separate server. In this case, I think that my third
option would make it easiest to facilitate this. You would have to
change all the client parameters to connect to a different server. Or
maybe not - thinking aloud, I could pass the 'image server connection
parameters' to the client from the main server once a connection has
been established. A second implication is that you would have to
change all the paths in the database table. Again, maybe not - just
store the file names in the table, and the path to the directory as a
separate parameter. Then you only have to change the parameter.

I guess the point of all this rambling is that my thought process is
leading me towards my third option, but this would be a bit of work to
set up, so I would appreciate any comments from anyone who has been
down this road before - do I make sense, or are there better ways to
handle this?

Any suggestions will be much appreciated.

Thanks

Frank Millman

Jul 22 '07 #1
8 1971
Frank Millman wrote:
My question is, what is the best way to get the image to the
client?
IMHO, HTTP would be most painless. Either incorporate a little HTTP
server into your server application, or use a seperate daemon and
let the server only output HTTP links.
My third thought was to set up a separate 'image server'. It would
be another server program written in Python, listening on its own
port number, waiting for a client request for a particular image.
It would know where to find it, read it in, and send it to the
client. Then all the client needs to know is the ip address and
port number.
See above -- you could also write your own HTTP server. Best using
Twisted or something of similar high level. Why make yourself work
developing such a system when somebody already did it for you?
I guess the point of all this rambling is that my thought process
is leading me towards my third option, but this would be a bit of
work to set up, so I would appreciate any comments from anyone who
has been down this road before - do I make sense, or are there
better ways to handle this?
For minimum additional work, I'd use some lightweight http daemon,
like lighttpd ot thttpd. Then your server can pass links like
<http://yourserver.example.com/images/thingy1.jpegand the clients
can use well-tested standard library routines to retrieve the
image.

Regards,
Björn

--
BOFH excuse #174:

Backbone adjustment

Jul 22 '07 #2
Frank Millman <fr***@chagford.comwrites:
Any suggestions will be much appreciated.
Why on earth don't you write the whole thing as a web app instead of
a special protocol? Then just use normal html tags to put images
into the relevant pages.
Jul 22 '07 #3
Frank Millman wrote:
I guess the point of all this rambling is that my thought process is
leading me towards my third option, but this would be a bit of work to
set up, so I would appreciate any comments from anyone who has been
down this road before - do I make sense, or are there better ways to
handle this?

Any suggestions will be much appreciated.
I would put the images into a static web directory, either on the same
or different server. Then your main server just sends the url (or
relevant portion of the url, or list of all urls to download), and then
the client grabs the images from your image server using urllib.

Let Apache do what it's good at, instead of reinventing that particular
wheel.

--
pkm ~ http://paulmcnett.com
Jul 22 '07 #4
Paul Rubin wrote:
Frank Millman <fr***@chagford.comwrites:
>Any suggestions will be much appreciated.

Why on earth don't you write the whole thing as a web app instead of
a special protocol? Then just use normal html tags to put images
into the relevant pages.
I believe he has a full desktop client app, not a web app. Believe it or
not, there's still a solid place for desktop applications even in this
ever-increasing webified world.

Use the right tool for the job...
--
pkm ~ http://paulmcnett.com
Jul 22 '07 #5
Paul McNett wrote:
Paul Rubin wrote:
>Frank Millman <fr***@chagford.comwrites:
>>Any suggestions will be much appreciated.

Why on earth don't you write the whole thing as a web app instead of
a special protocol? Then just use normal html tags to put images
into the relevant pages.

I believe he has a full desktop client app, not a web app. Believe it or
not, there's still a solid place for desktop applications even in this
ever-increasing webified world.
He's using wxPython and already has network connectivity to access the
database server.
Use the right tool for the job...
Yep... I also believe that a HTTP server is the right tool. :-)
Jul 22 '07 #6
On 7/22/07, Paul McNett <p@ulmcnett.comwrote:
Paul Rubin wrote:
Frank Millman <fr***@chagford.comwrites:
Any suggestions will be much appreciated.
Why on earth don't you write the whole thing as a web app instead of
a special protocol? Then just use normal html tags to put images
into the relevant pages.

I believe he has a full desktop client app, not a web app. Believe it or
not, there's still a solid place for desktop applications even in this
ever-increasing webified world.

Use the right tool for the job...
There is no reason that something being a "desktop app" means they
can't use HTTP instead of reinventing the protocol wheel all over
again.
--
pkm ~ http://paulmcnett.com
--
http://mail.python.org/mailman/listinfo/python-list

--
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/
Jul 22 '07 #7
Calvin Spealman wrote:
On 7/22/07, Paul McNett <p@ulmcnett.comwrote:
>Paul Rubin wrote:
Frank Millman <fr***@chagford.comwrites:
Any suggestions will be much appreciated.

Why on earth don't you write the whole thing as a web app instead of
a special protocol? Then just use normal html tags to put images
into the relevant pages.

I believe he has a full desktop client app, not a web app. Believe it or
not, there's still a solid place for desktop applications even in this
ever-increasing webified world.

Use the right tool for the job...

There is no reason that something being a "desktop app" means they
can't use HTTP instead of reinventing the protocol wheel all over
again.
Absolutely! Which is why I recommended setting up an httpd to serve the
images...

I interpreted Paul Rubin's response to say "rewrite the whole thing
(client, server, everything) as a web app".

Cheers!
--
pkm ~ http://paulmcnett.com
Jul 22 '07 #8

Frank Millman wrote:
Hi all

This is not strictly a Python question, but as the system to which
relates is written in Python, hopefully it is not too off-topic.
[...]
I now want to add the capability of displaying images on the client.
For example, if the application deals with properties, I want to
display various photographs of the property on the client. wxPython is
perfectly capable of displaying the image. My question is, what is the
best way to get the image to the client?
Thanks for all the responses.

The verdict seems unanimous - use http.

Thanks for pointing me in the right direction.

Frank

Jul 23 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
4
by: david | last post by:
hello, I have a client/server application. the server capture picture from webcam and send it to every client connected to it.the network part works good and the capture from webcam too. I...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.