<p>You can easily do this in twig with a conditional that checks if the width of the image is larger than your target transforms width. Try something like this:</p>

<pre><code>{% if image.getWidth()&gt;600 %}
  &lt;img src="{{ image.getUrl({ width: 600 }) }}"&gt;
{% else %}
  &lt;img src="{{ image.getUrl() }}"&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-10-08T15:13:00.107Z
2014-10-08T15:13:00.107Z
André Elvan
<p>At the moment I have an image 300px wide, my transform is set to a width of 600px so it upscales it. </p>

<p>I would like it to only transform if the image is over 600px. </p>

<p>Is this possible or should I use some other image manipulation thing like phpthumb?</p>

<image-transforms><image>
Image transform that only crops if image is larger than set dimensions
# Image transform that only crops if image is larger than set dimensions

(Asked by: username_0 on 2014-10-08)

At the moment I have an image 300px wide, my transform is set to a width of 600px so it upscales it.

I would like it to only transform if the image is over 600px.

Is this possible or should I use some other image manipulation thing like phpthumb?

**Tags:** image-transforms, image

---

## 1 answers

### Answer by username_1 on 2014-10-08. Score: 4 | Accepted answer

You can easily do this in twig with a conditional that checks if the width of the image is larger than your target transforms width. Try something like this:
{% if image.getWidth()>600 %}
  
{% else %}
  
{% endif %}


---

