-3

I'm trying to put first image on a certain area of the second image.

I tried to use imagemagick. I installed it to Visual Studio 2017. I didn't find how to use.

I tried to use CImg ("draw_image" function). I couldn't install properly. Because I couldn't find something how tell me completely.

I want to do this:

first image: https://ibb.co/gTRd3vz

second image: https://ibb.co/bmBYP4S

for example: I want to add the second image in 150x150 coordinate of the first image

like this: (I did with paint, but not what I want. I explain on the result pic) result pic: https://ibb.co/0Zh98fW

can someone tell me properly? If there is better solution, I want to know. I am in a big stuck.

2 Answers2

2

For implementing an overlay:

For ImageMagick, specifically , you would use Magick::Image.composite() method.

#include <Magick++.h>

int main() {
  Magick::Image first("wizard.png");
  Magick::Image second("rose.png");
  first.composite(second, 150, 150);
  first.write("output.png");
}

overlay

For using ImageMagick in a Visual Studio VC++ project:

In project settings, you need to set the include & library directory options to reference the ImageMagick installation location.

See VC++ Directories Property Page.

emcconville
  • 23,800
  • 4
  • 50
  • 66
0

I am not sure what you want and your 150x150 is not clear. Is that the size or offset position. Here is how to make something like what you have for your result using ImageMagick 6 command line. Sorry, I do not know C++ or Magick.Net

1.png

enter image description here

2.png

enter image description here

convert 1.png -page +650+500 2.png -background white -mosaic result.png


enter image description here

For ImageMagick 7, replace "convert" by "magick".

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • How can I use this in Visual Studio 2017? I couldn’t install this library – haydarinda Jul 27 '19 at 04:29
  • And is it suitable for real-time video process? I want to take frames and implement them like what you wrote? – haydarinda Jul 27 '19 at 04:29
  • Also What about the places that “I don’t want this area”? – haydarinda Jul 27 '19 at 04:31
  • I don't know C++ or Visual Studio or Window. See the other answer from emcconville about that. I do not think Imagemagick is a realtime processor, though some functions can be run via GPU. I do not know what you mean by do not want this area. As the second image is shifted partly off the first, the areas that are not on both must be filled in with something. Do you want that something to be transparent? – fmw42 Jul 27 '19 at 05:06
  • can you do this in Visual Studio. Because I'm getting this error: https://stackoverflow.com/questions/57230208/error-unresolved-external-symbol-while-using-magick-library-in-c-in-visual-st – haydarinda Jul 27 '19 at 09:00
  • Sorry, I do not know Visual Studio or Windows. Perhaps you installed the 32-bit version of Visual Studio and need the 64-bit version or the other way around? – fmw42 Jul 27 '19 at 16:01