Skip to content

Instantly share code, notes, and snippets.

@youribonnaffe
Created April 7, 2014 08:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save youribonnaffe/10016567 to your computer and use it in GitHub Desktop.
Resize images from size in HTML
@Grab(group='org.ccil.cowan.tagsoup',
module='tagsoup', version='1.2' )
def tagsoupParser = new org.ccil.cowan.tagsoup.Parser()
def slurper = new XmlSlurper(tagsoupParser)
def htmlParser = slurper.parseText(new File('file.html').text)
htmlParser.'**'.findAll{ it.name() == 'img'}.each {
if(it.@width != "") {
println "Resizing ${it.@src} to width ${it.@width}"
def p = "convert ${it.@src} -resize ${it.@width} ${it.@src}".execute()
p.waitFor()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment