Flutter: Merge two images using Dart and store it in local storage as a single image. Found the answer, Thanks to this awesome library https://pub.dev/packages/image
1 2 3 4 5 6 7 8 9 | final image1 = decodeImage(File('imageA.jpg').readAsBytesSync()); final image2 = decodeImage(File('imageB.jpg').readAsBytesSync()); final mergedImage = Image(image1.width + image2.width, max(image1.height, image2.height)); copyInto(mergedImage, image1, blend = false); copyInto(mergedImage, image2, dstx = image1.width, blend = false); final documentDirectory = await getApplicationDocumentsDirectory(); final file = new File(join(documentDirectory.path, "merged_image.jpg")); file.writeAsBytesSync(encodeJpg(mergedImage)); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.