- /**
- * 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);
- File dir = new File(iconFile.getParent());
- if (dir != null && !dir.exists()) {
- dir.mkdirs();
- }
- processor.writeScaledData(iconFile, "JPEG");
- return iconStoragePath;
- }
-
- /**
- * Make the resized file.
- * @param filePath
- * @param imageFile
- * @param processor
- * @return
- * @throws MediaExc
- * @throws IOException
- */
- private String doImageScaling(String filePath, File imageFile, ImageProcessor processor) throws MediaExc, IOException {
- // get a file path where the the original image should be saved if image resizing is turned on
- String imagesOriginalDir = configuration.getString("Producer.ImagesOriginalDir.Path");
- String imagesOriginalDirRelPath = configuration.getString("Producer.ImagesOriginalDir.RelPath");
- String imageOriginalFilePath = imagesOriginalDir + filePath;
- String imageOriginalRelPath = imagesOriginalDirRelPath + filePath;
- File originalFile = new File(imageOriginalFilePath);
- processor.descaleImage(maxSize, minDescaleRatio, minDescaleReduction);
- File originalDir = new File(originalFile.getParent());
- if (originalDir != null && !originalDir.exists()) {
- originalDir.mkdirs();
- }
- if (!originalFile.exists()) {
- FileRoutines.copy(imageFile, originalFile);
- reportChange(originalFile.getAbsolutePath());
- }
- // yoss: don't write the scaled data again if it's the same size as
- // the file that's there right now. Image producer runs are 4 times
- // faster this way.
- if (processor.getScaledFileSize() != imageFile.length()) {
- processor.writeScaledData(imageFile, "JPEG");
- }
- return imageOriginalRelPath;
- }