Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-29T19:17:35.197Z
Answers.Text: 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
Answers.UserDisplayName: Seba.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-29T22:27:15.457Z
Answers.Text: Glad you got it sorted out!
Answers.UserDisplayName: Aaron Berkowitz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-09T23:13:44.230Z
Answers.Text: Would you mind posting an answer here @Seba, or deleting the question if it seems like a duplicate?
Answers.UserDisplayName: Matt Stein
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-27T01:16:48.013Z
Answers.LastActivityDate: 2015-10-27T01:16:48.013Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <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>
  
Tags: <assets><image-transforms><craft-features>
Title: Image Transforms not stretching image
ThreadText: # 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 @username_0, or deleting the question if it seems like a duplicate?  
  
  ---
  
  