Jump to content

Image Orientation


Jdunning

Recommended Posts

I am looking for a simple rule to include in the Graphic insert rule that would check the data file for the orientation and if the value is 0 do nothing but if the orientation is 2700 it would rotate the image. Thanks
Link to comment
Share on other sites

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

Archived

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

×
×
  • Create New...