0

Let assume my input image name is cat.jpg after I processed the image I want to save the output image as cat_enhanced.jpg. How do I can do like that?

I don't know how to access the image name and format separately.

char* inputImgName = argv[1];

This code store both image name and format in the inputImgName pointer.

[Edited]

std::string imgNameString = argv[1];

Using this I can get the cat.jpg, but don't know how to save the image as described above.

Expected output:
input image name: cat.jpg
output image name: cat_enhanced.jpg

Miki
  • 40,887
  • 13
  • 123
  • 202
hua
  • 11
  • 4

1 Answers1

0

This is my answer to my question. Thanks @ L. Scott Johnson for pointing me out.

std::string inputImgName = argv[1];
std::string findFormat(".");
size_t pos = inputImgName.find(findFormat);
inputImgName.replace(pos, findFormat.length(), "_enhanced.");
cout << "The enhanced image name is: " << inputImgName << endl;
hua
  • 11
  • 4