use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class PipeInOutTest method testPipeOut.
/**
* @throws Exception
*/
@Test
public void testPipeOut() throws Exception {
File srcFile = ImageResourceUtils.extractFile("bad-ass-tattoo-fail.jpg");
File destFile = new File(srcFile.getPath() + ".piped." + FilenameUtils.getExtension(srcFile.getName()));
try {
Soft convertSoft = Convert.search();
IMOperation op = new IMOperation();
op.image(srcFile).autoOrient().quality(60D).image(// <-------- means standard output
"jpg:-");
try (OutputStream outputStream = new FileOutputStream(destFile)) {
convertSoft.withParameters(op.toList()).output(// <--------- out
outputStream).execute();
}
assertEquals(EXPECTED_SHA1, sha1Of(destFile));
} finally {
srcFile.delete();
destFile.delete();
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class PipeInOutTest method testPipeInOut.
/**
* @throws Exception
*/
@Test
public void testPipeInOut() throws Exception {
File srcFile = ImageResourceUtils.extractFile("bad-ass-tattoo-fail.jpg");
File destFile = new File(srcFile.getPath() + ".piped." + FilenameUtils.getExtension(srcFile.getName()));
try {
Soft convertSoft = Convert.search();
IMOperation op = new IMOperation();
// <-------- means standard input
op.image("-").autoOrient().quality(60D).image(// <-------- means standard output
"jpg:-");
try (InputStream inputStream = new FileInputStream(srcFile);
OutputStream outputStream = new FileOutputStream(destFile)) {
convertSoft.withParameters(op.toList()).input(// <--------- in
inputStream).output(// <--------- out
outputStream).execute();
}
assertEquals(EXPECTED_SHA1, sha1Of(destFile));
} finally {
srcFile.delete();
destFile.delete();
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class ConvertSoftProviderTestCase method test.
@Test
@Ignore
public void test() {
Soft soft = Convert.search();
for (SoftFound softFound : soft.getFounds()) {
System.out.println(softFound.getLocalizedBy());
System.out.println(softFound + " / " + softFound.getReason());
System.out.println();
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class GSExceptionKnowAnalyzeTestCase method runPdfToImage.
// *************************************
/**
* @param srcResource
* @param expectedMessage
* @param consumer
* @throws IOException
*/
private void runPdfToImage(String srcResource, String expectedMessage, Consumer<SoftExecutor> consumer) throws IOException {
File folder = new File(System.getProperty("java.io.tmpdir"), "gs-pdf2img-test");
try {
FileUtils.deleteDirectory(folder);
folder.mkdirs();
File srcFile = srcResource != null ? Resource.extract(folder, srcResource) : folder;
File outFile = new File(srcFile.getPath() + ".jpg");
try {
Soft gsSoft = GS.search();
List<String> list = new ArrayList<>();
list.add("-sDEVICE=png16m");
list.add("-sOutputFile=" + outFile.getPath());
list.add("-r200");
list.add("-dNOPAUSE");
list.add("-dBATCH");
list.add("-dSAFER");
list.add("-dFirstPage=1");
list.add("-dLastPage=1");
list.add("-dUseCropBox");
list.add(srcFile.getAbsolutePath());
SoftExecutor customizeExecutor = gsSoft.withParameters(list).workingDirectory(srcFile.getParentFile());
// .logCommandLine(System.out::println);
if (consumer != null) {
consumer.accept(customizeExecutor);
}
customizeExecutor.execute();
fail();
} catch (FMVExecuteException e) {
if (e.isKnown()) {
assertEquals(expectedMessage, e.getExceptionKnown().toString());
} else {
new NestedException(e).messageToLines().forEach(System.out::println);
throw e;
}
}
} finally {
FileUtils.deleteDirectory(folder);
}
}
use of org.fagu.fmv.soft.Soft in project fmv by f-agu.
the class JavaSoftProviderTestCase method testFind.
/**
*/
@Test
@Ignore
public void testFind() {
Soft java = Java.search();
for (SoftFound softFound : java.getFounds()) {
System.out.println(softFound);
}
System.out.println();
System.out.println(java);
}
Aggregations