Jump to content

Set a border around graphic (not graphic frame)


pmorgan

Recommended Posts

Good Afternoon,

 

Is it possible to set the border of an image in a rule?

 

I have a brochure and the user will be uploading an image

 

which will size itself to best fit within the frame. The images

 

being uploaded lack a border and need a border of black to appear around the image.

 

My issue is that I can put the border around the frame, but this only works when the image is set to fill the frame, and I need the border to be dynamic with the image instead.

 

Any thoughts?

Link to comment
Share on other sites

I'm adding a screenshot example. The image on the left is from the product, and you can see how the image is set to fill, and uses a border. Unfortunately the stretching of the image is an issue.

 

The superimposed image is the original file, and ideally, the image

in the product should maintain the proportions of the original, scale to fit the frame, and show a border around the picture (1 pt. thick, black).

 

-Parrish

 

 

Update:

 

I have also tried the graphic inline rule shown here:

 

return '<graphic resource="BioImage" width=6393.6 height=7156.8 scale=best alignv=center alignh=center>';

 

Can the border color be adjusted inside of this inline graphic rule?

 

-P

Ahmed_web.jpg.1b7d9a970abae89c3102ff7f084b2387.jpg

Link to comment
Share on other sites

  • 2 years later...

To my knowledge, it is not possible to have FP add a border to a graphic that does not have the same dimensions as the frame it is placed within.

 

The only thing I can think might work would be to place the image in a table cell and add a border programmatically to the cell, but I don't know for sure if this solution would work, or more importantly, be applicable to how you set up your template.

Link to comment
Share on other sites

The template that I'm working on is a postcard template which is filled with mostly variable text that is dropped in from the web. The picture is dropped in with this rule.

 

//this adds the agent picture to the postcard if there is one available based on their agent number

var Pic = new FusionProResource(Field("AgentNumber") + ".jpg", "graphic", true);
if (Pic.exists)
   return Pic;

ReportWarning("Image for " + Field("AgentNumber") + " not found");

 

There are roughly 500 different photos (agents) and I wouldn't guess that any of them will have the same dimensions as the graphic frame. Right now I have it set with 'Best Fit' and the clip setting selected. It works well. Ideally, we'd like to have a frame around the photo. However, as you said, there doesn't appear to be a way to add a frame within. I think I'm out of luck until I can convince our photographers to create a picture for each agent with the proper dimensions to accommodate the graphic frame.

 

Thanks for you input. I appreciate it.

Let me know if you ever run into a solution for it :)

Link to comment
Share on other sites

  • 1 month later...

From another thread:

Can this be used to solve the problem in this thread?

 

http://forums.pti.com/showthread.php?t=454&highlight=border+graphic

 

Meaning, can you make a dynamic table cell that fits to an uploaded graphic then make a border around it?

Yes, you could do something like this:

function InlineGraphicWithBorder(res, color)
{
   if (!res instanceof FusionProResource)
       throw "Not a resource: " + res;

   if (!res.exists)
       throw "Resource not found: " + res;

   var TM = new FusionProTextMeasure;
   TM.useTags = true;
   var err=TM.CalculateTextExtent(res.content);
   if (err)
       throw "Error measuring resource: " + res + ": " + TM.messages;

   var text = new FPTable;
   text.AddColumns(TM.textWidth);
   text.AddRows(1);
   text.Rows[0].Cells[0].Content = '<leading newsize=100>' + res.content;
   text.Rows[0].Cells[0].SetBorders("Thick", color, "Top", "Bottom", "Left", "Right");
   text.Rows[0].Cells[0].Margins = new FPTableMargins;
   text.Rows[0].Cells[0].Margins.Top = 0;
   text.Rows[0].Cells[0].Margins.Bottom = 0;
   text.Rows[0].Cells[0].Margins.Left = 0;
   text.Rows[0].Cells[0].Margins.Right = 0;
   return text.MakeTags();
}

Link to comment
Share on other sites

  • 3 weeks later...

Should this all be put into a graphic rule? I added your string and thought I edited it to apply to my pictures. It adds the photo but not within a table.

 

var Pic = new FusionProResource(Field("Agent Number") + ".jpg", "graphic", true);
if (Pic.exists)
   return Pic;

ReportWarning("Image for " + Field("Agent Number") + " not found");

function InlineGraphicWithBorder(res, color)
{
   if (!res instanceof FusionProResource)
       throw "Not a resource: " + Pic;

   if (!res.exists)
       throw "Resource not found: " + Pic;

   var TM = new FusionProTextMeasure;
   TM.useTags = true;
   var err=TM.CalculateTextExtent(Pic.content);
   if (err)
       throw "Error measuring resource: " + Pic + ": " + TM.messages;

   var text = new FPTable;
   text.AddColumns(TM.textWidth);
   text.AddRows(1);
   text.Rows[0].Cells[0].Content = '<leading newsize=100>' + Pic.content;
   text.Rows[0].Cells[0].SetBorders("Thick", color, "Top", "Bottom", "Left", "Right");
   text.Rows[0].Cells[0].Margins = new FPTableMargins;
   text.Rows[0].Cells[0].Margins.Top = 0;
   text.Rows[0].Cells[0].Margins.Bottom = 0;
   text.Rows[0].Cells[0].Margins.Left = 0;
   text.Rows[0].Cells[0].Margins.Right = 0;
   return text.MakeTags();
   }

 

Did I do something wrong there?

Link to comment
Share on other sites

The function Dan posted appears to return tagged text with an embedded table and an inline graphic. In order to use his code, you would place his function (unedited) in the JavaScript Globals and then call it from a separate text rule. So instead of returning "Pic" in a graphic rule like you have above, you would have a text rule with the following:

var Pic = new FusionProResource(Field("Agent Number") + ".jpg", "graphic", true);
return InlineGraphicWithBorder(Pic, "Green"); //use your color pre-defined in Advanced/Colors...

At least, that's how I think he intended it to be used. ;)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...