ACF Library

CalendarWithImage

Back to List

Description: Draw a calendar month with a image on top, logo, qrCode, etc.

FileMaker Prototype:

Set Variable [$res; ACF_Run("CalendarWithImage"; date_month;  Container_pict;  string_Poem)]

Category: IMAGES

Dependencies

  • drawCalendar: A function to draw a calendar image using the Image Drawing capabilities.

Function source:

Function CalendarWithImage ( date month, Container pict, string Poem  )
   string ys = string (month, "%Y"); 
   string ms = string (month, "%m"); 

   float width = 210/25.4*300; 
   float height = 297/25.4*300; 

   string res = drawCalendar ( month, width, 300.0, 7 );
   string path = $$ImgPath; 
   array string mnd = {
      "January", "February", "March", "April", "May", "June",
      "July", "August", "September", "October", "November", "December"
   }; 
   string pictSize = get_ImageSize(pict); 
   array string sz = explode ("x", pictSize); 
   int pictw = int(sz[1]); 
   int picth = int(sz[2]); 

   JSON img = NewImage (width, height, JSON ( "color", "white", "dpi", 300)); 

   float lm = width *0.05; 
   float rm = width *0.05; 
   float imgw = width-2*lm; 
   float imgh = picth/pictw * imgw; 

   ImageAddImage ( img, lm, lm, imgw, imgh, ":pict" );

   float caltop = lm+lm+imgh; 
   string calSize = get_ImageSize(path);
   array string szC = explode ("x", calSize); 
   int Calw = int(szC[1]); 
   int Calh = int(szC[2]); 

   ImageAddImage ( img, 0, caltop, width, Calh/Calw*width, path );

   // Add a poem below the calendar. 
   if (Poem != "") then
      float PoemStartY = Calh/Calw*width+caltop-50; 
      float PoemHight = 120.0; 
      JSON fontPoem    = JSON("name", "Helvetica", "size", 40, "color", "003366", "style", "italic");
      imageSetFont(img, fontPoem);
      ImageDrawTextBox (img, lm, PoemStartY, imgw, PoemHight, "– " + Poem + " –", JSON("align", "center", "valign", "top"));
   end if

   // Place the logo: 
   string logo = "/Users/ole/Prosjekter/dsCodeCompiler/html_root_path/images/horneks-logo-1.png"; 
   string logodim = get_ImageSize(logo); 
   array string logoSc = explode ("x", logodim); 
   int logoW = logoSc[1]; 
   int logoH = logoSc[2]; 
   float logoRatio = logoW/logoH; 
   float scaledW = width * 0.15; 
   float scaledH = scaledW / logoRatio; 

   ImageAddImage ( img, lm+imgw-scaledW, PoemStartY-scaledH*0.1, scaledW, scaledH, logo );

   // Add a QR image in the bottom right corner of the image. 

   JSON styleQR = JSON(
        "type",    "QR",
        "fgColor", "black",
        "bgColor", "white",
        "ecLevel", "M",
        "border",  4,
        "rotate",  0
    );

    // Center-ish placement of the QR
    float qrDim = width *0.07; 
    ImageAddBarcode (
        img,
        lm+imgw-qrDim, lm+imgh-qrDim,          // x,y
        qrDim, qrDim,        // width, height
        "https://horneks.no",           // QR content
        styleQR
    );

   string outPathDir = documents_directory() + "Calendars/New";
   // (You might want to ensure directory exists using your filesystem utils.)
   res = create_directory(outPathDir); 

   string outPath = outPathDir + format("/PictCalendar-%s-%s-%s-%d.png",
                                       ys+ms, mnd[int(ms)], ys, int(width));

   SaveImage ( img, outPath );
   $$ImgPath2 = outPath; 

   return string (img); 

end

The CalendarWithImage

Download the 2026 calendar from Our download area under Demo's and "ACF Calendar 2026" to see its result.

Back to List