Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 21st, 2022, 11:29 AM
rkury14 rkury14 is offline
Regular Contributor
 
Join Date: May 2014
Location: Tempe, AZ
Posts: 56
Default Need help scaling images from url link

Hi,

I have a "CreateResource" rule here that seems to work on a URL Link with https://, but the images are coming in at different sizes. Too small or too big.
How can I add a scaling code into the rule to make the images uniform?

Here is the js rule.

var baseName = Field("URL");

var extensions = [".tif", "gif", ".png", ".jpg"];
for (var i in extensions)

{ var pic = CreateResource(Field ("URL") + extensions[i], + "graphic", true);
if (pic.exists)
return pic;}

Print("http://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-12/256/thumbs-up" + Field ("URL") + " not found.");
return CreateResource(Field ("URL"))
return NullResource();

Thank you,
Reply With Quote
  #2  
Old April 22nd, 2022, 11:19 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Need help scaling images from url link

You don't do the scaling in the rule. You do the scaling in the graphic frame, using the controls on the Graphic Frame palette. You probably want the Scaling set to Best Fit.

Once again, I would need to look at your template and your data to be able to make more specific suggestions.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old April 22nd, 2022, 12:16 PM
rkury14 rkury14 is offline
Regular Contributor
 
Join Date: May 2014
Location: Tempe, AZ
Posts: 56
Default Re: Need help scaling images from url link

I am using a Text Frame window to apply the url from the list. There is only shrink to fit, but that doesn't work in this instance. Should I be using a graphic window? Because that would be asking for a path source which I don't have. I have attached the zip of the fusionpro template. I am looking for the best way to resize the image. Thank you,
Attached Files
File Type: zip 20302_Shift_Mailer.zip (4.10 MB, 5 views)
Reply With Quote
  #4  
Old April 22nd, 2022, 01:30 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Need help scaling images from url link

Quote:
Originally Posted by rkury14 View Post
Should I be using a graphic window?
Yes, absolutely.
Quote:
Originally Posted by rkury14 View Post
Because that would be asking for a path source which I don't have.
I don't understand what you mean by "a path source". Who is asking for that?

You can create a Graphic rule with exactly the same code as in your Text rule, and assign the rule to a Graphic frame. From the New Rule dialog, select the Graphic radio button at the top, then select Empty Rule and click Next. You can literally copy the content from your Text rule into the Graphic rule.
Quote:
Originally Posted by rkury14 View Post
I have attached the zip of the fusionpro template.
Thanks. I've attached a modified version with a Graphic rule and a Graphic frame, which I think does basically what you want.

I did make a few changes to your rule to clean up some unnecessary code.

I also changed it to first look for "png". The first record doesn't find the graphic without this change. The reason is that, when it looks for the URL with a "tif" extension, the web server returns an XML document with an error instead of the graphic, but because it's returning the XML, FusionPro thinks that it did successfully download the file, but it errors when trying to handle that XML as a graphic. (At least it works this way on Mac; it might still find the right graphic when composed on Windows, such as when you submit it to Producer.)

The moral of the story here is, you shouldn't really "test" for files downloaded from the Internet by extension, the way you can for local files. Your data should include the fully-resolved URL for each graphic, with the filename extension. Then your Graphic rule can be just the one-liner I mentioned in the previous thread:
Code:
return CreateResource(Field("URL"));
Also, in FusionPro 11 and later, you can accomplish this without any rule at all, by simply changing the field type to Graphic. From the menu in Acrobat, select FusionPro -> Data Definition -> Input Options, click Edit Fields, select the field and click Edit, then set the type to Graphic and the Subtype to File name. Then you can insert assign that field directly as the variable for a graphic frame, again, without any rule at all.
Attached Files
File Type: pdf 20302_Shift_Mailer-graphic-rule.pdf (2.29 MB, 5 views)
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old April 22nd, 2022, 05:05 PM
rkury14 rkury14 is offline
Regular Contributor
 
Join Date: May 2014
Location: Tempe, AZ
Posts: 56
Default Re: Need help scaling images from url link

OMG,

Thank you much for that clarification and fixing it for me.

This has really been a learning experience.

You are the best!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.