# Robot Framework code for imagemagick not working in windows environment

**URL:** <https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699>\
**Category:** Robot Framework\
**Created:** [2 November 2021 13:44 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699 "2021-11-02T13:44:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nafis456](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nafis456](https://forum.robotframework.org/u/nafis456)\
**Post date:** [2 November 2021 13:44 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/1 "2021-11-02T13:44:35Z")

</div>

I am trying to write robot framework code with initializing imagemagick. I have already downloaded imagemagick for windows version. But everytime i run the code, it gives me an error “the system can’t find the file specified”. Following is the imagemagick part of the robot code.

\*\*\* Variables \*\*\*  
${IMAGE\_COMPARATOR\_COMMAND} /var/run/utmp/ImageMagick-7.1.0-12/convert **REFERENCE**  **TEST** -metric RMSE -compare -format “%[distortion]” info:

\*\*\* Keywords \*\*\*  
Compare Images  
[Arguments] ${Reference\_Image\_Path} ${Test\_Image\_Path} ${Allowed\_Threshold}  
${TEMP}= Replace String ${IMAGE\_COMPARATOR\_COMMAND} **REFERENCE** ${Reference\_Image\_Path}  
${COMMAND}= Replace String ${TEMP} **TEST** ${Test\_Image\_Path}  
Log Executing: ${COMMAND}  
${RC} ${OUTPUT}= Run And Return Rc And Output ${COMMAND}  
Log Return Code: ${RC}  
Log Return Output: ${OUTPUT}  
${RESULT} Evaluate ${OUTPUT} \< ${Allowed\_Threshold}  
Should be True ${RESULT}

Compare Images C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/reference-screenshots/reference-1.jpg C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/test-screenshots/test-1.jpg 0.1

---

<div class="post-metadata">

**Author:** ![EdManlove](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/edmanlove/32/1002_2.png) [@EdManlove](https://forum.robotframework.org/u/EdManlove)\
**Post date:** [2 November 2021 13:54 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/2 "2021-11-02T13:54:08Z")

</div>

You would need to share more of the error/output which shows that path it is failing on to be able to best help. I do see you have a Linux path in the comparator command variable while running on Windows.

---

<div class="post-metadata">

**Author:** ![nafis456](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nafis456](https://forum.robotframework.org/u/nafis456)\
**Post date:** [2 November 2021 14:05 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/3 "2021-11-02T14:05:01Z")

</div>

from the log.html files here more of the error /output  
TEST Enter Application for Animation using Vulcan Build

| Full Name: | imagesDetect.Enter Application for Animation using Vulcan Build |
| --- | --- |
| Documentation: | Open application for animation part of RockSolid SDK using Vulcan |
| Start / End / Elapsed: | 20211101 18:02:47.987 / 20211101 18:02:52.788 / 00:00:04.801 |
| Status: | FAIL |
| Message: | Evaluating expression ‘The system cannot find the path specified. \< 0.1’ failed: SyntaxError: invalid syntax (, line 1) |

00:00:04.625KEYWORD AppiumLibrary . Open Application [http://localhost:4723/wd/hub](http://localhost:4723/wd/hub), alias=Myapp1, platformName=Windows, platformVersion=Windows10Pro, deviceName=‘Windows’, app=C:/share/RocksolidSDK/examples/buildv/animation/Release/animation.exe

00:00:00.171KEYWORD Screenshot . Take Screenshot

00:00:00.004KEYWORD Compare Images C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/reference-screenshots/reference-1.jpg, C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/test-screenshots/test-1.jpg, 0.1

Start / End / Elapsed: 20211101 18:02:52.784 / 20211101 18:02:52.788 / 00:00:00.004

00:00:00.000KEYWORD ${TEMP} = String . Replace String ${IMAGE\_COMPARATOR\_COMMAND}, **REFERENCE** , ${Reference\_Image\_Path}

00:00:00.000KEYWORD ${COMMAND} = String . Replace String ${TEMP}, **TEST** , ${Test\_Image\_Path}

00:00:00.000KEYWORD BuiltIn . Log Executing: ${COMMAND}

00:00:00.004KEYWORD ${RC}, ${OUTPUT} = OperatingSystem . Run And Return Rc And Output ${COMMAND}

| Documentation: | Runs the given command in the system and returns the RC and output. |
| --- | --- |
| Start / End / Elapsed: | 20211101 18:02:52.784 / 20211101 18:02:52.788 / 00:00:00.004 |

18:02:52.788 INFO Running command ‘/var/run/utmp/ImageMagick-7.1.0-12/convert C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/reference-screenshots/reference-1.jpg C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/test-screenshots/test-1.jpg -metric RMSE -compare -format “%[distortion]” info: 2\>&1’.

18:02:52.788 INFO ${RC} = 1

18:02:52.788 INFO ${OUTPUT} = The system cannot find the path specified.

00:00:00.000KEYWORD BuiltIn . Log Return Code: ${RC}

00:00:00.000KEYWORD BuiltIn . Log Return Output: ${OUTPUT}

00:00:00.000KEYWORD ${RESULT} = BuiltIn . Evaluate ${OUTPUT} \< ${Allowed\_Threshold}

| Documentation: | Evaluates the given expression in Python and returns the result. |
| --- | --- |
| Start / End / Elapsed: | 20211101 18:02:52.788 / 20211101 18:02:52.788 / 00:00:00.000 |

18:02:52.788 FAIL Evaluating expression ‘The system cannot find the path specified. \< 0.1’ failed: SyntaxError: invalid syntax (, line 1)

Can you suggest to me which would be a windows path, because i thought this was windows path in the command variable ?

---

<div class="post-metadata">

**Author:** ![nafis456](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nafis456](https://forum.robotframework.org/u/nafis456)\
**Post date:** [2 November 2021 14:07 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/4 "2021-11-02T14:07:18Z")

</div>

sorry i meant comparator command variable

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [2 November 2021 15:12 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/5 "2021-11-02T15:12:42Z")

</div>

> [@nafis456](#):
>
> ${RESULT} Evaluate ${OUTPUT} \< ${Allowed\_Threshold}

This is causing the error:

> 18:02:52.788 FAIL Evaluating expression ‘The system cannot find the path specified. \< 0.1’ failed: SyntaxError: invalid syntax (, line 1)

Coming from:  
`C:/Users/niskande/PycharmProjects/imagingProject/venv/RobotCases/test-screenshots/test-1.jpg -metric RMSE -compare -format “%[distortion]” info: 2>&1`

Must you use the redirection \>&1 ?

Maybe need some escaping?

OperatingSystem keywords should be replaced by Process (more reliable)

---

<div class="post-metadata">

**Author:** ![nafis456](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@nafis456](https://forum.robotframework.org/u/nafis456)\
**Post date:** [2 November 2021 16:36 UTC](https://forum.robotframework.org/t/robot-framework-code-for-imagemagick-not-working-in-windows-environment/2699/6 "2021-11-02T16:36:32Z")

</div>

Thank you for your answer HelioGuilherme66. I dont need to use redirection \>&1 but this is generated when i run my testcase, I am not sure how to disable it ? Can you suggest some guideline? Thank you

best regards  
nafis456
