Search in sources :

Example 11 with Soft

use of org.fagu.fmv.soft.Soft in project fmv by f-agu.

the class PipeInOutTest method testPipeIn.

/**
 * @throws Exception
 */
@Test
public void testPipeIn() 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(destFile);
        try (InputStream inputStream = new FileInputStream(srcFile)) {
            convertSoft.withParameters(op.toList()).input(// <--------- in
            inputStream).execute();
        }
        assertEquals(EXPECTED_SHA1, sha1Of(destFile));
    } finally {
        srcFile.delete();
        destFile.delete();
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) Soft(org.fagu.fmv.soft.Soft) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 12 with Soft

use of org.fagu.fmv.soft.Soft in project fmv by f-agu.

the class PipeInOutTest method testPipe_no.

/**
 * @throws Exception
 */
@Test
public void testPipe_no() 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(destFile);
        convertSoft.withParameters(op.toList()).execute();
        assertEquals(EXPECTED_SHA1, sha1Of(destFile));
    } finally {
        srcFile.delete();
        destFile.delete();
    }
}
Also used : File(java.io.File) Soft(org.fagu.fmv.soft.Soft) Test(org.junit.Test)

Aggregations

Soft (org.fagu.fmv.soft.Soft)12 File (java.io.File)8 Test (org.junit.Test)7 SoftFound (org.fagu.fmv.soft.find.SoftFound)4 FMVExecuteException (org.fagu.fmv.soft.exec.exception.FMVExecuteException)3 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 StringJoiner (java.util.StringJoiner)2 Ignore (org.junit.Ignore)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 FileUtils (org.apache.commons.io.FileUtils)1 IMOperation (org.fagu.fmv.im.IMOperation)1 Convert (org.fagu.fmv.im.soft.Convert)1 Logger (org.fagu.fmv.mymedia.logger.Logger)1 Loggers (org.fagu.fmv.mymedia.logger.Loggers)1