+ String iconPath = getBaseIconStoragePath() + fileBasePath + ".jpg";
+ String iconStoragePath = doIconScaling(processor, iconPath);
+ anImageEntity.setFieldValue("icon_height", new Integer(processor.getScaledHeight()).toString());
+ anImageEntity.setFieldValue("icon_width", new Integer(processor.getScaledWidth()).toString());
+ anImageEntity.setFieldValue("icon_path", iconPath);
+
+ if (scaleImages) {
+ String imageOriginalRelPath = doImageScaling(filePath, imageFile, processor);
+ anImageEntity.setFieldValue("original_file_path", imageOriginalRelPath);
+ anImageEntity.setFieldValue("img_height", Integer.toString(processor.getScaledHeight()));
+ anImageEntity.setFieldValue("img_width", Integer.toString(processor.getScaledWidth()));
+ } else {
+ anImageEntity.setFieldValue("img_height", new Integer(processor.getHeight()).toString());
+ anImageEntity.setFieldValue("img_width", new Integer(processor.getWidth()).toString());
+ }
+ processor.cleanup();
+ anImageEntity.setFieldValue("publish_path", filePath);
+ anImageEntity.update();
+ reportChange(iconStoragePath);
+ reportChange(imageFilePath);
+ }
+ }
+ catch(Throwable t) {
+ logger.error("MediaHandlerImagesExtern.execute: " + t.getMessage(), t);
+ throw new MediaFailure(t.getMessage(), t);
+ }
+ }
+
+ /**
+ * Scale an icon image and write it to the file system.
+ * @param processor
+ * @param iconPath
+ * @return
+ * @throws MediaExc
+ */
+ private String doIconScaling(ImageProcessor processor, String iconPath) throws MediaExc {
+ String iconStoragePath = configuration.getString("Producer.StorageRoot") + iconPath;
+ File iconFile = new File(iconStoragePath);
+ processor.descaleImage(maxIconSize, minDescaleRatio, minDescaleReduction);