<p>so I am using trying to use the Imager plugin to compress my images. It works fine this way:</p>

<pre><code>    {% set imagePath = "/path/to/img.jpg" %}
    {% set compressed = craft.imager.transformImage(imagePath, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
    &lt;img src="{{ compressed }}" alt="Foto-kantoor" class="img-max img-responsive wow fadeIn"&gt;
</code></pre>

<p>But if I try to use it inside a <code>{% for %}</code> loop it doesn't work and I get an error. Here's the code Im trying to use:      </p>

<pre><code>{% for image in logos %}
    {% if image %}
        &lt;div class="img-frame"&gt;
            {% set compressed = craft.imager.transformImage(image, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
            &lt;img src="{{ compressed.url }}" alt="Logo-{{ loop.index0 }}" class="img-responsive logo-img"&gt;
        &lt;/div&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>Then I get this error: </p>

<pre><code>Unable to open image /Applications/MAMP/htdocs/project/files/logos/my-logo.jpg
</code></pre>

<p>Does anyone know what Im doing wrong?</p>

<p>Thanks!</p>

CC BY-SA 3.0
2017-05-02T21:14:55.853Z
Any fatal errors in your `craft/storage/runtime/logs` files?  My guess is you're hitting either your php.ini file's max_execution_time or memory_limit settings.
Brad Bell
CC BY-SA 3.0
2017-06-09T11:01:13.880Z
@Branko Have you double checked that the file actually exists in the path specified?
André Elvan
<plugins><forloop><plugin-imager>
Imager plugin not working inside the loop
# Imager plugin not working inside the loop

(Asked by: username_0 on 2017-05-02)

so I am using trying to use the Imager plugin to compress my images. It works fine this way:
    {% set imagePath = "/path/to/img.jpg" %}
    {% set compressed = craft.imager.transformImage(imagePath, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
    

But if I try to use it inside a {% for %} loop it doesn't work and I get an error. Here's the code Im trying to use:      
{% for image in logos %}
    {% if image %}
        
            {% set compressed = craft.imager.transformImage(image, { pngCompressionLevel: 9, webpQuality: 10, jpegQuality: 50 }) %}
            
        
    {% endif %}
{% endfor %}

Then I get this error: 
Unable to open image /Applications/MAMP/htdocs/project/files/logos/my-logo.jpg

Does anyone know what Im doing wrong?
Thanks!

**Tags:** plugins, forloop, plugin-imager
> **Comments:**
> **username_1**: Any fatal errors in your `craft/storage/runtime/logs` files?  My guess is you're hitting either your php.ini file's max_execution_time or memory_limit settings.  
> **username_2**: @Branko Have you double checked that the file actually exists in the path specified?  

---

## 0 answers

