Skip to Content
author's profile photo Former Member
Former Member

Generating images (GIF) from iViews

Hi,

I am looking for a way to generate GIF images from my iView.

If I use a regular servlet as a portal component and set the response type to "image/gif", I get an empty HTML page.

Another approach would be to use a normal AbstractPortalComponent. But it seems that an AbstractPortalComponent can only produce HTML/XML/RSS.. output, but no binary format.

To include images as IResources works for static files, but not for Portal Components. Of course it would work to save my image to a file and use that, but I want to avoid that approach.

Has anybody done something like this ?

Regards,

Heiko

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2004 at 04:30 PM

    Hello Heiko,

    If you want to create an image in AbstractPortalComponent you can do the following:

    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response){

    HttpServletResponse servletResponse = request.getServletResponse(false);

    servletResponse.setContentType("image/gif");

    OutputStream os = servletResponse.getOutputStream();

    byte[] gifbytes;

    BufferedOutputStream out = null;

    try{

    gifbytes= <get byte array of the GIF image>;

    out = new BufferedOutputStream(os);

    out.write(gifbytes);

    }finally{

    if (os!=null){

    os.close();

    }

    }

    }

    basically the same approach will work with a plain servlet code.

    Best Regards,

    Dmitry

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2004 at 01:08 PM

    Hi,

    Detlev, your too fast, remember the speed of light limitation! I think one should have

    request.getServletResponse(true)

    since you don't want the portal to add any stuff around your Image.

    Hope that helps.

    PD

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Detlev Beutner

      Hi Detlev,

      hi PD,

      thanks for your comments. It works fine now (reward points already granted 😉).

      I was so focused on doContent() and setComponentResponseType() that I didn't notice that the request-event-cycle is much more complicated (and powerful !). Your hint opened the door to a new area to explore.....

      Cheers,

      Heiko

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.