We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    This is an auto-generated topic for phpThumbOf 1.1.0-rc1 by splittingred.

    Brief Description:

    A custom, secure output filter for phpThumb. Any phpThumb-compatable config options can be passed into parameter of the filter.
    New in 1.1.0-rc1

    • Added Amazon S3 support for storing cached thumbnails
    • Added plugin to clear thumb cache when clearing site cache

    See the official documentation at:
    http://rtfm.modx.com/display/ADDON/phpThumbOf
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 9102 ☆ A M B ☆
      • 318 Posts
      Hey, just wanted to say thanks for writing this, it works perfectly, I’m using it as-is and also used it as a basis to write a plugin to resize images on upload. It’s cleanly coded and easy to understand, use and extend. Thanks man, it’s a simple little filter but it rocks and saved me a lot of work trying to figure out how to do the same thing myself.
        • 28215
        • 4,149 Posts
        No problem! Glad it works for you.
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 34108
          • 66 Posts
          Hi Shaun smiley Thanks for this fantastic package - finally an out-of-the-box thumbnail generator for modx that just *works*! I especially love the zoom functionality - most of my clients have trouble learning to resize images themselves so this is a life saver.

          I was wondering if there’s a way to customise the outputted filesize and/or type of the thumbnail image? For example I have a jpeg image of a dog on this page - http://www.thespottedquoll.com.au/dalmatian - which is about 75 KB in filesize, but when it’s phpthumbed (as seen here - http://www.thespottedquoll.com.au/fire-flys/) the generated PNG is 235 KB - over 3 times as many KB as the original jpeg.

          I realise this is probably because the new thumbnail is in PNG format, so was wondering if there’s a way to specify the output be JPEG by default? Or, if not, a way to set the PNG compression rate? (I did take a look at the snippet code but my knowledge of PHP is only basic sorry).

          Thanks heaps, and thanks again for this great package, your efforts are definitely appreciated!

          - Harmony
            • 33337
            • 3,975 Posts
            Try adding &f=`jpg` in the snippet call.

            or

            [[+image:phpthumbof=`w=120&h=120&f=jpg`]]
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 34108
              • 66 Posts
              Thanks zi, adding &f=jpg to the call did the trick smiley Much appreciated!

              The new filesize of the thumbnail is now 15 KB.

              Thanks again.

              Harmony
                • 8080
                • 6 Posts
                [[*img:phpthumbof=`&wl=300&hp=100`]]

                Result:
                /assets/components/phpthumbof/cache/Z:/home/localhost/www/assets/components/phpthumbof/cache/assets_images_1286154312_earth2_medium.jpg.453e59d0dfa4a3450cc3236246689fa2.png


                Real path:
                assets/components/phpthumbof/cache/assets_images_1286154312_earth2_medium.jpg.453e59d0dfa4a3450cc3236246689fa2.png


                sad
                  • 33337
                  • 3,975 Posts
                  S3 support is really awesome. Able to use the CNAME will be great: https://github.com/splittingred/phpThumbOf/issues#issue/8
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 29875
                    • 4 Posts
                    hey, thank you very much for this awe... wait for it ...some snippet. laugh

                    I had the same problem as harmonysteel that the file size of the generated thumbs (in png) were bigger than the original image. I already know about the f-Option but that doesn’t do the trick if you can’t predict the image-format of the original image.

                    So I just changed some lines in the snippet and I want to share it, if someone had the same problem, or maybe it will be integrated in the next version of phpthumbof.
                    What I changed was this line:
                    if (empty($ptOptions['f']))$ptOptions['f'] = 'png';

                    Into this:
                    if (empty($ptOptions['f'])){
                        $ext = strtolower(pathinfo($input, PATHINFO_EXTENSION));
                        switch($ext){
                            case 'jpg':
                            case 'jpeg':
                                $ptOptions['f'] = 'jpeg';
                                break;
                            case 'gif':
                                $ptOptions['f'] = 'gif';
                                break;
                            default:
                                $ptOptions['f'] = 'png';
                                break;
                        }
                    }

                    This code take the file extension of the original image and put it as the output format for the thumb-image, but only if the f-Option is not set and it defaults to png for any image-format that isn’t jpg or gif.

                    Greets from Austria!
                      • 22377 ☆ A M B ☆
                      • 33 Posts
                      Quote from: Dronowar at Jan 28, 2011, 02:07 AM

                      [[*img:phpthumbof=`&wl=300&hp=100`]]

                      Result:
                      /assets/components/phpthumbof/cache/Z:/home/localhost/www/assets/components/phpthumbof/cache/assets_images_1286154312_earth2_medium.jpg.453e59d0dfa4a3450cc3236246689fa2.png


                      Real path:
                      assets/components/phpthumbof/cache/assets_images_1286154312_earth2_medium.jpg.453e59d0dfa4a3450cc3236246689fa2.png


                      sad

                      Having the exact same problem. Apparently when developing locally (using WAMP here) the paths get messed up.