We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1564
    • 31 Posts
    I have not found a general Support/Comments topic regarding autoGallery I will start a new topic over here. (I hope it’s ok)

    I have had a good experience with this snippet and I have integrated it in my project. Unfortunately I have got one problem.

    I have found out that automatic thumbnail generator is generating weird thumbs. Even though It does manage to resize and do what should the photos do look very flaky (fuzzy edges) and have a very big size if I take the photo quality into mind.

    Example
    --Original JPG (quality 60) has 200kB
    --Thumb auto resized 20kB (but very bad quality)
    --Thumb resized in Photoshop to the same size (quality 60) has 8kB

    Is it a general problem of all the automatic resizing tool, that the quality and size are dismal? What compression algorithm is usually used?

    Thanks for any suggestions!
    Regards, Andrew
      MODx is way ahead... Thanks for your work!
      • 1564
      • 31 Posts
      I have also not managed to find out in what order the photos are being output. It looks as if totally random order. I have tried to change names and date/time but it does not look as if it influences the order by any means. I ahve looked nito the code and the only part that could contain it should be this one:

      $output = '';
      while($entry = readdir($dir)) {
      if(!(($entry == '..')||($entry == '.')||(substr($entry, 0, 3) == 'tn_'))) {
      $path = $basepath . $mojeTV['value'] . '/' . $entry;
      $params['imgpath'] = $path;
      $filename = basename($path);
      $params['filename'] = $filename;
      $tnimgpath = $basepath . $mojeTV['value'] . '/tn_';
      $tnimgpath = $tnimgpath . $filename;


      Any thoughts? Thanks a lot!
        MODx is way ahead... Thanks for your work!
        • 24449
        • 81 Posts
        Hi!

        Sorry, I should watch this forum a bit more closely! Your email poked me into life though...

        AutoGallery was released a bit before it was really cleanly developed because I thought it might be handy to people that needed a similarly quick and dirty solution. I am working on a better version that I’ll put up soon.

        Regarding picture ordering I think it is ordered in whatever way the filesystem orders the files... Its alphabetical on our Fedora Linux server, so 01file comes before 1file comes before file comes before guile, etc. Ordering is definitely something I have added to the better version!

        Regarding resizing: there were some odd decisions taken about resizing - and, especially, cropping. I do the technical backed stuff and my mate does all the front-side, visual, humanities student stuff ( wink ) so I coded what he wants. I seem to remember that it forces things towards portrait format, so if you enter a width and a height it will crop the sides and stretch the top and bottom, even if the opposite would make far more sense. This could explain your dodgy quality? Alternately it could be really dodgy coding wink

        If you can point me to your site and give me any more details (on email if you’d prefer) I’d be happy to help. Although its 23:11 in the UK so it will be tomorrow...


        Ramsay


          • 24449
          • 81 Posts
          As a brief extra note: they thumbnails are build with "quality: 100" but thats the JPEG compression argument, so it explains the huge file size despite poor quality. Its probably an unfortunate interaction with the cropping thats causing your troubles.


          Ramsay
            • 1564
            • 31 Posts
            Thanks a ton for your input! cool

            As for the image quality I have prepared a few samples.
            tn_slokoa6.jpg (resized by the script) (Picture info - CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100)
            tn_slokoa6_ps.jpg (resized by Photoshop Q-100)
            tn_slokoa6_ps_q60.jpg (resized by Photoshop Q-60)

            The output by the script and the PS at q100 have the same size. That makes it certain that the compression is similar. Both have listed a compression ratio of 1.9 ... just the quality is different. (check the attachments)

            To get around the big size it would be posible to change the code in the snippet line:
            imagejpeg($targetimg, $tnimgpath, 100);
            changing the 100 to 60 or lower if I am not mistaken.


            As with the ordering I have encountered wierd ordering on the provider’s Linux box (don’t know the exact file system that is used). I have tried different namings as well as the 0001-00xx but without success. I will send you a link to the gallery on your email.

            Thanks again for your work and a good light snippet wink Its past midnight here as well so I am moving to bed as well.. Good night!
              MODx is way ahead... Thanks for your work!
              • 24449
              • 81 Posts
              Thats certainly the right line if you want to change the quality; I’ll make it an optional argument to the better version.

              It will be using whatever JPEG library is built in to your PHP install, so it will probably never compare to a shiny professional tool like Photoshop. Unfortunately those electrical cabinets contain lots of very small straight lines, which I would have expected to be tricky for anything but the best image resizing tool. Maybe I can reorder the resizing somehow; it could be that resizing then resampling would be better. Or something. Suggestions from the gallery (no pun intended) welcome! wink

              I’ll have a look today and try to release a better version of autoGallery. I’ve been meaning to revisit it for a while, so this is a good excuse.


              Ramsay
                • 17282
                • 283 Posts
                Hi .. This gall was also designed initially to work with quite large thumbs (width 300 I think) which it works better with and was designed with a very specific site in mind, on which it worked well, however, as Ramsay has pointed out it has been quite updated since then! I think its time Ramsay and myself got together packaged it properly documented it and released it into the wild!

                We have also integrated it now with Audio and Video playback and also Greybox
                  Everytime you use Flash ... a puppy dies .....
                  R.G Taylor
                  • 1564
                  • 31 Posts
                  Thanks for you comments! Really appreciated them..

                  I have managed to get around the thumb creation.. setting Q to 50 makes the size small and the quality issues are minor for me at the moment. In the end I can always repair it via Photoshop.

                  The only issue that is pretty important for me now is the ordering :-D I got stuck on this I am really puzzled how to make it order 0001->1000 oh lord smiley

                  Will your new version suppply some ordering options? Thanks a lot for your work!

                  Btw I am also using folder names via a TV (not the doc ID as by default)
                  $mojeTV = $modx->getTemplateVar('autogallery_folder', '*', $modx->documentIdentifier);
                  $dir = opendir($basepath . $mojeTV['value']);

                  Just a little suggestion for implemetation smiley

                  Thanks and looking forward for your new version!
                    MODx is way ahead... Thanks for your work!
                    • 24449
                    • 81 Posts
                    The quick and dirty way to do ordering is to replace:


                    $dir = opendir($basepath . $modx->documentIdentifier);
                    
                    $output = '';
                    while($entry = readdir($dir)) {
                    if(!(($entry == '..')||($entry == '.')||(substr($entry, 0, 3) == 'tn_'))) {
                    


                    with:



                    $dir = opendir($basepath . $docId);
                    
                    $output = '';
                    $filelist = array();
                    while($entry = readdir($dir)) {
                      if(!(($entry == '..')||($entry == '.')||(substr($entry, 0, 3) == 'tn_'))) {
                        array_push($filelist, $entry);
                      }
                    }
                    
                    sort($filelist);
                    
                    foreach($filelist as $entry) {
                    


                    I’ll try to make it a bit cleverer in the new version but thats working ok for me now. You can probably do clever things with the php sort command, it takes a second argument: http://us.php.net/manual/en/function.sort.php



                    Ramsay
                      • 1564
                      • 31 Posts
                      Thanks for the sorting code! Looks good to go smiley
                        MODx is way ahead... Thanks for your work!