# Help request: Capture images and blit them together with contrib-image-tools (jimp)

**URL:** <https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363>\
**Category:** General\
**Created:** [27 January 2022 19:02 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363 "2022-01-27T19:02:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [27 January 2022 19:02 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/1 "2022-01-27T19:02:31Z")

</div>

Having a little trouble getting and 'blitting' some images together. I suspect the source type is incorrect and I just don't know enough to work out where.

Seeing as a picture speaks a thousand words, here's a video demonstration of the problem and what I've tried: [Node-RED flow assistance request - contrib-image-tools - YouTube](https://www.youtube.com/watch?v=yu1ztBD5C1k)

And here is the flow:

```auto
[{"id":"66a0ab4cb637754e","type":"inject","z":"a77b2b14.9407e8","name":"Capture 3 pics","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"num","x":270,"y":260,"wires":[["18cca55a6cfbac35","e85a392a3bfd08d3"]]},{"id":"18cca55a6cfbac35","type":"function","z":"a77b2b14.9407e8","name":"1st img","func":"const trigger = parseInt(msg.payload)\nif (trigger == 1) {\n\n// file path with / at the end\nvar path = \"/home/pi/node-red-static/\"; // This is the path\nmsg.payload = path + \"frame1.jpg\"; // pass the full path to payload for the exec node to add to the end of the command\nmsg.frame1 = msg.payload;\n return msg;}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":260,"wires":[["038ddae2685057aa"]]},{"id":"e85a392a3bfd08d3","type":"delay","z":"a77b2b14.9407e8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":260,"y":320,"wires":[["d2c8a6f52703ec05","320c83e6b860d63c"]]},{"id":"d2c8a6f52703ec05","type":"function","z":"a77b2b14.9407e8","name":"2st img","func":"const trigger = parseInt(msg.payload)\nif (trigger == 1) {\n\n// file path with / at the end\nvar path = \"/home/pi/node-red-static/\"; // This is the path\nmsg.payload = path + \"frame2.jpg\"; // pass the full path to payload for the exec node to add to the end of the command\nmsg.frame2 = msg.payload;\n\n return msg;}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":320,"wires":[["03745879e42b832e"]]},{"id":"320c83e6b860d63c","type":"delay","z":"a77b2b14.9407e8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":260,"y":380,"wires":[["3b9a7e8d69e9c75c"]]},{"id":"3b9a7e8d69e9c75c","type":"function","z":"a77b2b14.9407e8","name":"3rd img","func":"const trigger = parseInt(msg.payload)\nif (trigger == 1) {\n\n// file path with / at the end\nvar path = \"/home/pi/node-red-static/\"; // This is the path\nmsg.payload = path + \"frame3.jpg\"; // pass the full path to payload for the exec node to add to the end of the command\nmsg.frame3 = msg.payload;\n\n return msg;}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":380,"wires":[["21d1ccee64dc4d18"]]},{"id":"8d58ddb71a7e5df1","type":"debug","z":"a77b2b14.9407e8","name":"frame grab","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":180,"wires":[]},{"id":"953d7669.9cbf78","type":"jimp-image","z":"a77b2b14.9407e8","name":"frame1","data":"payload","dataType":"msg","ret":"img","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"frame1","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":480,"y":580,"wires":[["837b82da.e1ddf"]]},{"id":"837b82da.e1ddf","type":"image viewer","z":"a77b2b14.9407e8","name":"","width":"80","data":"payload","dataType":"msg","active":true,"x":610,"y":580,"wires":[["9a147be1.7d1af8"]]},{"id":"dbb82ce3.015fd","type":"jimp-image","z":"a77b2b14.9407e8","name":"frame2","data":"payload","dataType":"msg","ret":"img","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"frame2","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":490,"y":680,"wires":[["7a25ce49.788e3"]]},{"id":"7a25ce49.788e3","type":"image viewer","z":"a77b2b14.9407e8","name":"","width":"80","data":"payload","dataType":"msg","active":true,"x":690,"y":680,"wires":[["9f823f06.0719c"]]},{"id":"9a147be1.7d1af8","type":"function","z":"a77b2b14.9407e8","name":"get sizes","func":"msg.width1 = msg.imageInfo.width;\nmsg.height1 = msg.imageInfo.height;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":580,"wires":[["6bdbca50.679ed4"]]},{"id":"9f823f06.0719c","type":"function","z":"a77b2b14.9407e8","name":"get sizes","func":"msg.width2 = msg.imageInfo.width;\nmsg.height2 = msg.imageInfo.height;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":680,"wires":[["21391c2bf0f20fbd"]]},{"id":"ad0be53d.59eba8","type":"function","z":"a77b2b14.9407e8","name":"Combined img params","func":"msg.width = msg.width1;\nmsg.height = msg.height1 + msg.height2 + msg.height3;\nmsg.height2and3 = msg.height2 + msg.height3;\nmsg.payload = {w: msg.width, h: msg.height}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":980,"wires":[["8c0d7a05.bcb2f8","5e0a149320a47b52"]]},{"id":"8c0d7a05.bcb2f8","type":"jimp-image","z":"a77b2b14.9407e8","name":"Combined image","data":"payload","dataType":"msg","ret":"img","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":490,"y":980,"wires":[["9917d983.f4d368"]]},{"id":"9917d983.f4d368","type":"jimp-image","z":"a77b2b14.9407e8","name":"blit image1","data":"combined","dataType":"msg","ret":"img","parameter1":"frame1","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"0","parameter3Type":"num","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width1","parameter6Type":"msg","parameter7":"height1","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":670,"y":980,"wires":[["d9d820c9.04114"]]},{"id":"25d4c9fe6464b803","type":"jimp-image","z":"a77b2b14.9407e8","name":"frame3","data":"payload","dataType":"msg","ret":"img","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"frame3","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":490,"y":780,"wires":[["8ce694f7ef87ae2f"]]},{"id":"8ce694f7ef87ae2f","type":"image viewer","z":"a77b2b14.9407e8","name":"","width":"80","data":"payload","dataType":"msg","active":true,"x":610,"y":780,"wires":[["8b89844c961f4e8a"]]},{"id":"8b89844c961f4e8a","type":"function","z":"a77b2b14.9407e8","name":"get sizes","func":"msg.width3 = msg.imageInfo.width;\nmsg.height3 = msg.imageInfo.height;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":780,"wires":[["ad0be53d.59eba8"]]},{"id":"038ddae2685057aa","type":"exec","z":"a77b2b14.9407e8","command":"ffmpeg -y -i rtsp://USERNAME:PASSWORD@IP-ADDRESS:554/live0.264 -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: Kitchen","x":630,"y":260,"wires":[["8d58ddb71a7e5df1","953d7669.9cbf78"],[],[]]},{"id":"2879d916.ae7e46","type":"image viewer","z":"a77b2b14.9407e8","name":"","width":"240","data":"combined","dataType":"msg","active":true,"x":1390,"y":160,"wires":[[]]},{"id":"2156fa27b67dfda8","type":"jimp-image","z":"a77b2b14.9407e8","name":"blit image3","data":"combined","dataType":"msg","ret":"img","parameter1":"frame3","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"height2and3","parameter3Type":"msg","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width3","parameter6Type":"msg","parameter7":"height3","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":1030,"y":980,"wires":[["2879d916.ae7e46"]]},{"id":"d9d820c9.04114","type":"jimp-image","z":"a77b2b14.9407e8","name":"blit image2","data":"combined","dataType":"msg","ret":"img","parameter1":"frame2","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"height1","parameter3Type":"msg","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width2","parameter6Type":"msg","parameter7":"height2","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":850,"y":980,"wires":[["2156fa27b67dfda8"]]},{"id":"5e0a149320a47b52","type":"debug","z":"a77b2b14.9407e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":860,"wires":[]},{"id":"9435702b.6e1c4","type":"inject","z":"a77b2b14.9407e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":520,"wires":[["dd869b1.00bf368"]]},{"id":"dd869b1.00bf368","type":"http request","z":"a77b2b14.9407e8","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://picsum.photos/200/300","tls":"","persist":false,"proxy":"","authType":"","x":140,"y":580,"wires":[["953d7669.9cbf78"]]},{"id":"6bdbca50.679ed4","type":"http request","z":"a77b2b14.9407e8","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://picsum.photos/200/300","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":680,"wires":[["dbb82ce3.015fd"]]},{"id":"21391c2bf0f20fbd","type":"http request","z":"a77b2b14.9407e8","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://picsum.photos/200/300","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":780,"wires":[["25d4c9fe6464b803"]]},{"id":"21d1ccee64dc4d18","type":"exec","z":"a77b2b14.9407e8","command":"ffmpeg -y -i rtsp://USERNAME:PASSWORD@IP-ADDRESS:5544/live1.264 -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: Live A","x":630,"y":380,"wires":[["25d4c9fe6464b803"],[],[]]},{"id":"03745879e42b832e","type":"exec","z":"a77b2b14.9407e8","command":"ffmpeg -y -i rtsp://USERNAME:PASSWORD@IP-ADDRESS:5544/live1.264 -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: CR2","x":630,"y":320,"wires":[["dbb82ce3.015fd"],[],[]]}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 22:10 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/2 "2022-01-27T22:10:47Z")

</div>

Here is a cleaner demo...

![chrome_joJhbCoyDw](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03752304be742e09304339238328a2be160d01bd.gif)

```auto
[{"id":"66a0ab4cb637754e","type":"inject","z":"42ea7bd7.2e3c24","name":"Capture 3 pics","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"path","v":"/home/pi/node-red-static/","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"num","x":590,"y":820,"wires":[["18cca55a6cfbac35"]]},{"id":"18cca55a6cfbac35","type":"function","z":"42ea7bd7.2e3c24","name":"Prep","func":"\nmsg.path1 = msg.path + \"frame1.jpg\"; \nmsg.path2 = msg.path + \"frame2.jpg\"; \nmsg.path3 = msg.path + \"frame3.jpg\"; \n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":820,"wires":[["d027f13d49df55fd"]]},{"id":"ad0be53d.59eba8","type":"function","z":"42ea7bd7.2e3c24","name":"Combined img params","func":"msg.width = msg.width1;\nmsg.height = msg.height1 + msg.height2 + msg.height3;\nmsg.height2and3 = msg.height2 + msg.height3;\nmsg.payload = {w: msg.width, h: msg.height}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":1140,"wires":[["8c0d7a05.bcb2f8"]]},{"id":"8c0d7a05.bcb2f8","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"Combined image","data":"payload","dataType":"msg","ret":"img","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":970,"y":1140,"wires":[["9917d983.f4d368"]]},{"id":"9917d983.f4d368","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"blit image1","data":"combined","dataType":"msg","ret":"img","parameter1":"frame1","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"0","parameter3Type":"num","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width1","parameter6Type":"msg","parameter7":"height1","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":1150,"y":1140,"wires":[["d9d820c9.04114"]]},{"id":"2879d916.ae7e46","type":"image viewer","z":"42ea7bd7.2e3c24","name":"","width":"240","data":"combined","dataType":"msg","active":true,"x":1730,"y":820,"wires":[[]]},{"id":"2156fa27b67dfda8","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"blit image3","data":"combined","dataType":"msg","ret":"img","parameter1":"frame3","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"height2and3","parameter3Type":"msg","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width3","parameter6Type":"msg","parameter7":"height3","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":1510,"y":1140,"wires":[["2879d916.ae7e46"]]},{"id":"d9d820c9.04114","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"blit image2","data":"combined","dataType":"msg","ret":"img","parameter1":"frame2","parameter1Type":"msg","parameter2":"0","parameter2Type":"num","parameter3":"height1","parameter3Type":"msg","parameter4":"0","parameter4Type":"num","parameter5":"0","parameter5Type":"num","parameter6":"width2","parameter6Type":"msg","parameter7":"height2","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"combined","sendPropertyType":"msg","parameterCount":7,"jimpFunction":"blit","selectedJimpFunction":{"name":"blit","fn":"blit","description":"blit the image with another Jimp image at x, y, optionally cropped","parameters":[{"name":"src","type":"","required":true,"hint":"the source image (a Jimp instance)","defaultType":"msg","defaultValue":"payload"},{"name":"x","type":"num","required":true,"hint":"the x position to blit the image"},{"name":"y","type":"num","required":true,"hint":"the y position to blit the image"},{"name":"srcx","type":"num","required":false,"hint":"the x position from which to crop the source image"},{"name":"srcy","type":"num","required":false,"hint":"the y position from which to crop the source image"},{"name":"srcw","type":"num","required":false,"hint":"the width to which to crop the source image"},{"name":"srch","type":"num","required":false,"hint":"the height to which to crop the source image"}]},"x":1330,"y":1140,"wires":[["2156fa27b67dfda8"]]},{"id":"ebb022f93478a173","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"buf > image","data":"payload","dataType":"msg","ret":"img","parameter1":"640","parameter1Type":"num","parameter2":"480","parameter2Type":"num","parameter3":"RESIZE_NEAREST_NEIGHBOR","parameter3Type":"resizeMode","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":3,"jimpFunction":"resize","selectedJimpFunction":{"name":"resize","fn":"resize","description":"resize the image. One of the w or h parameters can be set to automatic (\"Jimp.AUTO\" or -1).","parameters":[{"name":"w","type":"num|auto","required":true,"hint":"the width to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"h","type":"num|auto","required":true,"hint":"the height to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":1170,"y":820,"wires":[["85a820bfbfaaaa0b"]]},{"id":"e7fd1e7f401b0a9d","type":"image viewer","z":"42ea7bd7.2e3c24","name":"","width":"120","data":"frame1","dataType":"msg","active":true,"x":1550,"y":820,"wires":[["74897b6f4a2aa604"]]},{"id":"5ede3d1857ea25d2","type":"image viewer","z":"42ea7bd7.2e3c24","name":"","width":"120","data":"frame2","dataType":"msg","active":true,"x":1410,"y":900,"wires":[["511974dad5ea5ca6"]]},{"id":"e4bc06150d639772","type":"image viewer","z":"42ea7bd7.2e3c24","name":"","width":"120","data":"frame3","dataType":"msg","active":true,"x":1270,"y":980,"wires":[["ad0be53d.59eba8"]]},{"id":"85a820bfbfaaaa0b","type":"function","z":"42ea7bd7.2e3c24","name":"get sizes","func":"msg.width1 = msg.imageInfo.width;\nmsg.height1 = msg.imageInfo.height;\nmsg.frame1 = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":820,"wires":[["e7fd1e7f401b0a9d"]]},{"id":"8b46b674ded47a1a","type":"function","z":"42ea7bd7.2e3c24","name":"get sizes","func":"msg.width2 = msg.imageInfo.width;\nmsg.height2 = msg.imageInfo.height;\nmsg.frame2 = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1120,"y":900,"wires":[["5ede3d1857ea25d2"]]},{"id":"e0ed5cfc2e8c98ad","type":"function","z":"42ea7bd7.2e3c24","name":"get sizes","func":"msg.width3 = msg.imageInfo.width;\nmsg.height3 = msg.imageInfo.height;\nmsg.frame3 = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1120,"y":980,"wires":[["e4bc06150d639772"]]},{"id":"d027f13d49df55fd","type":"exec","z":"42ea7bd7.2e3c24","command":"ffmpeg -y -i https://miro.medium.com/max/1200/1*1BUIofZgqVuR6nj8LbrRtQ.jpeg -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: 1","x":920,"y":820,"wires":[["ebb022f93478a173"],[],[]]},{"id":"511974dad5ea5ca6","type":"exec","z":"42ea7bd7.2e3c24","command":"ffmpeg -y -i http://webcam01.ecn.purdue.edu/mjpg/video.mjpg -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: 3","x":740,"y":980,"wires":[["befc85876d0c7c36"],[],[]]},{"id":"74897b6f4a2aa604","type":"exec","z":"42ea7bd7.2e3c24","command":"ffmpeg -y -i https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Two_red_dice_01.svg/1200px-Two_red_dice_01.svg.png -vframes 1 -f image2pipe -vcodec png -","addpay":false,"append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Framegrab: 2","x":740,"y":900,"wires":[["62e4da15f75ae919"],[],[]]},{"id":"62e4da15f75ae919","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"buf > image","data":"payload","dataType":"msg","ret":"img","parameter1":"640","parameter1Type":"num","parameter2":"480","parameter2Type":"num","parameter3":"RESIZE_NEAREST_NEIGHBOR","parameter3Type":"resizeMode","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":3,"jimpFunction":"resize","selectedJimpFunction":{"name":"resize","fn":"resize","description":"resize the image. One of the w or h parameters can be set to automatic (\"Jimp.AUTO\" or -1).","parameters":[{"name":"w","type":"num|auto","required":true,"hint":"the width to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"h","type":"num|auto","required":true,"hint":"the height to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":930,"y":900,"wires":[["8b46b674ded47a1a"]]},{"id":"befc85876d0c7c36","type":"jimp-image","z":"42ea7bd7.2e3c24","name":"buf > image","data":"payload","dataType":"msg","ret":"img","parameter1":"640","parameter1Type":"num","parameter2":"480","parameter2Type":"num","parameter3":"RESIZE_NEAREST_NEIGHBOR","parameter3Type":"resizeMode","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":3,"jimpFunction":"resize","selectedJimpFunction":{"name":"resize","fn":"resize","description":"resize the image. One of the w or h parameters can be set to automatic (\"Jimp.AUTO\" or -1).","parameters":[{"name":"w","type":"num|auto","required":true,"hint":"the width to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"h","type":"num|auto","required":true,"hint":"the height to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":930,"y":980,"wires":[["e0ed5cfc2e8c98ad"]]}]

```

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [28 January 2022 00:31 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/3 "2022-01-28T00:31:28Z")

</div>

Steve! Thank you so, so much. This is brilliant!  
I learned from what you did and with a couple little tweaks, I have it working perfectly for my use-case.

I really appreciate you taking the time on this for me.  
Thanks again,  
Dax.

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [28 January 2022 00:52 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/4 "2022-01-28T00:52:40Z")

</div>

Hey @Steve-Mcl, I've got that output sending to Pushover successfully - what would be the best way to pass the combined image output (now `msg.attachment`) to the email node as an attachment (or inline image, I don't mind either way)?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2fd5dca3a3aa5385f405e5c1ed7a70663e24340d.png)

I'm currently passing it an image saved to disk using`Set msg.attachments -> [{ "filename": msg.file, "path": msg.filename, "content": $$.payload	}]`, but I think I can pass the buffer directly without writing to disk, right?

I'm unsure how to implement it correctly. I connected the output of the `blit image3` node to this Change node below. And as you can see I've tried setting it to `msg.attachment` with no luck (the attachment arrives in email, but is 0 bytes.)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/25264fa57d7196d55a0c1bbaa864819b14019b17.png)

I'm sure I'm missing something tiny, but I just don't know what it is!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 January 2022 08:14 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/5 "2022-01-28T08:14:11Z")

</div>

> [@daxliniere](#):
>
> I'm currently passing it an image saved to disk using `Set msg.attachments -> [{ "filename": msg.file, "path": msg.filename, "content": $.payload	}]` , but I think I can pass the buffer directly without writing to disk, right?

Yes.

Change the last image output to type buffer  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/3/d39d3d40d96a2b66ef49f4f59dae030b1e22557b.png)

Use this bit of flow...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3edd35f2dad5f8255a3ea757f0b885c75b1834c6.png)

```auto
[{"id":"f508aa8.70f5358","type":"change","z":"42ea7bd7.2e3c24","name":"Setup Email - inline","rules":[{"t":"set","p":"cid","pt":"msg","to":"","tot":"date"},{"t":"set","p":"attachments","pt":"msg","to":"[{\t \"filename\": 'snapshot_' & $replace($now(),\":\",\"_\") & '.jpg', \t \"content\": $$.combined,\t \"cid\": \"\" & cid & \"\"\t}]","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"Activity detected","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"'<img src=\"cid:' & cid & '\"/>'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":1240,"wires":[["e7e50356.464ba"]]},{"id":"208b28b4f1b60f29","type":"function","z":"42ea7bd7.2e3c24","name":"Setup Email as attachement","func":"//get mime\nconst imgType = msg.imageInfo.MIME.replace(\"image/\",\"\");\nconst filename = `snapshot_${Date.now()}.${imgType}`\nmsg.attachments = [{ filename: filename, content: msg.combined}];\n\n\nmsg.payload = \"See attached image\";\n\nmsg.topic = \"Activity detected\";\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1160,"y":1300,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [29 January 2022 00:52 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/6 "2022-01-29T00:52:20Z")

</div>

Thanks again, Steve. I gotta buy you a beer.

By the way, I was just working out how to convert the PNG output to a JPG before emailing the image when I discovered you're the maintainer of contrib-image-tools! I had no idea! Thanks so much for the nodes and for your help in setting all of this up.

Speaking of PNG to JPG conversion, I think I can see how to do this for a file on disk, but not for an image in buffer. I tried changing the frame grab nodes from `-vcodec png` to `-vcodec jpg`, but it just caused an error at the buf\>img node, halting the flow.  
Could you point me in the right direction if you have a moment, please?

Lastly, I've had a couple instances of one framegrab node not completing (or sending junk? buf\>img says 'cannot be empty') to the following node which obviously stops the flow at that point (throws an error.) This results in no images being combined at all.  
Is there a way to maybe read all 3 images in parallel and pass them to the series of blit compositing nodes?

All the best,  
Dax.

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [4 February 2022 00:07 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/7 "2022-02-04T00:07:16Z")

</div>

Hey all,  
Any ideas on how to convert a PNG buffer stream to JPG buffer stream?

Thank you in advance!  
Dax.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 February 2022 00:07 UTC](https://discourse.nodered.org/t/help-request-capture-images-and-blit-them-together-with-contrib-image-tools-jimp/57363/8 "2022-02-18T00:07:17Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
