Created
June 5, 2013 22:05
-
-
Save beranradek/5717712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.examples.img | |
import java.io.File | |
import scala.sys.process._ | |
class ImageMagickConverter(convertExec: String) { | |
def resizeImage(in: File, out: File, width: Int, height: Int, quality: Int = ImageMagickConverter.DefaultQuality): Boolean = { | |
val qual = if (quality < 0) ImageMagickConverter.DefaultQuality else if (quality > 100) 100 else quality | |
val inAbsPath = in.getAbsolutePath() | |
val outAbsPath = out.getAbsolutePath() | |
val cmd = s"${convertExec} -geometry ${width}x${height} -quality ${qual} ${inAbsPath} ${outAbsPath}" | |
val exitCode = cmd.! | |
exitCode == 0 | |
} | |
} | |
object ImageMagickConverter { | |
val DefaultQuality = 80 | |
def main(args: Array[String]) { | |
println(new ImageMagickConverter("""c:\programy\portable\ImageMagick-6.8.5-10\convert.exe""") | |
.resizeImage(new File("""c:\Radek\obrazky\conectarok_1328754878_49.jpg"""), | |
new File("""c:\Radek\obrazky\conectarok_1328754878_49-out.jpg"""), 336, 210)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment