Answers.Body: <p>After looking for a while, I found this was due to the whitespace before <code>&lt;?php</code> i.e</p>
  
  <pre><code>&lt;space&gt;&lt;?php (starting of the file)
  </code></pre>
  
  <p>in <code>civicrm_settings.php</code> file which was messing the png file generation. On removing this space, the image was loaded correctly without errors. So if anyone encounters this error, make sure all your included files are white-space free before <code>&lt;?php</code>.</p>
  
  <p>Update: This normally occurs due to an invalid image that is formed by the headers. Flushing the headers with <code>ob_clean()</code> just before <a href="https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/blob/2.x/CRM/Mosaico/Utils.php#L299" rel="nofollow noreferrer">specifying the same</a> have also worked for some users. There is a great answer <a href="https://stackoverflow.com/a/2591854/4243217">https://stackoverflow.com/a/2591854/4243217</a> which explains about the space issue while creating image using ImagickDraw(used by Mosaico).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-06T00:06:01.700Z
Answers.Text: Jintendra - thanks for this diagnosis. I am facing exactly the same issue and do not have a whitespace before `<?php` in my civicrm.settings.php file. A search in the directory tree uncovers many files that have such whitespaces before `<?php`, including WordPress theme files, plugins, civicrm extensions, etc. Can you explain why such a whitespace is an issue for this pop-up, and how to mitigate it? Which files are loaded by Imagick when generating the image? Thanks.
Answers.UserDisplayName: cividesk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-06T05:38:25.727Z
Answers.Text: For further reference - there was a `?>\n\n<?php` in the functions.php file of the WordPress Church theme. Removed it and it fixed the issue.
  
  I believe this issue would be corrected by resolving https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/55
Answers.UserDisplayName: cividesk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-06T06:12:00.657Z
Answers.Text: will soon update the answer of why it is actually needed.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T10:01:20.930Z
Answers.Text: I encountered the same issue. In my case it was due to a Drupal module that contained UTF8 files with a byte order mark (BOM). So I can confirm that it's due to "spaces" before <?php, as Jitendra mentioned. But beware that 1) it can be anywhere in your website php files, 2) the "spaces" can be invisible (I used a hex editor to see the BOM)
Answers.UserDisplayName: AlainB
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-08T13:16:04.447Z
Answers.LastActivityDate: 2017-10-09T12:10:26.787Z
Answers.LastEditDate: 2017-10-09T12:10:26.787Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>After enabling the latest Mosaico on one site, we found the icons are not loaded after adding a new template. After dragging the image from the left to place on the template the image is displayed as below -</p>
  
  <p><a href="https://i.sstatic.net/TUHgp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TUHgp.png" alt="enter image description here"></a></p>
  
  <p>On opening the ajax url in a new window, it says -</p>
  
  <blockquote>
    <p>The Image &lt;258*150_url> cannot be displayed because it contains errors`</p>
  </blockquote>
  
Tags: <mosaico><imagick>
Title: Mosaico - ImagickDraw unable to load any image on templates
ThreadText: # Mosaico - ImagickDraw unable to load any image on templates
  
  (Asked by: username_0 on 2017-07-08)
  
  After enabling the latest Mosaico on one site, we found the icons are not loaded after adding a new template. After dragging the image from the left to place on the template the image is displayed as below -
  
  [![enter image description here](https://i.sstatic.net/TUHgp.png)](https://i.sstatic.net/TUHgp.png)
  
  On opening the ajax url in a new window, it says -
  
  > The Image <258\*150\_url> cannot be displayed because it contains errors`
  
  **Tags:** mosaico, imagick
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-07-08. Score: 2 | Accepted answer
  
  After looking for a while, I found this was due to the whitespace before `<?php` i.e
  
  ```
  <space><?php (starting of the file)
  
  ```
  
  in `civicrm_settings.php` file which was messing the png file generation. On removing this space, the image was loaded correctly without errors. So if anyone encounters this error, make sure all your included files are white-space free before `<?php`.
  
  Update: This normally occurs due to an invalid image that is formed by the headers. Flushing the headers with `ob_clean()` just before [specifying the same](https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/blob/2.x/CRM/Mosaico/Utils.php#L299) have also worked for some users. There is a great answer <https://stackoverflow.com/a/2591854/4243217> which explains about the space issue while creating image using ImagickDraw(used by Mosaico).
  
  > **Comments:**
  > **username_1**: Jintendra - thanks for this diagnosis. I am facing exactly the same issue and do not have a whitespace before `<?php` in my civicrm.settings.php file. A search in the directory tree uncovers many files that have such whitespaces before `<?php`, including WordPress theme files, plugins, civicrm extensions, etc. Can you explain why such a whitespace is an issue for this pop-up, and how to mitigate it? Which files are loaded by Imagick when generating the image? Thanks.  
  > **username_1**: For further reference - there was a `?>\n\n<?php` in the functions.php file of the WordPress Church theme. Removed it and it fixed the issue.  I believe this issue would be corrected by resolving https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico/issues/55  
  > **username_0**: will soon update the answer of why it is actually needed.  
  > **username_2**: I encountered the same issue. In my case it was due to a Drupal module that contained UTF8 files with a byte order mark (BOM). So I can confirm that it's due to "spaces" before <?php, as username_0 mentioned. But beware that 1) it can be anywhere in your website php files, 2) the "spaces" can be invisible (I used a hex editor to see the BOM)  
  
  ---
  
  