Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.