Hallo,
auf meinem Mac - Laufwerk habe ich ein Bild, welches hochkant ist.
Das Bild möchte ich nun hochladen und verwende u.a. folgende Funktion (kleiner machen etc.)...
Das Problem scheint mir nun, dass hier das Bild nicht so betrachtet wird, wie es auf meinem Laufwerk ist.
Ggf. speichert es auf meinem Mac die EXIF Informationen so ab, sodass das Bild in meinem File Explorer entsprechend angezeigt wird.
Lade ich das Bild nun hoch, dann ist es nicht hochkant.
Kennt jemand das Problem?
Wie kann man das lösen?
auf meinem Mac - Laufwerk habe ich ein Bild, welches hochkant ist.
Das Bild möchte ich nun hochladen und verwende u.a. folgende Funktion (kleiner machen etc.)...
Das Problem scheint mir nun, dass hier das Bild nicht so betrachtet wird, wie es auf meinem Laufwerk ist.
Ggf. speichert es auf meinem Mac die EXIF Informationen so ab, sodass das Bild in meinem File Explorer entsprechend angezeigt wird.
Lade ich das Bild nun hoch, dann ist es nicht hochkant.
Kennt jemand das Problem?
Java:
/**
* InputStream ausgeben
*
* @throws IOException
*/
public static BufferedImage convertByteArrayToBufferedImage(byte[] byteArray) throws IOException {
InputStream is = new ByteArrayInputStream(byteArray);
BufferedImage newBi = ImageIO.read(is);
return newBi;
}
Java:
public ByteArrayOutputStream resizePicture(byte[] inputStreamOriginal, int width, int height)
throws IOException {
BufferedImage bimg = StorageHelper.convertByteArrayToBufferedImage(inputStreamOriginal);
int originalWidth = bimg.getWidth();
int originalHeight = bimg.getHeight();
// Nur verkleinern, wenn das Original Bild wirklich größer ist:
if (originalWidth > width || originalHeight > height) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Thumbnails.of(bimg).size(width, height).outputFormat("jpg").toOutputStream(outputStream);
return outputStream;
}
return null;
}
Wie kann man das lösen?