Changeset 659


Ignore:
Timestamp:
02/07/12 09:50:21 (3 months ago)
Author:
niko
Message:

change to maven project

Location:
Core/trunk
Files:
3 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • Core/trunk/.classpath

    r586 r659  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<classpath> 
    3         <classpathentry kind="src" path="src"/> 
    4         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    5         <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/corinis"/> 
     3        <classpathentry kind="src" output="target/classes" path="src/main/java"/> 
     4        <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> 
     5        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 
     6        <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> 
    67        <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/> 
    7         <classpathentry combineaccessrules="false" kind="src" path="/XMLUtils"/> 
    8         <classpathentry kind="output" path="bin"/> 
     8        <classpathentry kind="output" path="target/classes"/> 
    99</classpath> 
  • Core/trunk/.project

    r586 r659  
    1111                        </arguments> 
    1212                </buildCommand> 
     13                <buildCommand> 
     14                        <name>org.eclipse.m2e.core.maven2Builder</name> 
     15                        <arguments> 
     16                        </arguments> 
     17                </buildCommand> 
    1318        </buildSpec> 
    1419        <natures> 
     20                <nature>org.eclipse.m2e.core.maven2Nature</nature> 
    1521                <nature>org.eclipse.jdt.core.javanature</nature> 
    1622        </natures> 
  • Core/trunk/src/main/java/corinis/util/FileUtils.java

    r531 r659  
    369369                                 
    370370                        // character replaces... better this way 
    371                         case 'Ä': 
    372                         case 'Â': 
    373                         case 'À': 
    374                         case 'Á': 
     371                        case '\u00c4': 
     372                        case '\u00c2': 
     373                        case '\u00c0': 
     374                        case '\u00c1': 
    375375                                placeHolder = false; 
    376376                                sb.append('A'); 
    377377                                break; 
    378378                                 
    379                         case 'ä': 
    380                         case 'â': 
    381                         case 'á': 
    382                         case 'à': 
     379                        case '\u00e4': 
     380                        case '\u00e2': 
     381                        case '\u00e1': 
     382                        case '\u00e0': 
    383383                                placeHolder = false; 
    384384                                sb.append('a'); 
    385385                                break; 
    386                         case 'Ö': 
    387                         case 'Ò': 
    388                         case 'Ó': 
    389                         case 'Ô': 
     386                        case '\u00d6': 
     387                        case '\u00d2': 
     388                        case '\u00d3': 
     389                        case '\u00d4': 
    390390                                placeHolder = false; 
    391391                                sb.append('O'); 
    392392                                break; 
    393                         case 'ö': 
    394                         case 'ô': 
    395                         case 'ó': 
    396                         case 'ò': 
     393                        case '\u00f6': 
     394                        case '\u00f4': 
     395                        case '\u00f3': 
     396                        case '\u00f2': 
    397397                                placeHolder = false; 
    398398                                sb.append('o'); 
    399399                                break; 
    400                         case 'Ü': 
    401                         case 'Û': 
    402                         case 'Ú': 
    403                         case 'Ù': 
     400                        case '\u00dc': 
     401                        case '\u00db': 
     402                        case '\u00da': 
     403                        case '\u00d9': 
    404404                                placeHolder = false; 
    405405                                sb.append('U'); 
    406406                                break; 
    407                         case 'ü': 
    408                         case 'û': 
    409                         case 'ú': 
    410                         case 'ù': 
     407                        case '\u00fc': 
     408                        case '\u00fb': 
     409                        case '\u00fa': 
     410                        case '\u00f9': 
    411411                                placeHolder = false; 
    412412                                sb.append('u'); 
    413413                                break; 
    414                         case 'î': 
    415                         case 'ì': 
    416                         case 'í': 
     414                        case '\u00ee': 
     415                        case '\u00ec': 
     416                        case '\u00ed': 
    417417                                placeHolder = false; 
    418418                                sb.append('i'); 
    419419                                break; 
    420                         case 'Î': 
    421                         case 'Í': 
    422                         case 'Ì': 
     420                        case '\u00ce': 
     421                        case '\u00cd': 
     422                        case '\u00cc': 
    423423                                placeHolder = false; 
    424424                                sb.append('I'); 
    425425                                break; 
    426                         case 'ß': 
     426                        case '\u00df': 
    427427                                placeHolder = false; 
    428428                                sb.append('s'); 
  • Core/trunk/src/main/java/corinis/util/images/MediaConverter.java

    r596 r659  
    2626        public static final int TYPE_DOCUMENT = 1; 
    2727 
    28          
     28 
    2929        /** The type is an image 
    3030         */ 
     
    5656        /** xls (Excel) files 
    5757         */ 
    58     public static final int TYPE_FILE_XLS = 10; 
     58        public static final int TYPE_FILE_XLS = 10; 
    5959        /** xls (Excel) files 
    6060         */ 
    61     public static final int TYPE_FILE_PPT = 11; 
     61        public static final int TYPE_FILE_PPT = 11; 
    6262        /** video 
    6363         */ 
    64     public static final int TYPE_FILE_VIDEO = 12; 
    65          
     64        public static final int TYPE_FILE_VIDEO = 12; 
     65 
    6666        /** The type is an unknown file 
    6767         */ 
    6868        public static final int TYPE_FILEUNKNOWN = 2; 
    69          
     69 
    7070        public static final int ROTATE_NONE = -1; 
    7171        public static final int ROTATE_AUTO = 0; 
     
    8686                if (!original.isFile()) 
    8787                        return null; 
    88                  
     88 
    8989                // generate the converted path: 
    9090                // /originalfolder/originalfilename-w-h-orient-x-y-cx-cy.ext 
    9191                String paths[] = original.getAbsolutePath().replace('\\', '/').split("/"); 
    92                  
     92 
    9393                String ext = paths[paths.length].substring(paths[paths.length].lastIndexOf('.'));                
    9494                StringBuffer path = new StringBuffer('/'); 
     
    104104                path.append(orientation); 
    105105                path.append(ext); 
    106                  
    107                  
     106 
     107 
    108108                File target = new File(core.getConfigurator().getMediaConverterPath() + path); 
    109                  
     109 
    110110                // lets do something with the original 
    111111                if (!target.exists()) 
    112112                { 
    113             int type = TYPE_FILEUNKNOWN; //unknown 
    114             String imgtype = null; 
    115             int width = -1; 
    116             int height = -1;                         
    117              
    118             // only display images, no other junk 
    119             if (ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")) 
    120             { 
    121                 type = TYPE_FILE_IMAGE; // image 
    122                 imgtype = Thumbnailer.TYPE_JPEG; 
    123                 ext = "jpg"; 
    124             } else if (ext.equalsIgnoreCase("gif")) 
    125             { 
    126                 type = TYPE_FILE_IMAGE; // image 
    127                 imgtype = Thumbnailer.TYPE_GIF; 
    128                 ext = "gif"; 
    129             } else if (ext.equalsIgnoreCase("png")) 
    130             { 
    131                 type = TYPE_FILE_IMAGE; // image 
    132                 imgtype = Thumbnailer.TYPE_PNG; 
    133                 ext = "png"; 
    134             } else if (ext.equalsIgnoreCase("avi")) 
    135             { 
    136                 type = TYPE_FILE_VIDEO;  
    137                 imgtype = Thumbnailer.TYPE_VIDEO; 
    138                 ext = "avi"; 
    139             } else if (ext.equalsIgnoreCase("mov")) 
    140             { 
    141                 type = TYPE_FILE_VIDEO;  
    142                 imgtype = Thumbnailer.TYPE_VIDEO; 
    143                 ext = "mov"; 
    144             } else if (ext.equalsIgnoreCase("wmv")) 
    145             { 
    146                 type = TYPE_FILE_VIDEO;  
    147                 imgtype = Thumbnailer.TYPE_VIDEO; 
    148                 ext = "wmv"; 
    149             } else if (ext.equalsIgnoreCase("fla")) 
    150             { 
    151                 type = TYPE_FILE_FLASH; // flash 
    152                 ext = "fla"; 
    153             } else if (ext.equalsIgnoreCase("dcr")) 
    154                 type = TYPE_FILE_SHOCKWAVE; // shockwave 
    155             else if (ext.equalsIgnoreCase("pdf")) 
    156                 type = TYPE_FILE_PDF; // pdf 
    157             else if (ext.equalsIgnoreCase("doc")) 
    158                 type = TYPE_FILE_DOC; // avi 
    159             else if (ext.equalsIgnoreCase("zip")) 
    160                 type = TYPE_FILE_ZIP; // quicktime 
    161             else 
    162                 type = TYPE_FILEUNKNOWN;   
    163              
    164             // get the width/height of the file 
    165             if (type == TYPE_FILE_FLASH || type == TYPE_FILE_VIDEO || type == TYPE_FILE_IMAGE) 
    166             {             
    167                     ImageInfo ii = new ImageInfo(); 
    168                     ii.setInput(new FileInputStream(original)); 
    169                     if (ii.check()) 
    170                     { 
    171                         width = ii.getWidth(); 
    172                         height = ii.getHeight(); 
    173                     } 
    174                      
    175                     if (width <= 0) 
    176                         width = 0; 
    177                     if (height <= 0) 
    178                         height = 0; 
    179                      
    180             } 
    181              
    182             try 
    183             { 
    184                 // we have written the file, lets find out information about it  
    185                 // and convert/thumbnail it :) 
    186                 switch (type) 
    187                 { 
    188                         case TYPE_FILE_IMAGE: 
    189                                 // jpeg is a special case - imageinfo might fail 
    190                                 if (imgtype.equals(Thumbnailer.TYPE_JPEG)) 
    191                                         { 
    192                                         Metadata metadata = JpegMetadataReader.readMetadata(original); 
    193                                         Directory exif = metadata.getDirectory(ExifDirectory.class); 
    194                                         Directory jpeg = metadata.getDirectory(JpegDirectory.class); 
    195                                         // for later? 
    196                                         if (orientation == ROTATE_AUTO) 
    197                                                 if (exif.containsTag(ExifDirectory.TAG_ORIENTATION)) 
    198                                                         orientation = exif.getInt(ExifDirectory.TAG_ORIENTATION ); 
    199  
    200                                         if (jpeg.containsTag(JpegDirectory.TAG_JPEG_IMAGE_WIDTH)) 
    201                                                 width = jpeg.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH); 
    202                                         if (jpeg.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) 
    203                                                 height = jpeg.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT); 
    204                                         } 
    205                                  
    206                                 break; 
    207                         case TYPE_FILE_VIDEO: 
    208                                 break; 
    209                 } 
    210             } 
    211             catch (Exception e) 
    212             { 
    213                 // these errors should be caught but are not necessary abort-level 
    214                 core.printLog("Problem with file" + original.getAbsolutePath(), e, Core.LOG_WARNING); 
    215             } 
    216              
    217             // create the cache directory (where the flv, thumbnails etc are stored) if not existant 
    218             if (!target.getParentFile().isDirectory()) 
    219             { 
    220                 if (!target.getParentFile().mkdirs()) 
    221                 { 
    222                         core.printLog("Unable to create: " + target.getParentFile().getAbsolutePath(), null, Core.LOG_ERROR); 
    223                         return null; 
    224                 } 
    225             } 
    226              
    227             String rotate = ""; 
    228             switch (orientation) 
    229             { 
    230                 case 1: break; // nothing 
    231                 case 2: rotate = " -flip "; break; 
    232                 case 3: rotate = " -rotate 180 "; break; 
    233                 case 4: rotate = " -flop "; break; 
    234                 case 5: rotate = " -rotate 270 -flip "; break; 
    235                 case 6: rotate = " -rotate 90 "; break; 
    236                 case 7: rotate = " -rotate 270 -flip "; break; 
    237                 case 8: rotate = " -rotate 270 "; break; 
    238             } 
    239              
    240             // create the thumbnail if possible 
    241             if (imgtype != null) 
    242             { 
    243                         String runme = core.getConfigurator().getImageMagickConvert() + " " + original.getAbsolutePath() + " -resize "; 
    244                         runme += resizeW + "x" + resizeH + "! -crop "; 
    245                         runme += w + "x" + h + "+" + x + "+" + y; 
    246                 runme += rotate; 
    247                         runme += " +repage " + target.getAbsolutePath(); 
    248                         try 
    249                         { 
    250                                 Process p = Runtime.getRuntime().exec(runme); 
    251                                 if (wait) 
    252                                     p.waitFor(); 
    253                         } 
    254                         catch (Exception e) { 
    255                                 // Print out Error if available 
    256                                 System.err.println(runme); 
    257                                 e.printStackTrace(); 
    258                         } 
    259             } 
     113                        int type = TYPE_FILEUNKNOWN; //unknown 
     114                        String imgtype = null; 
     115                        int width = -1; 
     116                        int height = -1;                         
     117 
     118                        // only display images, no other junk 
     119                        if (ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg")) 
     120                        { 
     121                                type = TYPE_FILE_IMAGE; // image 
     122                                imgtype = Thumbnailer.TYPE_JPEG; 
     123                                ext = "jpg"; 
     124                        } else if (ext.equalsIgnoreCase("gif")) 
     125                        { 
     126                                type = TYPE_FILE_IMAGE; // image 
     127                                imgtype = Thumbnailer.TYPE_GIF; 
     128                                ext = "gif"; 
     129                        } else if (ext.equalsIgnoreCase("png")) 
     130                        { 
     131                                type = TYPE_FILE_IMAGE; // image 
     132                                imgtype = Thumbnailer.TYPE_PNG; 
     133                                ext = "png"; 
     134                        } else if (ext.equalsIgnoreCase("avi")) 
     135                        { 
     136                                type = TYPE_FILE_VIDEO;  
     137                                imgtype = Thumbnailer.TYPE_VIDEO; 
     138                                ext = "avi"; 
     139                        } else if (ext.equalsIgnoreCase("mov")) 
     140                        { 
     141                                type = TYPE_FILE_VIDEO;  
     142                                imgtype = Thumbnailer.TYPE_VIDEO; 
     143                                ext = "mov"; 
     144                        } else if (ext.equalsIgnoreCase("wmv")) 
     145                        { 
     146                                type = TYPE_FILE_VIDEO;  
     147                                imgtype = Thumbnailer.TYPE_VIDEO; 
     148                                ext = "wmv"; 
     149                        } else if (ext.equalsIgnoreCase("fla")) 
     150                        { 
     151                                type = TYPE_FILE_FLASH; // flash 
     152                                ext = "fla"; 
     153                        } else if (ext.equalsIgnoreCase("dcr")) 
     154                                type = TYPE_FILE_SHOCKWAVE; // shockwave 
     155                        else if (ext.equalsIgnoreCase("pdf")) 
     156                                type = TYPE_FILE_PDF; // pdf 
     157                        else if (ext.equalsIgnoreCase("doc")) 
     158                                type = TYPE_FILE_DOC; // avi 
     159                        else if (ext.equalsIgnoreCase("zip")) 
     160                                type = TYPE_FILE_ZIP; // quicktime 
     161                        else 
     162                                type = TYPE_FILEUNKNOWN;   
     163 
     164                        // get the width/height of the file 
     165                        if (type == TYPE_FILE_FLASH || type == TYPE_FILE_VIDEO || type == TYPE_FILE_IMAGE) 
     166                        {             
     167                                ImageInfo ii = new ImageInfo(); 
     168                                ii.setInput(new FileInputStream(original)); 
     169                                if (ii.check()) 
     170                                { 
     171                                        width = ii.getWidth(); 
     172                                        height = ii.getHeight(); 
     173                                } 
     174 
     175                                if (width <= 0) 
     176                                        width = 0; 
     177                                if (height <= 0) 
     178                                        height = 0; 
     179 
     180                        } 
     181 
     182                        try 
     183                        { 
     184                                // we have written the file, lets find out information about it  
     185                                // and convert/thumbnail it :) 
     186                                switch (type) 
     187                                { 
     188                                case TYPE_FILE_IMAGE: 
     189                                        // jpeg is a special case - imageinfo might fail 
     190                                        if (imgtype.equals(Thumbnailer.TYPE_JPEG)) 
     191                                        { 
     192                                                Metadata metadata = JpegMetadataReader.readMetadata(original); 
     193                                                Directory exif = metadata.getDirectory(ExifDirectory.class); 
     194                                                Directory jpeg = metadata.getDirectory(JpegDirectory.class); 
     195                                                // for later? 
     196                                                                if (orientation == ROTATE_AUTO) 
     197                                                                        if (exif.containsTag(ExifDirectory.TAG_ORIENTATION)) 
     198                                                                                orientation = exif.getInt(ExifDirectory.TAG_ORIENTATION ); 
     199 
     200                                                                if (jpeg.containsTag(JpegDirectory.TAG_JPEG_IMAGE_WIDTH)) 
     201                                                                        width = jpeg.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH); 
     202                                                                if (jpeg.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) 
     203                                                                        height = jpeg.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT); 
     204                                        } 
     205 
     206                                        break; 
     207                                case TYPE_FILE_VIDEO: 
     208                                        break; 
     209                                } 
     210                        } 
     211                        catch (Exception e) 
     212                        { 
     213                                // these errors should be caught but are not necessary abort-level 
     214                                core.printLog("Problem with file" + original.getAbsolutePath(), e, Core.LOG_WARNING); 
     215                        } 
     216 
     217                        // create the cache directory (where the flv, thumbnails etc are stored) if not existant 
     218                        if (!target.getParentFile().isDirectory()) 
     219                        { 
     220                                if (!target.getParentFile().mkdirs()) 
     221                                { 
     222                                        core.printLog("Unable to create: " + target.getParentFile().getAbsolutePath(), null, Core.LOG_ERROR); 
     223                                        return null; 
     224                                } 
     225                        } 
     226 
     227                        String rotate = ""; 
     228                        switch (orientation) 
     229                        { 
     230                        case 1: break; // nothing 
     231                        case 2: rotate = " -flip "; break; 
     232                        case 3: rotate = " -rotate 180 "; break; 
     233                        case 4: rotate = " -flop "; break; 
     234                        case 5: rotate = " -rotate 270 -flip "; break; 
     235                        case 6: rotate = " -rotate 90 "; break; 
     236                        case 7: rotate = " -rotate 270 -flip "; break; 
     237                        case 8: rotate = " -rotate 270 "; break; 
     238                        } 
     239 
     240                        // create the thumbnail if possible 
     241                        if (imgtype != null) 
     242                        { 
     243                                String runme = core.getConfigurator().getImageMagickConvert() + " " + original.getAbsolutePath() + " -resize "; 
     244                                runme += resizeW + "x" + resizeH + "! -crop "; 
     245                                runme += w + "x" + h + "+" + x + "+" + y; 
     246                                runme += rotate; 
     247                                runme += " +repage " + target.getAbsolutePath(); 
     248                                try 
     249                                { 
     250                                        Process p = Runtime.getRuntime().exec(runme); 
     251                                        if (wait) 
     252                                                p.waitFor(); 
     253                                } 
     254                                catch (Exception e) { 
     255                                        // Print out Error if available 
     256                                        System.err.println(runme); 
     257                                        e.printStackTrace(); 
     258                                } 
     259                        } 
    260260                }                
    261261                return core.getConfigurator().getMediaConverterUrl() + path; 
  • Core/trunk/src/main/java/corinis/util/images/Thumbnailer.java

    r570 r659  
    33 
    44import java.awt.Dimension; 
    5 import java.awt.Frame; 
    65import java.awt.Graphics; 
    76import java.awt.GraphicsConfiguration; 
     
    1413import java.awt.image.ColorModel; 
    1514import java.awt.image.PixelGrabber; 
    16 import java.io.ByteArrayInputStream; 
    17 import java.io.ByteArrayOutputStream; 
    1815import java.io.File; 
    19 import java.io.FileOutputStream; 
    20 import java.io.InputStream; 
    2116 
    2217import javax.swing.ImageIcon; 
    23  
    24 import Acme.JPM.Encoders.GifEncoder; 
    2518 
    2619import com.drew.metadata.Directory; 
    2720import com.drew.metadata.Metadata; 
    2821import com.drew.metadata.exif.ExifDirectory; 
    29 import com.sun.jimi.core.ImageAccessException; 
    30 import com.sun.jimi.core.Jimi; 
    31 import com.sun.jimi.core.raster.JimiRasterImage; 
    3222 
    3323/** 
     
    3626 * Version History 
    3727 * --------------- 
     28 * 1.4 Niko Berger 
     29 * - removed "qunat" support -use imagemagick 
     30 *  
    3831 * 1.3 Niko Berger 
    3932 * - Added support for imagemagick 
     
    148141    } 
    149142 
    150     public static Image createThumbnailImage(Image image, Dimension size) throws Exception { 
    151         Frame fr = new Frame(); 
    152  
    153         return fr.createImage(createThumbnail(image, size).getImageProducer()); 
    154     } 
    155143 
    156144    public static String getImageTypeFromExt (String ext) 
     
    169157                return null; 
    170158    } 
    171     /** 
    172      * @param image the image object 
    173      * @param size the size the thumbnail should be 
    174      * @return a scaled JimiRasterImage object 
    175      * @throws Exception 
    176      */ 
    177     public static JimiRasterImage createThumbnail(Image image, Dimension size) throws Exception { 
    178         return Jimi.createRasterImage( 
    179                    image.getScaledInstance(size.width, size.height, Image.SCALE_SMOOTH) 
    180                    .getSource()); 
    181     } 
    182  
    183     /** 
    184      * creates an jpeg input stream 
    185      * @param image the original image object 
    186      * @param size the desired thumbnail size 
    187      * @return an inputstream that includes the thumbnail data in jpeg 
    188      * @throws Exception 
    189      */ 
    190     public static InputStream createThumbnailInputStream(Image image, Dimension size) throws Exception{ 
    191         JimiRasterImage raster = createThumbnail(image, size); 
    192         ByteArrayOutputStream out = new ByteArrayOutputStream(); 
    193         Jimi.putImage("image/jpeg", raster, out); 
    194         out.close(); 
    195         byte it[] = out.toByteArray(); 
    196         return new ByteArrayInputStream(it); 
    197     } 
    198  
    199     /** 
    200      * @param file the source file 
    201      * @param maxDim the maximum dimension 
    202      * @return a thumbnail of the the source 
    203      * @throws Exception 
    204      */ 
    205     public static Image createThumbnail (File file, int maxDim) throws Exception 
    206     { 
    207       Image ii = getImage (file); 
    208       return createThumbnailImage(ii, getThumbnailSize(ii, maxDim)); 
    209     } 
    210  
    211     /** 
    212      * @param file the source file 
    213      * @param maxDim the maximum dimension 
    214      * @return a stream for the jpeg of the thumbnail 
    215      * @throws Exception 
    216      */ 
    217     public static InputStream createThumbnailInputStream (File file, int maxDim) throws Exception 
    218     { 
    219       Image ii = getImage (file); 
    220       return createThumbnailInputStream(ii, getThumbnailSize(ii, maxDim)); 
    221     } 
    222  
    223     /** 
    224      * Creates a new thumbnail of the original file 
    225      * @param in the source file 
    226      * @param out the destination file 
    227      * @param maxDim the maximum dimension(width/height, resize wont change the proportion) 
    228      * @param type the type of the image (example: image/jpeg) 
    229      * @throws Exception 
    230      */ 
    231     public static void createThumbnail (File in, int maxDim, File out, String type) throws Exception 
    232     { 
    233       Image iin = getImage (in); 
    234       Dimension d = getThumbnailSize(iin, maxDim); 
    235       createThumbnail(iin, d, out, type); 
    236     } 
     159     
    237160 
    238161 
     
    273196                } 
    274197                else{ 
    275                         Image iin = getImage (in); 
    276                         Dimension d = getThumbnailSize(iin, maxDim); 
    277                         createThumbnail(iin, d, out, type); 
     198                        throw new RuntimeException("Imagemagick not configured - please check your configuration!"); 
    278199                } 
    279200        } 
     
    354275                } 
    355276                else{ 
    356                         Image iin = getImage (in); 
    357                         createThumbnail(iin, new Dimension(width, height), out, type); 
     277                        throw new RuntimeException("Imagemagick not configured - please check your configuration!"); 
    358278                } 
    359279        } 
     
    377297 
    378298    /** 
    379      * 
    380      * @param image the image to take the pixels from 
    381      * @return an array of pixels 
    382      * @throws ImageAccessException 
    383      */ 
    384     static int[][] getPixels(JimiRasterImage image) throws ImageAccessException { 
    385         int w = image.getWidth(); 
    386         int h = image.getHeight(); 
    387  
    388         int pixels[][] = new int[w][h]; 
    389         for (int x = w; x-- > 0; ) { 
    390             for (int y = h; y-- > 0; ) { 
    391                 pixels[x][y] = image.getPixelRGB(x, y); 
    392             } 
    393         } 
    394  
    395         return pixels; 
    396     } 
    397  
    398     /** 
    399      * Writes a image scaled to a file 
    400      * @param image the original image 
    401      * @param size the new size 
    402      * @param outputFile the output file 
    403      * @param type the type of the image 
    404      * @throws Exception 
    405      */ 
    406     public static void createThumbnail(Image image, Dimension size, File outputFile, String type) throws Exception{ 
    407       if (TYPE_GIF.equalsIgnoreCase(type)) 
    408       { 
    409         JimiRasterImage raster = createThumbnail(image, size); 
    410         FileOutputStream out = new FileOutputStream(outputFile); 
    411  
    412         // change the raster image to 256 colors 
    413         Quant q = new Quant(raster); 
    414         q.init(); 
    415         BufferedImage iout = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_3BYTE_BGR); 
    416  
    417         int w = raster.getWidth(); 
    418         int h = raster.getHeight(); 
    419  
    420         int pixels[][] = getPixels(raster); 
    421         for (int x = w; x-- > 0; ) { 
    422             for (int y = h; y-- > 0; ) { 
    423                 iout.setRGB(x, y, q.convert(pixels[x][y])); 
    424             } 
    425         } 
    426  
    427         GifEncoder ge = new GifEncoder(iout, out); 
    428         ge.encode(); 
    429       } 
    430       else 
    431       { 
    432         JimiRasterImage raster = createThumbnail(image, size); 
    433         FileOutputStream fos = new FileOutputStream(outputFile); 
    434         Jimi.putImage(type, raster, fos); 
    435         fos.flush(); 
    436         fos.close(); 
    437       } 
    438     } 
    439  
    440     /** 
    441      * Create a Thumbnail out of an file with a fixed dimension 
    442      * @param image The original image 
    443      * @param size the thumbnail size 
    444      * @param outputFile the output file 
    445      * @param type the type of the image (example: image/jpeg) 
    446      * @throws Exception 
    447      */ 
    448     public static void createThumbnail(File image, Dimension size, File outputFile, String type) throws Exception{ 
    449         createThumbnail(new ImageIcon(image.getPath()).getImage(), size, outputFile, type); 
    450     } 
    451  
    452  
    453     /** 
    454299     * @param image the original file 
    455300     * @return an image object 
Note: See TracChangeset for help on using the changeset viewer.