Skip to content
Snippets Groups Projects
Commit 1185f667 authored by srosse's avatar srosse
Browse files

OO-2061: add getSize for file, wording, german and english missing keys

parent 2444c1d9
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,11 @@ public class ImageHelperBean implements ImageService { ...@@ -49,6 +49,11 @@ public class ImageHelperBean implements ImageService {
return imageHelperServiceProvider.getSize(image, suffix); return imageHelperServiceProvider.getSize(image, suffix);
} }
@Override
public Size getSize(File image, String suffix) {
return imageHelperServiceProvider.getSize(image, suffix);
}
@Override @Override
public boolean cropImage(File image, File cropedImage, Crop cropSelection) { public boolean cropImage(File image, File cropedImage, Crop cropSelection) {
return imageHelperServiceProvider.cropImage(image, cropedImage, cropSelection); return imageHelperServiceProvider.cropImage(image, cropedImage, cropSelection);
......
...@@ -43,6 +43,8 @@ public interface ImageHelperSPI { ...@@ -43,6 +43,8 @@ public interface ImageHelperSPI {
public Size getSize(VFSLeaf image, String suffix); public Size getSize(VFSLeaf image, String suffix);
public Size getSize(File image, String suffix);
public boolean cropImage(File image, File cropedImage, Crop cropSelection); public boolean cropImage(File image, File cropedImage, Crop cropSelection);
public Size scaleImage(File image, String extension, File scaledImage, int maxWidth, int maxHeight, boolean fill); public Size scaleImage(File image, String extension, File scaledImage, int maxWidth, int maxHeight, boolean fill);
......
...@@ -39,6 +39,8 @@ public interface ImageService { ...@@ -39,6 +39,8 @@ public interface ImageService {
public Size getSize(VFSLeaf image, String suffix); public Size getSize(VFSLeaf image, String suffix);
public Size getSize(File image, String suffix);
public boolean cropImage(File image, File cropedImage, Crop cropSelection); public boolean cropImage(File image, File cropedImage, Crop cropSelection);
public Size scaleImage(File image, String extension, File scaledImage, int maxWidth, int maxHeight, boolean fill); public Size scaleImage(File image, String extension, File scaledImage, int maxWidth, int maxHeight, boolean fill);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
package org.olat.core.commons.services.image.spi; package org.olat.core.commons.services.image.spi;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Iterator; import java.util.Iterator;
...@@ -59,6 +61,17 @@ public abstract class AbstractImageHelper implements ImageHelperSPI { ...@@ -59,6 +61,17 @@ public abstract class AbstractImageHelper implements ImageHelperSPI {
return size; return size;
} }
public Size getSize(File image, String suffix) {
Size size = null;
if(StringHelper.containsNonWhitespace(suffix)) {
size = getImageSize(image, suffix);
}
if(size == null) {
size = getImageSizeFallback(image);
}
return size;
}
private Size getImageSizeFallback(VFSLeaf media) { private Size getImageSizeFallback(VFSLeaf media) {
InputStream fileStream = null; InputStream fileStream = null;
BufferedImage imageSrc = null; BufferedImage imageSrc = null;
...@@ -117,5 +130,51 @@ public abstract class AbstractImageHelper implements ImageHelperSPI { ...@@ -117,5 +130,51 @@ public abstract class AbstractImageHelper implements ImageHelperSPI {
} }
return result; return result;
} }
private Size getImageSize(File media, String suffix) {
Size result = null;
Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(suffix);
if (iter.hasNext()) {
ImageReader reader = iter.next();
try (InputStream mediaStream = new FileInputStream(media);
ImageInputStream stream = new MemoryCacheImageInputStream(mediaStream)){
reader.setInput(stream);
int readerMinIndex = reader.getMinIndex();
int width = reader.getWidth(readerMinIndex);
int height = reader.getHeight(readerMinIndex);
result = new Size(width, height, 0, 0, false);
} catch (IOException e) {
log.error(e.getMessage());
} finally {
reader.dispose();
}
} else {
log.error("No reader found for given format: " + suffix);
}
return result;
}
private Size getImageSizeFallback(File media) {
BufferedImage imageSrc = null;
try (InputStream fileStream = new FileInputStream(media)) {
imageSrc = ImageIO.read(fileStream);
if (imageSrc == null) {
// happens with faulty Java implementation, e.g. on MacOSX
return null;
}
double realWidth = imageSrc.getWidth();
double realHeight = imageSrc.getHeight();
return new Size((int)realWidth, (int)realHeight, 0, 0, false);
} catch (IOException e) {
// log error, don't do anything else
log.error("Problem while setting image size to fit for resource::" + media, e);
return null;
} finally {
if (imageSrc != null) {
imageSrc.flush();
}
}
}
} }
#Thu Jun 02 15:29:28 CEST 2016 #Wed Jun 15 14:04:13 CEST 2016
add.solution=Add solution add.solution=Add solution
add.task=Add task add.task=Add task
assessment.group.tool=Grade group assessment.group.tool=Grade group
...@@ -214,6 +214,7 @@ solution.list.description=Select "$\:add.solution" or "$\:create.solution" to ad ...@@ -214,6 +214,7 @@ solution.list.description=Select "$\:add.solution" or "$\:create.solution" to ad
solution.list.title=Upload sample solutions solution.list.title=Upload sample solutions
solution.title=Title solution.title=Title
submission=Submission submission=Submission
submission.add.title=Add document
submission.confirmation=The submission of $numberOfFiles file(s) ($filename) for $first $last ($email) at $date, $time has been confirmed. submission.confirmation=The submission of $numberOfFiles file(s) ($filename) for $first $last ($email) at $date, $time has been confirmed.
submission.email.confirmation=Send text additionally as email submission.email.confirmation=Send text additionally as email
submission.enabled=Enable solution drop box for participants submission.enabled=Enable solution drop box for participants
...@@ -243,6 +244,7 @@ task.assignment.error=Unexpected error\! ...@@ -243,6 +244,7 @@ task.assignment.error=Unexpected error\!
task.assignment.type=$org.olat.course.nodes.ta\:form.task.type task.assignment.type=$org.olat.course.nodes.ta\:form.task.type
task.assignment.type.auto=$org.olat.course.nodes.ta\:form.task.type.auto task.assignment.type.auto=$org.olat.course.nodes.ta\:form.task.type.auto
task.assignment.type.manual=$org.olat.course.nodes.ta\:form.task.type.manual task.assignment.type.manual=$org.olat.course.nodes.ta\:form.task.type.manual
task.coach.allowed.upload=Coaches can upload tasks
task.description=Description task.description=Description
task.execution=Task execution task.execution=Task execution
task.execution.group=as a group task.execution.group=as a group
......
#Thu Apr 21 15:21:09 CEST 2016 #Wed Jun 15 14:04:51 CEST 2016
add.track=Untertitel hinzuf\u00FCgen add.track=Untertitel hinzuf\u00FCgen
admin.config.enable=Videoressource einschalten admin.config.enable=Videoressource einschalten
admin.config.title=Videokonfiguration admin.config.title=Videokonfiguration
...@@ -6,24 +6,23 @@ admin.config.transcoding=Transcoding aktivieren ...@@ -6,24 +6,23 @@ admin.config.transcoding=Transcoding aktivieren
admin.config.videoNode=Video Kursbaustein aktivieren admin.config.videoNode=Video Kursbaustein aktivieren
admin.menu.title=Video admin.menu.title=Video
admin.menu.title.alt=Konfiguration der Video-Resource admin.menu.title.alt=Konfiguration der Video-Resource
poster.select=Poster ausw\u00E4hlen listing.viewing.counter={0} Aufrufe
poster.help=Bild vom Typ JPG. Das Bild sollte die identischen Masse wie das Original Video haben (Selbe H\u00F6he und Weite in Pixel).
poster.error.filetype=F\u00FCr Poster Bild werden nur Bilder vom Typ JPG unterst\u00FCtzt. poster.error.filetype=F\u00FCr Poster Bild werden nur Bilder vom Typ JPG unterst\u00FCtzt.
poster.help=Bild vom Typ JPG. Das Bild sollte die identischen Masse wie das Original Video haben (Selbe H\u00F6he und Weite in Pixel).
poster.select=Poster ausw\u00E4hlen
quality.master=Master video
quality.resolution.1080=1080p Full-HD
quality.resolution.2160=2160p 4K
quality.resolution.240=240p
quality.resolution.360=360p
quality.resolution.480=480p
quality.resolution.720=720p HD
quality.table.header.dimension=Dimension quality.table.header.dimension=Dimension
quality.table.header.format=Format quality.table.header.format=Format
quality.table.header.size=Gr\u00F6sse
quality.table.header.resolution=Aufl\u00F6sung quality.table.header.resolution=Aufl\u00F6sung
quality.table.header.size=Gr\u00F6sse
quality.table.header.view=ansehen quality.table.header.view=ansehen
quality.view=vorschau quality.view=vorschau
quality.master=Master video
quality.resolution.2160=2160p 4K
quality.resolution.1080=1080p Full-HD
quality.resolution.720=720p HD
quality.resolution.480=480p
quality.resolution.360=360p
quality.resolution.240=240p
transcoding.waiting=In Warteschlange
transcoding.processing=In Bearbeitung
tab.video.metaDataConfig=Metadaten tab.video.metaDataConfig=Metadaten
tab.video.posterConfig=Poster konfigurieren tab.video.posterConfig=Poster konfigurieren
tab.video.qualityConfig=Videoqualit\u00E4ten tab.video.qualityConfig=Videoqualit\u00E4ten
...@@ -41,6 +40,8 @@ track.table.label=Untertitel ...@@ -41,6 +40,8 @@ track.table.label=Untertitel
track.upload=Hochladen track.upload=Hochladen
track.upload.error.nofile=Bitte w\u00E4hlen Sie eine Datei aus. track.upload.error.nofile=Bitte w\u00E4hlen Sie eine Datei aus.
track.upload.error.nolang=Bitte w\u00E4hlen Sie eine Sprache aus dieser Liste aus track.upload.error.nolang=Bitte w\u00E4hlen Sie eine Sprache aus dieser Liste aus
transcoding.processing=In Bearbeitung
transcoding.waiting=In Warteschlange
video.config.creationDate=Erstellungs Datum video.config.creationDate=Erstellungs Datum
video.config.description=Beschreibung video.config.description=Beschreibung
video.config.fileSize=Gr\u00F6sse der Videodatei video.config.fileSize=Gr\u00F6sse der Videodatei
...@@ -51,10 +52,10 @@ video.config.poster.hint=Hier legen Sie fest welches Bild sowohl als Poster / St ...@@ -51,10 +52,10 @@ video.config.poster.hint=Hier legen Sie fest welches Bild sowohl als Poster / St
video.config.poster.replace=Poster ersetzen video.config.poster.replace=Poster ersetzen
video.config.poster.upload=Poster hochladen video.config.poster.upload=Poster hochladen
video.config.ratio=Seitenverh\u00E4ltnis video.config.ratio=Seitenverh\u00E4ltnis
video.config.track.error.type=nur *.vtt and *.srt Dateien sind erlaubt
video.config.track.table.file=Untertitel Datei video.config.track.table.file=Untertitel Datei
video.config.tracks=Verf\u00FCgbare Untertiteldateien video.config.tracks=Verf\u00FCgbare Untertiteldateien
video.config.tracks.table.add=hinzuf\u00FCgen video.config.tracks.table.add=hinzuf\u00FCgen
video.config.tracks.table.delete=l\u00F6schen video.config.tracks.table.delete=l\u00F6schen
video.config.tracks.table.lang=Sprache video.config.tracks.table.lang=Sprache
video.config.width=Breite video.config.width=Breite
listing.viewing.counter={0} Aufrufe
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment