Jump to content

Programming FusionPro determine what orientation should be displayed


Jenn Koder

Recommended Posts

This forum has always been so helpful, I searched for my issue but couldn't find anything that worked. That said, I have 55 photos that need be able to be ordered by clients, some of the photos are portrait and some are landscape. Ideally, they would select which photo they would like to request in a drop-down without having to choose the orientation themselves. Is there a way on my end to have FusionPro determine what orientation should be displayed? I have two pages in my file, one is 12 x 18 and named "Landscape" and the other is 18 x 12 and named "Portrait". I am happy to attach my file if needed.

Link to comment
Share on other sites

You can run FusionProTextMeasure on graphics to get a height and width. You might use a function like this:

function image_is_portrait(graphic_res)
{
    var tm = new FusionProTextMeasure;
        tm.CalculateTextExtent(graphic_res.content);
        
    return (tm.textHeight > tm.textWidth);
}

var my_image = CreateResource("photo.jpg", "graphic", true);
return image_is_portrait(my_image);

This would return true if the height is greater than width, ie portrait, or false if landscape.

Link to comment
Share on other sites

Change your data CSV to look like this:

Graphic
02_CPS625_20230329_0036.jpg
05_CPX097_20170808_0049-Edit-2.jpg

Alter the line in the javascript from
var my_image = CreateResource("photo.jpg", "graphic", true);
to
var my_image = CreateResource(Field("Graphic"), "graphic", true);

Link to comment
Share on other sites

I did that and I do not see the photos populate on my screen... I composed it anyway to see what would happen and I got this error message:

Graphic is not found or is not processed properly: 02_CPS625_20230329_0036.jpg.
Check for file existence and that it is of the proper format.
uncaught exception: Error: In Resource(), no resource named 02_CPS625_20230329_0036
Composing record #1, input record 1
Graphic is not found or is not processed properly: 02_CPS625_20230329_0036.jpg.
Check for file existence and that it is of the proper format.
 

I've attached the newly collected file.

Framed Photos 12 x 18 pti.zip

Link to comment
Share on other sites

When I extract that zip file and turn on preview it works without any changes. I think the issue is your jpg files don't live in the same directory as your template pdf. You would need to add the full path into the "Search Path" box in the composition window for it to see them.

If this is going to be a product on Marcom it would just be a matter of populating the Graphic dropdown with a Library Collection and you don't have to worry about paths so much. It will just pick up the graphic chosen.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...