Replace all occurance of an image with another one in a larger image.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Schakal
Posts: 4
Joined: 2018-12-15T06:19:45-07:00
Authentication code: 1152
Location: Moscow, Russia

Replace all occurance of an image with another one in a larger image.

Post by Schakal »

Hello, Gentlemen!
Could you please advise is it possible? An example - there's a chat screenshot with a lot of emojis, and I need to replace all occurances of one particular emoji (let's say devil) to another one (angel).Can it be automated?
Thanks a lot in advance!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replace all occurance of an image with another one in a larger image.

Post by snibgo »

Schakal wrote:Can it be automated?
Yes.

See viewtopic.php?f=1&t=9620
snibgo's IM pages: im.snibgo.com
Schakal
Posts: 4
Joined: 2018-12-15T06:19:45-07:00
Authentication code: 1152
Location: Moscow, Russia

Re: Replace all occurance of an image with another one in a larger image.

Post by Schakal »

snibgo wrote: 2018-12-15T07:11:22-07:00 Yes.
Dear snibgo , glad to see it is possilble. Unfortunately I've failed to find any info, probably I did it wrong. English isn't my native language, so I could search incorrectly. Would you be so kind to direct me?
Thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replace all occurance of an image with another one in a larger image.

Post by snibgo »

That page tells you how to ask questions.

You should say what version of IM you use, on what platform. You should link to an example screenshot and what you want to search for and what you want to replace it with.

If you don't do this, we can only give vague answers.

See the very similar recent question: viewtopic.php?f=1&t=35163
snibgo's IM pages: im.snibgo.com
Schakal
Posts: 4
Joined: 2018-12-15T06:19:45-07:00
Authentication code: 1152
Location: Moscow, Russia

Re: Replace all occurance of an image with another one in a larger image.

Post by Schakal »

Thank you snibgo. Now I understand.
Well, I'm OK to use any version on Windows 7, 64bit.
For the screenshots, it's now not that important as I've got an idea how search of sub-image works, but here they are:
Source image: https://schakal.ru/tmp/from.png
Subimage to search for: https://schakal.ru/tmp/find.png
Subimage to replace with: https://schakal.ru/tmp/with.png
Resulting image I expect to get: https://schakal.ru/tmp/to.png

The issue I still have is that I can't pass an output of 'compare' command to 'compose'. I've read some examples, but it seems that IM doesn't send output to console in usual way as most Windows command line programs do, so I can't save it to a file or variable or to pipeline it any further.
For example, classic output redirection doesn't work. IM still sends the output to the console and generates an empty file with no output:

Code: Select all

compare -metric RMSE -subimage-search from.png find.png tmp.png > tmp.txt
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replace all occurance of an image with another one in a larger image.

Post by snibgo »

Your links don't work for me. I get:

Code: Select all

Error 1011 Ray ID: 489af3e98db134b2 • 2018-12-15 18:25:26 UTC 
Access denied
What happened?
The owner of this website (schakal.ru) does not allow hotlinking to that resource (/tmp/from.png).
Images are sent to stdout. Text messages go to stderr, so use "2>tmp.txt".
snibgo's IM pages: im.snibgo.com
Schakal
Posts: 4
Joined: 2018-12-15T06:19:45-07:00
Authentication code: 1152
Location: Moscow, Russia

Re: Replace all occurance of an image with another one in a larger image.

Post by Schakal »

snibgo wrote: 2018-12-15T11:28:18-07:00Text messages go to stderr, so use "2>tmp.txt".
Wow! Thank you very much! Didn't expect it at all.
Post Reply