Project

General

Profile

Revision 0ef925f0

ID0ef925f085f5814def94328efa8dd204ac78bd12
Parent 9e390a27
Child 68ce58c8

Added by Andreas Müller over 3 years ago

ref #5744 latest changes cyprus images

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusImagesActivator.java
24 24
import java.util.regex.Matcher;
25 25
import java.util.regex.Pattern;
26 26

  
27
import org.apache.commons.imaging.ImageReadException;
28
import org.apache.commons.imaging.Imaging;
29
import org.apache.commons.imaging.common.GenericImageMetadata.GenericImageMetadataItem;
30
import org.apache.commons.imaging.common.ImageMetadata;
31
import org.apache.commons.imaging.common.ImageMetadata.ImageMetadataItem;
27 32
import org.apache.log4j.Logger;
28
import org.apache.sanselan.ImageReadException;
29
import org.apache.sanselan.Sanselan;
30
import org.apache.sanselan.common.IImageMetadata;
31
import org.apache.sanselan.common.ImageMetadata.Item;
32 33
import org.joda.time.DateTime;
33 34
import org.joda.time.format.DateTimeFormat;
34 35
import org.joda.time.format.DateTimeFormatter;
......
195 196
        String artistStr = null;
196 197
        String created = null;
197 198
        try{
198
            IImageMetadata metadata = Sanselan.getMetadata(file);
199
            ArrayList<?> items = metadata.getItems();
199
//            IImageMetadata metadata = Sanselan.getMetadata(file);
200
            ImageMetadata metadata = Imaging.getMetadata(file);
201
            List<? extends ImageMetadataItem> items = metadata.getItems();
200 202
            for (Object object : items){
201
                Item item = (Item) object;
203
                ImageMetadataItem metadataItem = (ImageMetadataItem) object;
202 204
//                System.out.println(item.getKeyword() +  ":    " + item.getText());
203
                String keyword = item.getKeyword().toLowerCase();
204
                String value =removeQuots(item.getText());
205

  
206
                if("keywords".equals(keyword)){
207
                    String[] splits = value.split(":");
208
                    if (splits.length == 2){
209
                        keywords.put(splits[0].trim().toLowerCase(), splits[1].trim());
210
                    }else{
211
                        logger.warn("Keyword has not correct format and can not be parsed: " + value +  "  for file " + fileName);
205
                if (metadataItem instanceof GenericImageMetadataItem){
206
                    GenericImageMetadataItem item = (GenericImageMetadataItem) metadataItem;
207

  
208
                    String keyword = item.getKeyword().toLowerCase();
209
                    String value =removeQuots(item.getText());
210

  
211
                    if("keywords".equals(keyword)){
212
                        String[] splits = value.split(":");
213
                        if (splits.length == 2){
214
                            keywords.put(splits[0].trim().toLowerCase(), splits[1].trim());
215
                        }else{
216
                            logger.warn("Keyword has not correct format and can not be parsed: " + value +  "  for file " + fileName);
217
                        }
218
                    }else if ("Copyright Notice".equalsIgnoreCase(keyword)){
219
                        copyright = value;
220
                    }else if ("artist".equals(keyword)){
221
                        artistStr = value;
222
                    }else if ("date time original".equalsIgnoreCase(item.getKeyword())){
223
                        created = value;
212 224
                    }
213
                }else if ("Copyright Notice".equalsIgnoreCase(keyword)){
214
                    copyright = value;
215
                }else if ("artist".equals(keyword)){
216
                    artistStr = value;
217
                }else if ("date time original".equalsIgnoreCase(item.getKeyword())){
218
                    created = value;
219 225
                }
220 226
            }
221 227
        } catch (ImageReadException | IOException e1) {
222 228
            logger.warn("       Problem (" + e1.getMessage() + ") when reading metadata from file: " + fileName);
229
            e1.printStackTrace();
223 230
        }
224 231

  
225 232

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)