We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25284
    • 141 Posts
    Quote from: robinK at Nov 18, 2010, 10:11 AM

    I’ve got phpthumbof working fine for most of the things I want to do, however I can’t seem to get the filter section to work correctly.
    I’m actually trying to watermark an image, but in the interests of tracking down where I’m going wrong I have tried a simple flip,

    <image src='[[*image:phpthumbof=`fltr[]=flip|y`]]'/>


    Can the ’fltr’ array be passed by phpthumbof? Can anyone see what I’m doing wrong here?

    Ok, don’t know if it was me being a bit slow, but you can get this working if you just remove the brackets, i.e.
     <image src='[[*image:phpthumbof=`fltr=flip|y`]]'/> 


    It took me a while as I was expecting to have to follow the phpThumb example code. There is a slight difference in this usage.
    This works for the watermarking too.

    Hope that helps someone else.

    Robin
      • 25284
      • 141 Posts
      Quote from: Nomark at Nov 19, 2010, 09:35 AM

      I’m having some performance issues with the cache. It takes my server 0.25 seconds to find and load the cached file. The problem here lies in this line:

      /* ensure we have an accurate and clean cache directory */
      $phpThumb->CleanUpCacheDirectory();
      


      If I omit this line of code it speeds up the proces from 0.25 secs per thumb to 0.01 secs per thumb, which is awesome smiley The question is however: does this result in any problems on the long term?

      We’re going in production with this particular site and I thought it might be an idea to schedule a daily/hourly cronjob to execute this cache cleaning proces.

      Any thoughts on this?

      I’ve just been looking through the code and the CleanUpCacheDirectory does exactly what you’d expect from it.
      See line 651 of core/model/phpthumb/phpthumb.class.php

      As long as your cron job performs the same actions, I can’t see a problem. Your just calling the cleanup code at a more suitable time, rather than everytime a thumbnail is requested.

      Robin
        • 30585
        • 833 Posts
        Hi all,

        Is there a way to use PHPThumbOf with getResources TVs?

        I have this image path that I’d like to apply the modifier to:

        <img src="[[+tv.ImagePath]]" alt="" />


        I’ve tried many variations of the call I could think of, but no image gets displayed.

        Here are two calls I tried:
        <img src="[[+!tv.ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />

        <img src="[[+tv.!ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />


        Also, where can I see a list of available parameters. The snippet source code was of no help in that regard.

          A MODx Fanatic
          • 473
          • 70 Posts
          Quote from: treigh at Nov 24, 2010, 09:30 PM

          Hi all,

          Is there a way to use PHPThumbOf with getResources TVs?

          I have this image path that I’d like to apply the modifier to:

          <img src="[[+tv.ImagePath]]" alt="" />


          I’ve tried many variations of the call I could think of, but no image gets displayed.

          Here are two calls I tried:
          <img src="[[+!tv.ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />

          <img src="[[+tv.!ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />


          Also, where can I see a list of available parameters. The snippet source code was of no help in that regard.



          in getResources snippet you must set properties &includeTVs=`1` and &processTVs=`1`
            • 33987 ☆ A M B ☆
            • 197 Posts
            And in your chunk you would have to do it like this:
            <img src="[[+tv.ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />
            
              Sterc Internet & Marketing | MODX Founding Partner | Chairman of the MODX Advisory Board

              In need of a MODX consult? Try our MODX Developers Experts!
              • 7557
              • 61 Posts
              Quote from: treigh at Nov 24, 2010, 09:30 PM


              Also, where can I see a list of available parameters. The snippet source code was of no help in that regard.



              http://phpthumb.sourceforge.net/demo/docs/phpthumb.readme.txt
                • 30585
                • 833 Posts
                I must say that I needed some patience.

                I did try this:
                <img src="[[+tv.ImagePath:phpthumbof=`&f=jpeg&q=75&wl=200&hp=200`]]" alt="" />

                But because the page was taking too long to load, I concluded that the call didn’t work. But it did work after too minutes of loading.

                The first time the image is resized is awfully long though.

                Thanks for your help
                  A MODx Fanatic
                  • 27985
                  • 54 Posts
                  Sorry if this has already been answered...

                  Is there a way to use this within a snippet? IE send a path and params and get back a path to a resized image?

                  Thanks,
                    MODx 2.0.6
                    PHP 5.3.3
                    MySQL 5.1.50
                    • 17329
                    • 53 Posts
                    @someone

                    I did it this way and it works for me :

                    $params = array();
                    $params['input'] = $image; // URL to the large image
                    $options = '&f=jpg';
                    $options .= '&w='.$thumbnailsWidth;
                    $options .= '&h='.$thumbnailsHeight;
                    $options .= '&zc=1';
                    $options .= '&fltr=usm|'.$thumbnailsSharpen;
                    $params['options'] = $options;
                    $thumbnail = $modx->runSnippet("phpthumbof", $params);
                    
                      • 8522
                      • 145 Posts
                      I got phpthumbof to do "text to font" rendering. see example:
                      [[*canvas:phpthumbof=`&f=png&w=600&h=24&zc=1&fltr=wmt|Welcome to MODx|17|TL|000000|assets/fonts/Helvetica.ttf|100|0|0|ebecec|0`]]


                      But as a workaround I need to specify an image to call phpthumb as output filter. phpthumb can create new images without a source file, see http://phpthumb.sourceforge.net/demo/docs/phpthumb.readme.txt
                      new = create new image, not thumbnail of existing image.
                             Requires "w" and "h" parameters set.
                             [ex: &new=FF0000|75] - red background, 75% opacity
                             Set to hex color string of background. Opacity is
                             optional (defaults to 100% opaque).


                      In this case it would make a lot of sense to use phpthumbof as snippet or would you suggest to write a different snippet to achieve this?