We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29451
    • 1 Posts
    Quote from: lmestre at Dec 10, 2010, 03:07 AM

    @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);
    



    Sorry, but I am new to PHP and trying to wrap my head around this. Could you explain how to call this and what it’s actually doing?

    As far as I can tell, it creates an array called params which gets passed the URL when you call it. Then it parses the different options that get passed to the snippet into the ’options’ element.

    How exactly does the .= work? Does it just keep adding on to the ’options’ element each new variable? And then this long line of variables gets added to the params array, and somehow the ’input’ and ’options’ gets sorted out in the end?

    Why does $image not get a period before it, but all the other options do?

    I’ve been looking at intro PHP array stuff, and I can’t figure out exactly what’s going on here. Any help would be much appreciated. I feel like understanding this would help me understand a lot about how to manipulate snippets in MODx and PHP in general.
      • 20618
      • 7 Posts
      I can’t get this to work inside getResources. I did set includeTVs=`1` and processTVs=`1`. and the call is asfollow:

      <img src="[[+tv.img_level3_product:phpthumb=`&f=jpeg&q=75&w=190`]]" alt="[[+tv.title_nl]]" width="190" class="product" />


      It shows the original image and not the thumbnail, even after clearing the cache.

      Im using MODx 2.0.6-pl2 traditional with getResources 1.2.2-pl and phpThumbOf 1.1.0-rc1

      ---------------------------------------------------------
      MySQL 5.0.45 | PHP 5.2.13 | Linux | Apache/2.2.3 (CentOS)
      ---------------------------------------------------------

      Ok it works and the solution was very simple:

      <img src="[[+tv.img_level3_product:phpthumbof=`&f=jpeg&q=75&w=190`]]" alt="[[+tv.title_nl]]" width="190" class="product" />


      so instead of using :phpthumb you need to use :phpthumbof !!
        • 6408
        • 58 Posts
        Im trying to use phpthumbof with gallery.

        Im calling a single image in a chunk and trying to convert it to a thumbnail. However Im getting a whole load of output code and duplicated items repeated over and over on the screen.

        My snippet call is:
        [[!getResources? &parents=`22`&limit=`4` &showHidden=`1` &tpl=`popularProductBox` &includeTVs=`1` &processTVs=`1`]]


        Then my chunk is:
        <div class="productBox"><h4>[[+pagetitle]]</h4>
        [[+tv.photo:phpthumbof=`&f=jpeg&q=75&wl=75`]] <p>[[+description]]</p>
        <p><a href="#">Find out more...</a></p>
        </div>


        And here is a sample of the output:

        [2011-01-17 15:23:41] (ERROR @ /xxxxxx/index.php) [phpThumbOf] Could not generate thumbnail: - Debug: Array ( [0] => phpThumb() v1.7.9-200712090829 in file "phpthumb.class.php" on line 216 [1] => setCacheDirectory() starting with config_cache_directory = "/home/sites/xxx.xx.xx/public_html/xxxxxx/core/cache/phpthumb/" in file "phpthumb.class.php" on line 919 [2] => setting config_cache_directory to realpath(/home/sites/xxx.xx.xx/public_html/xxxxxx/core/cache/phpthumb) = "/home/sites/xxx.xx.xx/public_html/xxxxxx/core/cache/phpthumb" in file "phpthumb.class.php" on line 947 [3] => setCacheDirectory() starting with config_cache_directory = "/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache/" in file "phpthumb.class.php" on line 919 [4] => setting config_cache_directory to realpath(/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache) = "/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 947 [5] => setSourceFilename() set $this->sourceFilename to "" in file "phpthumb.class.php" on line 243 [6] => skipping CleanUpCacheDirectory() set to purge (30.0 days; 100.00MB; 10,000 files) in file "phpthumb.class.php" on line 652 [7] => file_exists() = 0 in file "phpthumb.class.php" on line 1101 [8] => is_executable() = 0 in file "phpthumb.class.php" on line 1102 [9] => using ImageMagick path from `which convert` (/usr/bin/convert) in file "phpthumb.class.php" on line 1121 [10] => ImageMagick version checked with "convert --version" in file "phpthumb.class.php" on line 1148 [11] => ImageMagick did not return recognized version string (Version: ImageMagick 6.4.3 2008-08-28 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC) in file "phpthumb.class.php" on line 1154 [12] => ImageMagick convert --version says "Unknown" in file "phpthumb.class.php" on line 1157 [13] => $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 884 [14] => $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 895 [15] => $this->thumbnailFormat set to $this->f "jpeg" in file "phpthumb.class.php" on line 902 [16] => $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 912 [17] => $this->sourceFilename set to "/home/sites/xxx.xx.xx/public_html//xxxxxx/" in file "phpthumb.class.php" on line 813 [18] => phpThumb() v1.7.9-200712090829 "/home/sites/xxx.xx.xx/public_html//xxxxxx/" does not exist in file "phpthumb.class.php" on line 3652 [19] => setCacheDirectory() starting with config_cache_directory = "/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 919 [20] => setting config_cache_directory to realpath(/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache) = "/home/sites/xxx.xx.xx/public_html/xxxxxx/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 947 [21] => SetCacheFilename() _src set from md5($this->sourceFilename) "/home/sites/xxx.xx.xx/public_html//xxxxxx/" = "706e91ccbc8d4d654485fad12a0734a6" in file "phpthumb.class.php" on line 3074 [22] => SetCacheFilename() _par set from md5(_farC_wl75_dpi150_q75) in file "phpthumb.class.php" on line 3107 [23] => starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 2894 [24] => GetImageSize("/home/sites/xxx.xx.xx/public_html//xxxxxx/") failed in file "phpthumb.class.php" on line 2917 [25] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1232 [26] => phpThumb_tempnam() returning "/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbj1ng3j" in file "phpthumb.class.php" on line 3867 [27] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1189 [28] => ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1189 [29] => GetImageSize(/home/sites/xxx.xx.xx/public_html//xxxxxx/) FAILED with error "[2011-01-17 15:23:41] (ERROR @ /home/sites/xxx.xx.xx/public_html/xxxxxx/core/model/phpthumb/phpthumb.class.php : 1312) PHP warning: getimagesize(/home/sites/xxx.xx.xx/public_html//xxxxxx/<img src="/xxxxxx/assets/components/gallery/connector.php?action=web/phpthumb&w=200&h=143&f=png&src=/xxxxxx/assets/components/gallery/files/2011/01/booklet.jpg" alt="" title="Booklet" class="" />) [function.getimagesize]: failed to open stream: No such file or directory " in file "phpthumb.class.php" on line 1318 [30] => GetImageSize(/home/sites/xxx.xx.xx/public_html//xxxxxx/) failed in file "phpthumb.class.php" on line 1460 [31] => Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 1807 [32] => ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1186 [33] => ImageMagick called as (convert -density 150 -quality 75 -interlace line "/home/sites/xxx.xx.xx/public_html//xxxxxx/[0]" jpeg:"/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbj1ng3j" 2>&1) in file "phpthumb.class.php" on line 1826 [34] => ImageMagick failed with message (sh: jpeg:/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbj1ng3j: No such file or directory) in file "phpthumb.class.php" on line 1834 [35] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 2924 [36] => SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 2873 [37] => SetOrientationDependantWidthHeight() setting w="75", h="0" in file "phpthumb.class.php" on line 2889 [38] => EXIF thumbnail extraction: (size=0; type=""; 0x0) in file "phpthumb.class.php" on line 2976 [39] => starting SourceImageToGD() in file "phpthumb.class.php" on line 3234 [40] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1232 [41] => phpThumb_tempnam() returning "/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbxryc2x" in file "phpthumb.class.php" on line 3867 [42] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1189 [43] => ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1189 [44] => GetImageSize(/home/sites/xxx.xx.xx/public_html//xxxxxx/) FAILED with error "[2011-01-17 15:23:41] (ERROR @ /home/sites/xxx.xx.xx/public_html/xxxxxx/core/model/phpthumb/phpthumb.class.php : 1312) PHP warning: getimagesize(/home/sites/xxx.xx.xx/public_html//xxxxxx/<img src="/xxxxxx/assets/components/gallery/connector.php?action=web/phpthumb&w=200&h=143&f=png&src=/xxxxxx/assets/components/gallery/files/2011/01/booklet.jpg" alt="" title="Booklet" class="" />) [function.getimagesize]: failed to open stream: No such file or directory " in file "phpthumb.class.php" on line 1318 [45] => GetImageSize(/home/sites/xxx.xx.xx/public_html//xxxxxx/) failed in file "phpthumb.class.php" on line 1460 [46] => Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 1807 [47] => ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1186 [48] => ImageMagick called as (convert -density 150 -thumbnail 75x -quality 75 -interlace line "/home/sites/xxx.xx.xx/public_html//xxxxxx/[0]" jpeg:"/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbxryc2x" 2>&1) in file "phpthumb.class.php" on line 1826 [49] => ImageMagick failed with message (sh: jpeg:/home/sites/xxx.xx.xx/public_html/xxxxxx/pThumbxryc2x: No such file or directory) in file "phpthumb.class.php" on line 1834 [50] => starting ImageCreateFromFilename(/home/sites/xxx.xx.xx/public_html//xxxxxx/) in file "phpthumb.class.php" on line 3149 [51] => empty $filename or GetImageSize(/home/sites/xxx.xx.xx/public_html//xxxxxx/) failed in file "phpthumb.class.php" on line 3198 [52] => Populating $rawimagedata in file "phpthumb.class.php" on line 3206 [53] => cannot fopen(/home/sites/xxx.xx.xx/public_html//xxxxxx/) in file "phpthumb.class.php" on line 3217 [54] => Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3283 [55] => $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3335 [56] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3337 [57] => phpThumb() v1.7.9-200712090829 Unknown image type identified by "" () in SourceImageToGD()[3449] in file "phpthumb.class.php" on line 3652 [58] => SourceImageToGD() failed in file "phpthumb.class.php" on line 323 
        
          • 6408
          • 58 Posts
          doesnt matter any more. Revo users are left out in the cold when it comes to forum support - goodbye modx, its been good to know you... noone to blame that has created modx but the modx evo documentation was easy to follow, as was the support structure for snippets, etc. Now its a continual struggle searching for relevant forum posts that mixes both evo and revo solutions 0- and understanding how snippet calls, etc were made were comprehensively documented and the resources were there to help, as were the people on the forums. I understand it takes contributors to help document what is a complex system - but the lack of resources combined with a lack of forum help is just a frustration.

          It seems now that snippet calls are *way* more complicated above and beyond what Evo’s core aim was - to build a cms system that was easy to implement for front-end developers, with clear and easily defined snippet calls. Now the snippet calls are becoming a complex string of paremeters that need clear understanding, and above all definitions. Unless you have an insight into how the core and these snippets were developed, you stand little chance of understanding it, and the lack of documentation means that web designers are left out in the cold.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Also in Evo, any of the more complex snippets could get some very ugly parameter lists. Wayfinder, Jot, Ditto, WebLoginPE come to mind. There probably aren’t as many "simple" snippets for Revo because in many cases they aren’t necessary; the functionality is built-in. Often these "simple" snippets were only to provide support functionality to other major snippets; the Revo versions have the functionality built-in. I read the forums several times a day and see tons of very interesting support posts by Jason, Shaun, Ryan and the rest of the core team. Occasionally I get caught out replying to a Revo question, but that’s only if I’m not paying attention to the section of the forum I’m reading. And don’t forget the IRC channels; those are usually very active as well.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 25663 MODX Staff
              • 12,272 Posts
              If you find Revo too complex, overkill or otherwise not suitable, you’re perfectly OK sticking with Evo (it’s not going anywhere).

              We agree the forum organization needs an overhaul, and we’re working on the forum migration right after the new site comes out of beta (http://beta.modx.com).
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                But does phpthumbof work on Evo?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 28215
                  • 4,149 Posts
                  phpthumbof does not support Gallery compatibility at this time.
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 6408
                    • 58 Posts
                    thanks guys i do appreciate the feedback and the hardwork you put into this, im sorry if i sounded rude - its just really frustrating if you try something you think will work and your enthusiastic about a project but cant get it done. so thanks for the feedback, i wish i had known the gallery / phpthumbof issue earlier. And i genuinely wish i could contribtute more to helping to understand how modx revo works. anyway perhaps this isnt the place for this conversation. I wish everyone well with revo,and the responses here from the team reflect their commitment to it.
                      • 29730
                      • 3 Posts
                      Quote from: someone at Nov 03, 2010, 01:48 PM

                      Any idea why I am getting a crazy path back? (/assets/components/phpthumbof/cache/var/www/vhosts/xxx/xxx.xxx.com/htdocs/assets/components/phpthumbof/cache/assets_images_papericon.jpg.44a3e177ce23da9b0c3708f158b746e0.png)

                      "/assets/components/phpthumbof/cache" should be sufficient and "/var/www/vhosts/xxx/xxx.xxx.com/htdocs/..." is my system mapping. Not sure how/why this would happen. Any idea?


                      I’m getting this sort of thing too.