Page 1 of 1

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

Posted: 2018-12-15T06:43:45-07:00
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!

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

Posted: 2018-12-15T07:11:22-07:00
by snibgo
Schakal wrote:Can it be automated?
Yes.

See viewtopic.php?f=1&t=9620

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

Posted: 2018-12-15T07:54:25-07:00
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.

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

Posted: 2018-12-15T08:20:29-07:00
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

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

Posted: 2018-12-15T10:19:39-07:00
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

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

Posted: 2018-12-15T11:28:18-07:00
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".

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

Posted: 2018-12-15T11:40:45-07:00
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.