Resize images from size in HTML
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
@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