<p>Before you run your transform, you can check the width of the asset file and adjust your transform as needed.</p>

<pre><code>{% set thumb = {
    mode: 'scale',
    width: 1000,
    quality: 70,
} %}

{% if asset.width &lt; 1000 %}

    {% set thumb = {
        mode: 'scale',
        width: asset.width,
        quality: 70,
    } %}

{% endif %}
</code></pre>

CC BY-SA 3.0
2015-10-29T19:17:35.197Z
Thanks for your reply, but i get errors using your code...
This solved it out: 
http://craftcms.stackexchange.com/questions/3045/image-transforms-getting-applied-even-when-image-is-smaller-than-the-transforms
Seba.
CC BY-SA 3.0
2015-10-29T22:27:15.457Z
Glad you got it sorted out!
Aaron Berkowitz
CC BY-SA 3.0
2017-05-09T23:13:44.230Z
Would you mind posting an answer here @Seba, or deleting the question if it seems like a duplicate?
Matt Stein
CC BY-SA 3.0
2015-10-27T01:16:48.013Z
2015-10-27T01:16:48.013Z
Aaron Berkowitz
<p>i´m implementing a image gallery and want to show the thumbnails ( no problem here ) with a transform applied, and i want to implement a image transform on the large image that opens on a lightbox. Why? because it´s a responsive website, and the load speed is crucial, and don´t want to slow things down loading the full image uploaded directly from the client camera ( 6mp or more ), i want to load a large image with a max width of 1000px and jpg quality of 70. I applied the transform and works fine, but the images below 1000px are streted to fit 1000px. </p>

<p>So, my question is: <strong>how to set max width of an image to 1000px BUT not forcing it if it´s smaller than the required size?</strong></p>

<p>Crop Fit and Scales don´t do the job.</p>

<p>Any help is welcome! Thanks.</p>

<assets><image-transforms><craft-features>
Image Transforms not stretching image
# Image Transforms not stretching image

(Asked by: username_0 on 2015-10-26)

i´m implementing a image gallery and want to show the thumbnails ( no problem here ) with a transform applied, and i want to implement a image transform on the large image that opens on a lightbox. Why? because it´s a responsive website, and the load speed is crucial, and don´t want to slow things down loading the full image uploaded directly from the client camera ( 6mp or more ), i want to load a large image with a max width of 1000px and jpg quality of 70. I applied the transform and works fine, but the images below 1000px are streted to fit 1000px.

So, my question is: **how to set max width of an image to 1000px BUT not forcing it if it´s smaller than the required size?**

Crop Fit and Scales don´t do the job.

Any help is welcome! Thanks.

**Tags:** assets, image-transforms, craft-features

---

## 1 answers

### Answer by username_1 on 2015-10-27. Score: 2

Before you run your transform, you can check the width of the asset file and adjust your transform as needed.
{% set thumb = {
    mode: 'scale',
    width: 1000,
    quality: 70,
} %}

{% if asset.width < 1000 %}

    {% set thumb = {
        mode: 'scale',
        width: asset.width,
        quality: 70,
    } %}

{% endif %}

> **Comments:**
> **username_0**: Thanks for your reply, but i get errors using your code... This solved it out:  http://craftcms.stackexchange.com/questions/3045/image-transforms-getting-applied-even-when-image-is-smaller-than-the-transforms  
> **username_1**: Glad you got it sorted out!  
> **username_2**: Would you mind posting an answer here @Seba, or deleting the question if it seems like a duplicate?  

---

