Jump to content

Image Orientation


Jdunning

Recommended Posts

I have downloaded the sample file and looked at it and I am looking for a way to set the image box orientation from the javascript

 

ie if I could add the ImgHorizontal1 field as a Var

if it returns 0 then nothing if it returns 2700 then change the image orientation?

 

var Var1 = "Image1";

var Var2 = ".jpg";

var Var3 = "";

var Var4 = Field("ImagePath1");

var Var5 = Field("ImgHorizontal1");

 

temp = '';

var_extension = '';

has_extension = '';

 

if (Var3 == "")

Var3 = Var3;

else

{

if (FusionPro.isMac)

Var3 = Var3 + ":";

else

Var3 = Var3 + "\\";

}

 

for (i=0; i<Field(Var1).length; i++)

{

temp = Mid(Field(Var1), Field(Var1).length-i,1);

var_extension = temp + var_extension;

 

if(var_extension == ".png" || var_extension == ".pdf" || var_extension == ".gif" || var_extension == ".eps" || var_extension == ".tif" || var_extension == ".tiff" || var_extension == ".jpg" || var_extension == ".jpeg")

{

has_extension = "true";

i=Field(Var1).length;

}

else

has_extension = "false";

}

 

if(has_extension == "true")

Pic = CreateResource(Var3 + Field(Var1), "graphic", true);

 

else

{

if(Var2 == ".jpg")

{

Pic = CreateResource(Var3 + Field(Var1) + ".jpeg", "graphic", true);

if (Pic.exists)

Pic = Pic;

else

Pic = CreateResource(Var3 + Field(Var1) + ".jpg", "graphic", true);

}

 

 

if(Var2 == ".tif")

{

Pic = CreateResource(Var3 + Field(Var1) + ".tif", "graphic", true);

if (Pic.exists)

Pic = Pic;

else

Pic = CreateResource(Var3 + Field(Var1) + ".tiff", "graphic", true);

}

 

 

if(Var2 == ".png" || Var2 == ".pdf" || Var2 == ".eps" || Var2 == ".gif")

{

Pic = CreateResource(Var3 + Field(Var1) + Var2, "graphic", true);

}

 

}

 

if (Pic.exists)

{

return Pic;

}

 

else

{

return CreateResource(Var3 + Var4, "graphic", true);

}

Link to comment
Share on other sites

You don't set the orientation of the box in JavaScript. In the example, you have two boxes, one for landscape images, one for portrait images, each of which calls a rule which determines whether it can accommodate the graphic.

 

If you already have a rule returning a graphic resource, then that doesn't need to be modified. Just change the first line of each rule ("landscape" and "portrait" in the example) to call out your existing rule, like so:

var MyResource = Rule("YourGraphicRule");

Link to comment
Share on other sites

var MyResource = Rule("Insert Pose 8");

if (IsResourceLandscape(MyResource))

return MyResource;

//else

return NullResource();

 

 

I get an error line 2 ReferenceError: IsResourceLandscape is not defined

Edited by Jdunning
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...