We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25483
    • 741 Posts
    Can I crop the images to a given size instead of fit it inside the given size??

    I have a (header) slideshow on a site in which the images have to be the same size always. For example the size is 200*100px, but now it fit’s the image inside that area. So for example some images get a size of 193*100px instead of 200*100px.

    How can I force MaxiGallery to create images of exactly 200*100px and with a watermark?
      with regards,

      Ronald Lokers
      'Front-end developer' @ h2o Media

      • 7923
      • 4,213 Posts
      MaxiGallery can’t crop images. Sorry. And it always resize them by preserving the aspect ratio.

      But what you can do instead is that you make maxigallery to store only the uploaded original images, by using &keep_big_img and unlimited max size for big image.

      Then use phpThumb snippet in maxigallery templates to resize that big image to what ever size you want. Or you can make maxigallery to just store the images always as they are uploaded and use phpThumb snippet in every maxigallery template to resize and filter them the way you want.



        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 7231
        • 4,205 Posts
        I recently used PHP Thumbnailer Class v2.0 and it handles cropping. The biggest problem with cropping though is that it will always be based on predefined point (or center) and sometimes it may not be the best place to crop a given image.

        cropFromCenter($cropSize)
        Create a square crop of $cropSize pixels from the center of the image. Example:

        //create a 100x100 pixel crop from the center of an image
        $thumb->cropFromCenter(100);
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 25483
          • 741 Posts
          Quote from: doze at Oct 29, 2008, 05:18 AM

          MaxiGallery can’t crop images. Sorry. And it always resize them by preserving the aspect ratio.

          But what you can do instead is that you make maxigallery to store only the uploaded original images, by using &keep_big_img and unlimited max size for big image.

          Then use phpThumb snippet in maxigallery templates to resize that big image to what ever size you want. Or you can make maxigallery to just store the images always as they are uploaded and use phpThumb snippet in every maxigallery template to resize and filter them the way you want.

          So this will be the idea to do:

          Let maxigallery resize the picture to a size bigger then needed (to not store a full 2 / 4mb image). And then let phpThumb make the right sized image with the watermark on it?

          And can I do this with 3 different maxigallery templates? I need 2 big photo’s with a different watermark and a small one with a watermark.
          Am I right if I say that I just need to use another maxigallery template for every different output? And can I use multiple calls on 1 page?

          Quote from: dev_cw at Oct 29, 2008, 05:49 AM

          I recently used PHP Thumbnailer Class v2.0 and it handles cropping. The biggest problem with cropping though is that it will always be based on predefined point (or center) and sometimes it may not be the best place to crop a given image.

          cropFromCenter($cropSize)
          Create a square crop of $cropSize pixels from the center of the image. Example:

          //create a 100x100 pixel crop from the center of an image
          $thumb->cropFromCenter(100);

          That would not be a problem for me if it just use the center as reference point. The problem I have is that the image area I have doesn’t have the same aspect ratio as a normal photo. So a normal photo is a little bit shorter (in width) then the area used.
            with regards,

            Ronald Lokers
            'Front-end developer' @ h2o Media

            • 7923
            • 4,213 Posts
            Quote from: MediaGuy at Oct 29, 2008, 06:46 AM

            So this will be the idea to do:

            Let maxigallery resize the picture to a size bigger then needed (to not store a full 2 / 4mb image). And then let phpThumb make the right sized image with the watermark on it?

            And can I do this with 3 different maxigallery templates? I need 2 big photo’s with a different watermark and a small one with a watermark.
            Am I right if I say that I just need to use another maxigallery template for every different output? And can I use multiple calls on 1 page?
            Yes, that’s correct. You will just use the phpThumb PHx modifier that can be found from resources in MaxiGallery templates. The input image will always be the same originally uploaded and resized image by maxigallery, and you feed that to phpThumb to make it correct size with needed croppings. phpThumb caches all the images it creates, so this doesn’t give much overhead to the process.

            You can use multiple calls on one page as allways, just remember to use the &manage_target and &is_target parameters if you want to manage the galleries from there.


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 25483
              • 741 Posts
              Ok, I am trying to use the PHx modifier right now. Can I config Maxigallery to only save the 1 version of the image? I only want to create one image with a maximum size.
                with regards,

                Ronald Lokers
                'Front-end developer' @ h2o Media

                • 7231
                • 4,205 Posts
                But what you can do instead is that you make maxigallery to store only the uploaded original images, by using &keep_big_img and unlimited max size for big image.
                Is this what you are looking to do?
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don't know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 25483
                  • 741 Posts
                  Quote from: dev_cw at Nov 07, 2008, 05:23 AM

                  But what you can do instead is that you make maxigallery to store only the uploaded original images, by using &keep_big_img and unlimited max size for big image.
                  Is this what you are looking to do?

                  Yes, I want maxigallery to create just 1 image with a maximum height/width of 1000 px. And then use phpthumb to create the right thumbnails smiley I almost have it working, but I also get a thumbnail that I don’t need. And besides that; the cache of phpthumb doesn’t work :S
                    with regards,

                    Ronald Lokers
                    'Front-end developer' @ h2o Media

                    • 7923
                    • 4,213 Posts
                    No, MaxiGallery will always create it’s own thumbnail.. but what does it matter? smiley

                    You can set 0 to the max size for the normal picture, so there will be the original uploaded one and a thumbnail, you just won’t use the thumbnail anywhere. If you want to get rid of it, you need to comment the parts from maxigallery code where it’s done.


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 25483
                      • 741 Posts
                      Quote from: doze at Nov 07, 2008, 08:18 AM

                      No, MaxiGallery will always create it’s own thumbnail.. but what does it matter? smiley

                      You can set 0 to the max size for the normal picture, so there will be the original uploaded one and a thumbnail, you just won’t use the thumbnail anywhere. If you want to get rid of it, you need to comment the parts from maxigallery code where it’s done.

                      Hmz... ok! I think I will just leave it as it is, they are just a few kb. And they are used in the manage mode to aren’t they? Ok... just keep them smiley

                      Now I just need to solve my cache problem with phpthumb (base_dir restriction) laugh
                        with regards,

                        Ronald Lokers
                        'Front-end developer' @ h2o Media