use of org.fagu.fmv.im.ImageMetadatas in project fmv by f-agu.
the class TimeOffsetImageComparatorTestCase method mockImage.
/**
* @param time
* @param device
* @param model
* @param fileName
* @return
*/
private FileFinder<Image>.InfosFile mockImage(long time, String device, String model, String fileName) {
Image image = mock(Image.class);
ImageMetadatas imageMetadatas = mock(ImageMetadatas.class);
File file = mock(File.class);
doReturn(time).when(image).getTime();
doReturn(imageMetadatas).when(image).getMetadatas();
doReturn(new Date(time)).when(imageMetadatas).getDate();
if (device != null) {
doReturn(device).when(imageMetadatas).getDevice();
}
if (model != null) {
doReturn(model).when(imageMetadatas).getDeviceModel();
}
FileFinder<Image>.InfosFile infosFile = mock(InfosFile.class);
doReturn(image).when(infosFile).getMain();
doReturn(file).when(image).getFile();
doReturn(fileName).when(file).getName();
return infosFile;
}
use of org.fagu.fmv.im.ImageMetadatas in project fmv by f-agu.
the class ConsoleOutput method forOutput.
/**
* @param fileSource
* @param fromFile
* @return
*/
public static String forOutput(FileSource fileSource, File fromFile) {
StringBuilder buf = new StringBuilder(100);
buf.append(StringUtils.rightPad(Integer.toString(fileSource.getNumber()), 3)).append(' ').append(' ');
FileType fileType = fileSource.getFileType();
if (fileType != null) {
buf.append(fileType.name().charAt(0)).append(' ');
}
String meta = null;
if (fileSource.isImage()) {
ImageMetadatas imageMetadatas = fileSource.getImageMetadatas();
if (imageMetadatas != null) {
meta = imageMetadatas.getDimension().toString();
}
}
if (fileSource.isAudioOrVideo()) {
MovieMetadatas videoMetadatas = fileSource.getVideoMetadatas();
if (videoMetadatas != null) {
AudioStream audioStream = videoMetadatas.getAudioStream();
VideoStream videoStream = videoMetadatas.getVideoStream();
if (videoStream != null) {
Optional<Duration> duration = videoStream.duration();
String sd = duration.isPresent() ? duration.get().toString() : "";
meta = videoStream.size().toString() + " " + sd;
} else if (audioStream != null) {
Optional<Duration> duration = audioStream.duration();
meta = duration.isPresent() ? duration.get().toString() : "";
}
}
}
String subPath = null;
if (fromFile != null) {
subPath = StringUtils.substringAfter(fileSource.getFile().getPath(), fromFile.getPath() + File.separator);
} else {
subPath = fileSource.getFile().getName();
}
buf.append(StringUtils.rightPad(meta, 25)).append(' ').append(' ').append(subPath);
return buf.toString();
}
Aggregations