We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48381
    • 21 Posts
    Hi,
    When using pthumb to output images with fixed size sometimes the result differs by 1 pixel.
    I ask for image height of 400px, and some images always result in 399px.
    I could not detect the difference in the source images which cause this - I assume some rounding of aspect ratio...
    I changed to image+ but I get the same behavior.

    pthumb:
    <img src='[[+tv_image:pThumb=`w=400&h=270&zc=1`]]'>-->


    image+:
    Target (minimal) Width: 400
    Target (minimal) Height: 270

    Output as Image+, Generate Thumb URL: yes, not custom output chunk

    My temporary solution using image+ is to re-crop it with a very small change - the recalculation usually fixes it and the image output size is as expected.

    Since I have an image list with float left, a 1-pixel change in height breaks the entire grid.
    Did anyone else encounter this and have a solution?

    I would like to avoid any of the following solutions I thought of:
    - have the image as a CSS background (bad for SEO)
    - have the image with fixed width height according to the breakpoint (not responsive as I would like)
    - CSS object fit (best solution I found but a problem with browser support)
      • 3749
      • 24,544 Posts
      I think this may be a browser bug. I've read of cases where image heights in Firefox are often 1 pixel different from those in Chrome. I'm not sure if that's still true, but you might check in different browsers.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 48381
        • 21 Posts
        thanks for your answer.
        I'm not sure I agree - but thankfully I could not recreate it to test on firefox vs chrome.

        Please see attached screenshot - in the devtools it was written Natural: 400px,
        and for one image for no clear reason Natural: 399px

        My understanding was the source image is generated by the pthumb resizer.
        Next time it happens I will try to save locally the image from multiple browsers
        and see in photoshop if browsers are related to it.
          • 3749
          • 24,544 Posts
          Uploading screenshots doesn't work right now, so you have to put them somewhere else and provide a link to them.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting