We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hi,
    I've read several pages about phpthumb, I thought that the problem with spaces inside filename had been fixed...but in my site it doesn't work:

    I use phpthumbof with more ore less 10 images in a page: images without spaces are correctly transformed, images with spaces are not transformed, giving also error in Apache like this:

    [Thu Oct 26 12:43:00 2011] [error] [client xx.yy.zz] File does not exist: /var/www/mydomain.com/images/this
    when the image name is "this nice earth.jpg"

    can it also be the problem for slow loading?
    Thanks in advance,
    Alessandro
      TilliLab | MODX Ambassador
      website
      • 36891
      • 5 Posts
      You really shouldn't have spaces in your filenames -> use dash / underscore instead.
      • You are right,
        the problem is not me but my customers...the site is managed by a group of people/editors, and sometimes one of them uploads an image with a space in the filename...

        I read in the forum and in the Github that this problem should have been fixed adding the line
            return str_replace(' ','%20',$cacheUrl); 


        but in my case it doesn't seem to work, if I give a look at MODx log I read this:

        [2011-11-02 09:32:39] (ERROR @ /site/index.php) [phpThumbOf] Could not generate thumbnail: http://localhost/site/images/notizie/new site.jpg - Debug: Array
        (...
            [26] => GetImageSize("http://localhost/site/images/notizie/new site.jpg") failed in file "phpthumb.class.php" on line 3078
        ...
            [31] => GetImageSize(http://localhost/site/images/notizie/new site.jpg) FAILED with error "" in file "phpthumb.class.php" on line 1409
          [32] => GetImageSize(http://localhost/site/images/notizie/new site.jpg) failed in file "phpthumb.class.php" on line 1556
            [36] => ImageMagick failed with message (error : Unknown IO error
        convert: no decode delegate for this image format `/tmp/magick-XXhjLq6H' @ error/constitute.c/ReadImage/532.
        convert: no data returned `http://localhost/site/images/notizie/new site.jpg' @ error/url.c/ReadURLImage/226.
        convert: missing an image filename `jpeg:/var/www/site/pThumbxl1Tij' @ error/convert.c/ConvertImageCommand/2970.) in file "phpthumb.class.php" on line 1963
        ...
        


        I've tested it in different server, always linux based, now I'm testing it locally with Ubuntu server,
        PHP Version 5.3.5-1ubuntu7.2

        I wonder if I could add a prefilter, like: if there is a space in the name DON'T use phpthumb, otherwise go on

        Do you think this could be a solution?
          TilliLab | MODX Ambassador
          website
        • mm,
          I've tried with:

          <img src="[[++site_url]][[*my_image:cut_spaces:phpthumbof=`w=150&h=150&zc=1`]]" />


          where "cut_space" is a snippet to remove spaces inside the name, but of course with this solution it doesn't find the image...

          [ed. note: tillilab last edited this post 12 years, 6 months ago.]
            TilliLab | MODX Ambassador
            website
            • 33968
            • 863 Posts
            You almost got it - make a simple output modifier that will replace the spaces in the filename with %20 - the html code for a space.

            Create a new snippet called spacereplace :
            <?php
            return str_replace(' ','%20',$input);
            


            Then in your template:
            <img src="[[*imagetv:spacereplace]]" />
            


            A better solution would be a plugin that formats the filename and removes the spaces at the time of upload....
            • Thanks Lucas!

              I made it work changing a little:

              <img src="[[++site_url]][[!phpthumbof? &input=`[[++base_path]]images/[[*my_tv_image:cut_spaces]]` 
              &options=`&w=200&h=200&zc=0&aoe=0&far=0`]]" />


              One problem was the tv setting with the base URL pointing to
              [[++site_url]]images/

              I had to remove it.

              Another problem was passing the base_path to phpthumbof, I solved using the snippet.

              There is a last problem...but I'm afraid it depends on phpthumb script: cpu usage becomes very high to render the output image...
              if I have 6 images in the same page, not yet cached, phpthumb almost block Apache...

              Is it a known issue?

                TilliLab | MODX Ambassador
                website
              • I am having a similar problem with phpthumbof in MODx Revolution 2.2.0-pl2 When there is a space in the path or file name it throws an error that it cannot resize the image even if I replace the spaces with %20. If I use it as a modifier it returns the unmodified image but if I use it as a snippet it returns nothing. The debug log returns the following:

                [9] => ImageMagickThumbnailToGD() aborting because cannot find convert in $this->config_imagemagick_path (), and `which convert` returned (which: no convert in (/bin:/usr/bin)) in file "phpthumb.class.php" on line 1131
                  • 38339
                  • 41 Posts
                  maybe this solution is helpful?
                    Revolution 2.2.6
                  • Thank you, I did apply this work-around to the site. It is not ideal because it could be overwritten in an update but it works. I know spaces are not proper form but try telling that to a client who wants their site to just work.
                    • It was pointed out on GitHub that there is an issue in phpthumbof 1.3.1 that may be causing this and some rather severe errors on some sites.

                      https://github.com/splittingred/phpThumbOf/issues/34 and https://github.com/splittingred/phpThumbOf/issues/36