Image vs. ImageField: how to post an image object

10 messages Options
Embed this post
Permalink
megabass () Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
Hello all,

I am new at Plone Forums and just getting starting with developing for plone.

Could you plese help me(or give a link to help information) to construct an image object and get the link of it.

So ... I need to generate an image(that's not the problem) and then create and post the image object(that is it)

Thank you in anticipation
pigeonflight () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink


On Thu, Oct 29, 2009 at 6:06 PM, megabass <[hidden email]> wrote:

Hello all,

I am new at Plone Forums and just getting starting with developing for
plone.

Could you plese help me(or give a link to help information) to construct an
image object and get the link of it.

So ... I need to generate an image(that's not the problem)
 
and then create
and post the image object(that is it)
 
So you're talking about a scenerio where an image (e.g. a graph from some data) is generated and you want to know how to "pass' that generated image to plone programmatically?
Is that what you're asking?

Thank you in anticipation
--
View this message in context: http://n2.nabble.com/Image-vs-ImageField-how-to-post-an-image-object-tp3916101p3916101.html
Sent from the Archetypes mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users



--
SplashStart - Professional Websites. Starting Now.
http://www.splashstart.com


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
pigeonflight wrote:
On Thu, Oct 29, 2009 at 6:06 PM, megabass <megabass@arcor.de> wrote:

So you're talking about a scenerio where an image (e.g. a graph from some
data) is generated and you want to know how to "pass' that generated image
to plone programmatically?
Is that what you're asking?
Hello, pigeonflight!
Yeah, this is exact what I meant
Mikko Ohtamaa () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink

>
> So you're talking about a scenerio where an image (e.g. a graph from some
> data) is generated and you want to know how to "pass' that generated image
> to plone programmatically?
> Is that what you're asking?
>
>
Hello, pigeonflight!
Yeah, this is exact what I meant

The outline of the process

1. Create a BrowserView for URL from which image is served

2. Use generic Python knowledge and image library to draw the actual image (check Python imaging library)

3. Instead of serving HTML from your view you send the image data. Python imaging library can "save" image to memory using StringIO and you can return the data of this temporary file-like object. request.response.setHeader("Content-type: image/jpeg")

Here is one complex example - it might be too complex to set the main points in it, but I hope it is something:


-MIkko

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
Mikko Ohtamaa wrote:
1. Create a BrowserView for URL from which image is served

2. Use generic Python knowledge and image library to draw the actual image
(check Python imaging library)

3. Instead of serving HTML from your view you send the image data. Python
imaging library can "save" image to memory using StringIO and you can return
the data of this temporary file-like object.
request.response.setHeader("Content-type: image/jpeg")

Here is one complex example - it might be too complex to set the main points
in it, but I hope it is something:

http://code.google.com/p/plonegomobile/source/browse/trunk/gomobile/gomobile.mobile/gomobile/mobile/browser/resizer.py
Hello Mikko,

thank you very much for your answer and the code example. It's realy pretty deifficult to understand it without a context.

Could you please explain the third step more detailed.
So I have a browser view and the image object is already generated.

here are some cuts from browser .pt und .py files

pt:
...
[<]span tal:content="view/getImage"[>]Image[<]/span[>]
...


py:

class dashboardView(BrowserView):
    """
    dashboard browser view
    """
    implements(IdashboardView)
...
  def getImage(self):

     img = Image.new(mode, size)
     #generate the image
     ...

    #how can I return the link to the image object?
    #or could you please provide me your solution with the temporary file


Thank very much
Vlad
pigeonflight () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
megabass,
This is a candidate for the Plone Developers Manual.
Once you've distilled this, I suggest that you contribute an example to the Plone Developers Manual

On Fri, Oct 30, 2009 at 4:50 AM, megabass <[hidden email]> wrote:


Mikko Ohtamaa wrote:
>
> 1. Create a BrowserView for URL from which image is served
>
> 2. Use generic Python knowledge and image library to draw the actual image
> (check Python imaging library)
>
> 3. Instead of serving HTML from your view you send the image data. Python
> imaging library can "save" image to memory using StringIO and you can
> return
> the data of this temporary file-like object.
> request.response.setHeader("Content-type: image/jpeg")
>
> Here is one complex example - it might be too complex to set the main
> points
> in it, but I hope it is something:
>
> http://code.google.com/p/plonegomobile/source/browse/trunk/gomobile/gomobile.mobile/gomobile/mobile/browser/resizer.py
>
>

Hello Mikko,

thank you very much for your answer and the code example. It's realy pretty
deifficult to understand it without a context.

Could you please explain the third step more detailed.
So I have a browser view and the image object is already generated.

here are some cuts from browser .pt und .py files

pt:
...
[<]span tal:content="view/getImage"[>]Image[<]/span[>]
...


py:

class dashboardView(BrowserView):
   """
   dashboard browser view
   """
   implements(IdashboardView)
...
 def getImage(self):

    img = Image.new(mode, size)
    #generate the image
    ...

   #how can I return the link to the image object?
   #or could you please provide me your solution with the temporary file


Thank very much
Vlad
--
View this message in context: http://n2.nabble.com/Image-vs-ImageField-how-to-post-an-image-object-tp3916101p3917930.html
Sent from the Archetypes mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users



--
SplashStart - Professional Websites. Starting Now.
http://www.splashstart.com


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink

pigeonflight wrote:
megabass,
This is a candidate for the Plone Developers Manual.
Once you've distilled this, I suggest that you contribute an example to the
Plone Developers Manual
Hello, pigeonflight,

I would like to participate. But I need help first...
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
Could somebody help me?
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink
Hello All!

I did the steps Mikko described and could call the content of image via template but it couldn't be displayed as man tal Knowlege isn't enough...(I saw binary simbols displayed)

What I would like to do is to register programmatically an ImageField and fill it with a generated image just to get possibility to scale it easily, could somebody give me a reference or some advises how to do it?

I think I can not call the download function properly. Do sombody know some workraronds about it?

Thank you in anticipation
megabass () Re: Image vs. ImageField: how to post an image object
Reply Threaded More More options
Print post
Permalink