I have Kafka messages sending face of the person in crowd. I want to crop a specific portion of this image based on co-ordinates provided. How can I do this in NiFi? Do I need to use imagemagick on Windows NT and in linux the following command: mogrify -crop {Width}x{Height}+{X}+{Y} +repage image.png?
Execute this command using - ExecuteStreamCommand processor?
I refer to : Command line batch image cropping tool
you can use ExecuteGroovyScript
processor with following code:
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
def ff = session.get()
if(!ff)return
ff.write{rawIn, rawOut->
BufferedImage img = ImageIO.read(rawIn) //read image from flowfile input stream
def x=100,y=200,endX=800,endY=600
img = img.getSubimage(x, y, endX, endY) //crop
ImageIO.write(img, "png", rawOut) //write transformed image into flowfile as PNG
}
REL_SUCCESS << ff //transfer to success