Skip to content

Commit

Permalink
do not use File
Browse files Browse the repository at this point in the history
  • Loading branch information
yagee-de committed Jul 21, 2023
1 parent f41dfa4 commit 4df0064
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/org/mycore/imagetiler/MCRImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.ByteChannel;
Expand Down Expand Up @@ -72,7 +71,7 @@
/**
* The <code>MCRImage</code> class describes an image with different zoom levels that can be accessed by its tiles.
* <p>
* The main purpose of this class is to provide a method to {@link #tile()} an image {@link File} of a MyCoRe derivate.
* The main purpose of this class is to provide a method to {@link #tile()} an image {@link Path} of a MyCoRe derivate.
* <p>
* The resulting file of the tile process is a standard ZIP file with the suffix <code>.iview2</code>.
* Use {@link #setTileDir(Path)} to specify a common directory where all images of all derivates are tiled. The resulting IView2 file
Expand Down Expand Up @@ -226,7 +225,7 @@ public static int getTileCount(final int imageWidth, final int imageHeight) {
}

/**
* returns a {@link File} object of the .iview2 file or the derivate folder.
* returns a {@link Path} object of the .iview2 file or the derivate folder.
*
* @param tileDir the base directory of all image tiles
* @param derivateID the derivate ID the image belongs to
Expand Down Expand Up @@ -563,9 +562,10 @@ public MCRTiledPictureProps tile(MCRTileEventHandler eventHandler) throws IOExce
}

private void setOrientation() {
long start = System.nanoTime();
short orientation = 1;
try {
Metadata metadata = ImageMetadataReader.readMetadata(imageFile.toFile());
try (var is = Files.newInputStream(imageFile)) {
Metadata metadata = ImageMetadataReader.readMetadata(is, Files.size(imageFile));
ExifIFD0Directory exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
if (exifIFD0Directory != null) {
LOGGER.info("Exif Directory found.");
Expand All @@ -577,7 +577,8 @@ private void setOrientation() {
//no orientation defined;
}
this.orientation = MCROrientation.fromExifOrientation(orientation);
LOGGER.info("Orientation for " + this.imageFile + ": " + this.orientation.name());
long end = System.nanoTime();
LOGGER.info("Orientation for {}: {} ({} ms)", this.imageFile, this.orientation.name(), (end - start) / 1e6);
}

protected MCROrientation getOrientation() {
Expand Down

0 comments on commit 4df0064

Please sign in to comment.