I'm looking for ways through which I can convert png images to jpg format in flutter as I'm unable to find a way to do that anywhere.
This is the code I tried but it is giving me black images:
// Read a jpeg image from file.
img.Image image = img.decodeImage(File(pngfilepath).readAsBytesSync());
// Resize the image to a 200 height thumbnail (maintaining the aspect ratio).
img.Image thumbnail = img.copyResize(image, height: 200);
// Save the thumbnail as a JPG.
File(outputfilepath/filename.jpg)
..writeAsBytesSync(img.encodeJpg(thumbnail));
So, please provide me a way in which I can convert png to jpg. Thank you.