jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject cvs commit: jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image ImageTag.java
Date Tue, 01 Jun 2004 11:41:00 GMT
abey        2004/06/01 04:41:00

  Modified:    image/src/org/apache/taglibs/image ImageTag.java
  Log:
  Added support to check and default to JPEG if GIF encoding support is lacking
  
  Revision  Changes    Path
  1.6       +71 -56    jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageTag.java
  
  Index: ImageTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/ImageTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ImageTag.java	3 May 2004 15:47:42 -0000	1.5
  +++ ImageTag.java	1 Jun 2004 11:41:00 -0000	1.6
  @@ -1,56 +1,49 @@
   /*
    * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  - * reserved.
  - *
  + * 
  + * Copyright (c) 1999 The Apache Software Foundation. All rights reserved.
  + * 
    * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  + * modification, are permitted provided that the following conditions are met:
  + * 
  + * 1. Redistributions of source code must retain the above copyright notice,
  + * this list of conditions and the following disclaimer.
  + * 
  + * 2. Redistributions in binary form must reproduce the above copyright notice,
  + * this list of conditions and the following disclaimer in the documentation
  + * and/or other materials provided with the distribution.
  + * 
  + * 3. The end-user documentation included with the redistribution, if any, must
  + * include the following acknowlegement: "This product includes software
  + * developed by the Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowlegement may appear in the software itself, if and
  + * wherever such third-party acknowlegements normally appear.
  + * 
    * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  + * Foundation" must not be used to endorse or promote products derived from this
  + * software without prior written permission. For written permission, please
  + * contact apache@apache.org.
  + * 
  + * 5. Products derived from this software may not be called "Apache" nor may
  + * "Apache" appear in their names without prior written permission of the Apache
  + * Group.
  + * 
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE
  + * SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - *
  + * 
  + * This software consists of voluntary contributions made by many individuals on
  + * behalf of the Apache Software Foundation. For more information on the Apache
  + * Software Foundation, please see <http://www.apache.org/>.
  + *  
    */
   
   package org.apache.taglibs.image;
  @@ -75,13 +68,13 @@
   import com.mullassery.imaging.util.Util;
   
   /**
  - * Images will be processed and saved in a specified directory. The image tag
  - * is printed with the src pointing to the newly created image. The attribute
  - * to refresh will always generate the image. When it is turned off, the image
  + * Images will be processed and saved in a specified directory. The image tag is
  + * printed with the src pointing to the newly created image. The attribute to
  + * refresh will always generate the image. When it is turned off, the image
    * which was generated earlier is used. This will save a lot of processing and
    * memory usage (especially for usage such as thumbnails etc.). The display
  - * option allows one to specify an image to be displayed or just created but
  - * not displayed.
  + * option allows one to specify an image to be displayed or just created but not
  + * displayed.
    * 
    * For truly dynamic images that are made for a particular person only and that
    * is not required after that one use can turn on a &quot;dynamic&quot; option/
  @@ -224,12 +217,34 @@
       }
   
       private void getLocalImageFile() throws JspException {
  +        String imgFile = null;
           //if the name is not specified the src will be specified
           if (name == null) {
               URL url = getUrl(src);
               name = url.getFile().substring(url.getFile().lastIndexOf('/') + 1);
  +            imgFile = Util.extractFileName(name);
  +            // The genrated file may be jpeg due to lack of GIF encoding support
  +            if (Util.getExtentionType(imgFile).equalsIgnoreCase("GIF")) {
  +                try {
  +                    Class.forName("Acme.JPM.Encoders.GifEncoderNoCM");
  +                    Class.forName("com.eteks.filter.Web216ColorsFilter");
  +                } catch (ClassNotFoundException e) {
  +                    context
  +                            .log("ACME and PJA classes (pjatools.jar) for GIF "
  +                                    + "Encoding should be in the classpath. "
  +                                    + "You can get them from" +
  +                                    		" http://www.eteks.com/pja/en/");
  +                    context.log("Searching for a JPEG image instead that might" +
  +                    		" be saved last time due to lack of GIF encoding" +
  +                    		" support.");
  +                    int ind_dot = name.indexOf('.');
  +                    name = name.substring(0, ind_dot + 1) + "jpg";
  +                    imgFile = Util.extractFileName(name);
  +                }
  +            }
  +        } else {
  +            imgFile = Util.extractFileName(name);
           }
  -        String imgFile = Util.extractFileName(name);
           img = new File(context.getRealPath("/") + dir, imgFile);
       }
   
  @@ -349,7 +364,7 @@
           }
           URL url = null;
           try {
  -            url = new URL(hres.encodeURL(srcStr));
  +            url = new URL(srcStr);
           } catch (MalformedURLException e) {
               context.log("Not a proper URL: " + srcStr, e);
               throw new JspException(e);
  @@ -405,4 +420,4 @@
           this.quality = quality;
   
       }
  -}
  +}
  \ No newline at end of file
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message