We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20073
    • 8 Posts
    Hi

    How do we change the font and text alignement with image using MAxigallery
      • 27330
      • 884 Posts
      try in maxigallery CSS file.
        • 7923
        • 4,213 Posts
        Are you speaking about the picture watermarking or what text? any other than watermarking is done in stylesheets. For watermarking, there are parameters to align the text and change font.. you can see more info from MaxiGallery wiki page.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 36693
          • 66 Posts
          Sorry to revive this old thread, but it went unanswered, so I thought I’d recycle. Plus, it proves I searched! lol


          Is there any way to change the font face of the watermark? I can’t find any help in the wiki, forum or indeed code. Any ideas?
            • 7923
            • 4,213 Posts
            not without editing the code, sorry..

            There are few ways to go about it.. The current class that does watermarking uses imagestring() function to do the watermarking. That function takes the font "face" as an integer (1, 2, 3, 4 and 5 being possible values by default). You can define own fonts for this function by loading them up with imageloadfont(). That function returns an integer what is the loaded font’s identifier.

            But the fonts for imageloadfont() has to be in this specific php font format (gdf). You can convert fonts to gdf using this tool for example, but by quoting php manual "The font file format is currently binary and architecture dependent. This means you should generate the font files on the same type of CPU as the machine you are running PHP on.", e.g. if you convert the font using PC, you cannot use the font in a server on MAC.

            So if you want to try this, do the following:

            1. Convert a font to use with the tool I linked above and save it to maxigallery watermark folder for example.
            2. Open up /assets/snippets/maxigallery/maxigallery.class.php.
            3. In line #256 you should find this (line number not 100% accurate, depending on version in use):
            $thumb->txt_watermark_font=$watermark_font;
            

            replace that with:
            $thumb->txt_watermark_font=imageloadfont ($modx->config['base_path'].MAXIGALLERY_PATH.'watermark/thumbnail.gdf');
            

            Notice that for this example I used "thumbnail.gdf" as the font filename.

            Now try and see if it works.. I haven’t tried it, so don’t know, but that’s how it should work.

            Then another option if you want to use ttf fonts is to edit the thumbnail class what MaxiGallery uses. If you want to try that, do the following:

            1. Save a TTF font to the maxigallery watermark folder for example.
            2. Open up /assets/snippets/maxigallery/watermark/Thumbnail.class.php.
            3. In lines #380 and #398 you will find the following:
            imagestring ( $this->img["des"], $this->txt_watermark_font, $this->calc_text_position_H() , $this->calc_text_position_V(), $this->txt_watermark,$txt_color);
            

            replace those with:
            imagettftext( $this->img["des"], 10, 0, $this->txt_watermark_Vmargin, $this->txt_watermark_Hmargin, $txt_color, 'arial.ttf', $this->txt_watermark);
            

            Where 10 is the font size, 0 is the angle of the text and arial.ttf is the font file (in watermark folder). But with this implementation you loose the functionality of &..._watermark_valign and &..._watermark_halign parameters, and you need to use &..._watermark_txt_vmargin and &..._watermark_txt_hmargin parameters to set the x and y position for the watermark text in pictures (so they do not control the margin anymore).

            Haven’t tried this either, but it should work too..

            I hope these answer to your questions, report back with results! smiley


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 36693
              • 66 Posts
              I will do! Thanks for the very comprehensive reply.

              I’ll give the GDF way a shot, as it sounds like it will be more adaptable for others’ use as it keeps all the functionality.

              Loving maxigallery, by the way!
                • 36693
                • 66 Posts
                Unfortunately, I gave in. I have resorted to creating an image in photoshop and sticking with the easy method of picture watermarking. Deadlines forced me to abandon my curiosity. However, I am very pleased with the result, as it was my first real production from photoshop.

                I used shadowing to ensure that the white text works even on light backgrounds, and it looks neat without compromising the photo.

                I’ll keep the thread tagged just in case I try again in the future.