We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37997
    • 5 Posts
    Has anyone else had trouble with phpThumbOf not cropping images when using zc=1 ? It works perfectly on my local test server but won't crop images on the live server... If I use &fltr[]=bord|1|0|0|ffffff cropping works but I don't want to have a white border. I'd really appreciate any advice.
      • 25803 ☆ A M B ☆
      • 721 Posts
      We've found that different servers either support it or do not.
        • 28215
        • 4,149 Posts
        Do you have ImageMagick installed on your server?
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 18817 ☆ A M B ☆
          • 205 Posts
          We had the same issue and found that GD library & ImageMagick were not enabled. I suggest that route.
            Sal Baldovinos
            SEO & DIGITAL MARKETING

            ARIEL DIGITAL | Maximize Your Potential
            www.arieldigitalmarketing.com
            • 37997
            • 5 Posts
            Hi splittingred,

            Do you have ImageMagick installed on your server?

            No but I don't think it's necessary? My local test server just uses GD and it works fine. I ended up just creating my own thumbnail snippet using the modPhpThumb extension class which works perfectly using the zc parameter. It's very strange that phpThumbOf doesn't...
              • 33337
              • 3,975 Posts
              Quote from: bobbob at Apr 16, 2012, 04:28 AM
              Hi splittingred,

              Do you have ImageMagick installed on your server?

              No but I don't think it's necessary? My local test server just uses GD and it works fine. I ended up just creating my own thumbnail snippet using the modPhpThumb extension class which works perfectly using the zc parameter. It's very strange that phpThumbOf doesn't...
              Would you like to share your snippet with us? smiley

              Thanks.
                Zaigham R - MODX Professional | Skype | Email | Twitter

                Digging the interwebs for #MODX gems and bringing it to you. modx.link
                • 37997
                • 5 Posts
                Quote from: zaigham at Apr 27, 2012, 09:15 AM

                Would you like to share your snippet with us? smiley

                Thanks.

                Sure smiley Here's the snippet

                <?php
                // --------------------
                // Parameters
                // --------------------
                // $src
                // $width
                // $height
                // $zc
                
                if (empty($modx)) return;
                
                if (!$modx->loadClass('modPhpThumb', $modx->getOption('core_path') . 'model/phpthumb/', true, true))
                {
                    $modx->log(modX::LOG_LEVEL_ERROR, 'Could not load modPhpThumb class.');
                    
                    return;
                }
                
                $thumb_path = sprintf('assets/thumbs/%sx%s-%s', $width, $height, basename($src));
                
                if (!file_exists($thumb_path))
                {
                    $thumb = new modPhpThumb($modx);
                    $thumb->initialize();
                    $thumb->set($src);
                    
                    if (isset($width)) $thumb->setParameter('w', $width);
                    if (isset($height)) $thumb->setParameter('h', $height);
                    if (isset($zc)) $thumb->setParameter('zc', $zc);
                    
                    $thumb->GenerateThumbnail();
                    $thumb->RenderToFile(MODX_BASE_PATH . $thumb_path);
                }
                
                return $thumb_path;


                If you were to name the snippet 'create_thumb' you would call it using:

                [[!create_thumb? &src=`path/to/your/image` &width=`300` &height=`150` &zc=`1`]]


                and it will output the path to the generated thumbnail.

                Note: The generated thumbnail names aren't very good if you miss out either the width or the height parameters but that won't stop it working.