Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created July 18, 2015 13:34
Show Gist options
  • Select an option

  • Save Sciss/19ee848622a05010b534 to your computer and use it in GitHub Desktop.

Select an option

Save Sciss/19ee848622a05010b534 to your computer and use it in GitHub Desktop.
import sys.process._
def maxSize(dir: File): (Int, Int) = {
val xs = dir.children(_.ext.toLowerCase == "png")
((0, 0) /: xs) { case ((w, h), x) =>
val txt = Seq("identify", x.path).!!
val words = txt.split(" ")
require(words(1) == "PNG")
val sub = words(2)
val j = sub.indexOf('x')
val w1 = sub.substring(0, j).toInt
val h1 = sub.substring(j + 1).toInt
math.max(w, w1) -> math.max(h, h1)
}
}
val dir = userHome/"Documents"/"devel"/"Grenzwerte"/"image_out"
assert(dir.isDirectory)
maxSize(dir) // (1395,1403)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment